Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
386 changes: 328 additions & 58 deletions AGENTS.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ validate: .init
test: validate
docker exec \
test-container-$(GIT_SHA) \
entrypoint tofu apply --target module.aks_zero --target module.eks_zero --target module.gke_zero --input=false --auto-approve
entrypoint tofu apply --target module.aks_zero --target module.eks_zero --target module.gke_zero --target module.scw_zero --input=false --auto-approve
docker exec \
test-container-$(GIT_SHA) \
entrypoint tofu apply --target module.eks_zero_nginx --input=false --auto-approve
Expand Down Expand Up @@ -95,6 +95,7 @@ shell: .check-container
-e KBST_AUTH_AWS \
-e KBST_AUTH_AZ \
-e KBST_AUTH_GCLOUD \
-e KBST_AUTH_SCW \
-e HOME=/infra/tests/.user \
--workdir /infra/tests \
ghcr.io/kbst/terraform-kubestack/dev:test-$(GIT_SHA)-${DOCKER_TARGET} \
Expand Down
File renamed without changes.
29 changes: 29 additions & 0 deletions oci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ RUN echo "GOOGLE_CLOUD_SDK_VERSION: ${GOOGLE_CLOUD_SDK_VERSION}" \
RUN /opt/google/bin/gcloud components install gke-gcloud-auth-plugin


#
#
# Scaleway builder
FROM builder AS scw-builder

ARG TARGETARCH

# https://github.com/scaleway/scaleway-cli/releases
ARG SCALEWAY_CLI_VERSION=2.35.0

RUN echo "SCALEWAY_CLI_VERSION: ${SCALEWAY_CLI_VERSION}" \
&& curl -LO https://github.com/scaleway/scaleway-cli/releases/download/v${SCALEWAY_CLI_VERSION}/scaleway-cli_${SCALEWAY_CLI_VERSION}_linux_${TARGETARCH} \
&& mv scaleway-cli_${SCALEWAY_CLI_VERSION}_linux_${TARGETARCH} /opt/bin/scw \
&& chmod +x /opt/bin/scw \
&& /opt/bin/scw version


#
#
# Azure builder
Expand Down Expand Up @@ -231,6 +248,15 @@ COPY --from=azure-builder /opt/azure /opt/azure
ENV PATH=$PATH:/opt/azure/bin


#
#
# Scaleway variant
FROM final-base AS scw

# Scaleway
COPY --from=scw-builder /opt/bin/scw /opt/bin/scw


#
#
# Default (multi-cloud) variant
Expand All @@ -247,3 +273,6 @@ ENV PATH=$PATH:/opt/google/bin
# Azure
COPY --from=azure-builder /opt/azure /opt/azure
ENV PATH=$PATH:/opt/azure/bin

# Scaleway
COPY --from=scw-builder /opt/bin/scw /opt/bin/scw
3 changes: 3 additions & 0 deletions quickstart/src/configurations/_shared/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ In case of the automation being unavailable, upgrades requiring manual steps or
# for GCP
gcloud init
gcloud auth application-default login

# for Scaleway
scw init
```

1. Select desired environment
Expand Down
10 changes: 0 additions & 10 deletions quickstart/src/configurations/aks/Dockerfile.loc

This file was deleted.

10 changes: 0 additions & 10 deletions quickstart/src/configurations/eks/Dockerfile.loc

This file was deleted.

10 changes: 0 additions & 10 deletions quickstart/src/configurations/gke/Dockerfile.loc

This file was deleted.

10 changes: 0 additions & 10 deletions quickstart/src/configurations/multi-cloud/Dockerfile.loc

This file was deleted.

60 changes: 60 additions & 0 deletions quickstart/src/configurations/multi-cloud/scw_zero_cluster.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module "scw_zero" {
source = "github.com/kbst/terraform-kubestack//scaleway/cluster?ref={{version}}"

configuration = {
# apps environment
apps = {
# Set name_prefix used to generate the cluster name
# [name_prefix]-[workspace]-[region]
# e.g. name_prefix = kbst becomes: `kbst-apps-fr-par`
# for small orgs the name works well,
# for bigger orgs consider department or team names
name_prefix = ""

# Set the base_domain used to generate the FQDN of the cluster
# [cluster_name].[provider_name].[base_domain]
# e.g. kbst-apps-fr-par.scw.infra.example.com
# The domain must be registered with Scaleway Domains and DNS
base_domain = ""

# The Scaleway region to deploy the clusters in
# e.g. "fr-par", "nl-ams", "pl-waw"
region = ""

# Kubernetes version for the cluster
# Use a minor version string to allow patch upgrades, e.g. "1.32"
cluster_version = "1.32"

# Container Network Interface plugin
# Options: "cilium", "calico", "weave", "flannel", "kilo"
cni = "cilium"

# Whether to delete additional resources (load-balancers, block volumes,
# the private network if empty) created in Kubernetes when deleting the cluster.
# Set to true only if you want these resources cleaned up automatically on destroy.
delete_additional_resources = false

# Default node pool configuration
default_node_pool = {
# Commercial node type — see `scw k8s node-pool list-available-types`
node_type = "DEV1-M"

# Initial number of nodes in the pool
size = 1

# Minimum and maximum size for autoscaling
min_size = 1
max_size = 1

# Enable Scaleway's cluster autoscaler for this pool
autoscaling = false

# Enable automatic node replacement on failure
autohealing = true
}
}

# ops environment, inherits from apps
ops = {}
}
}
24 changes: 24 additions & 0 deletions quickstart/src/configurations/multi-cloud/scw_zero_providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
provider "scaleway" {
# region is read from SCW_DEFAULT_REGION environment variable
# or can be set explicitly, e.g.:
# region = "fr-par"
}

provider "kustomization" {
alias = "scw_zero"
kubeconfig_raw = module.scw_zero.kubeconfig
}

locals {
scw_zero_kubeconfig = yamldecode(module.scw_zero.kubeconfig)
}

provider "kubernetes" {
alias = "scw_zero"

host = local.scw_zero_kubeconfig["clusters"][0]["cluster"]["server"]
token = local.scw_zero_kubeconfig["users"][0]["user"]["token"]
cluster_ca_certificate = base64decode(
local.scw_zero_kubeconfig["clusters"][0]["cluster"]["certificate-authority-data"]
)
}
4 changes: 4 additions & 0 deletions quickstart/src/configurations/multi-cloud/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ terraform {
kustomization = {
source = "kbst/kustomization"
}

scaleway = {
source = "scaleway/scaleway"
}
}

required_version = ">= 0.15"
Expand Down
1 change: 1 addition & 0 deletions quickstart/src/configurations/scw/.gitignore
1 change: 1 addition & 0 deletions quickstart/src/configurations/scw/.user
1 change: 1 addition & 0 deletions quickstart/src/configurations/scw/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM {{image_name}}:{{image_tag}}-scw
1 change: 1 addition & 0 deletions quickstart/src/configurations/scw/README.md
44 changes: 44 additions & 0 deletions quickstart/src/configurations/scw/scw_zero_cluster.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module "scw_zero" {
source = "github.com/kbst/terraform-kubestack//scaleway/cluster?ref={{version}}"

configuration = {
# apps environment
apps = {
# Set name_prefix used to generate the cluster name
# [name_prefix]-[workspace]-[region]
# e.g. name_prefix = kbst becomes: `kbst-apps-fr-par`
# for small orgs the name works well,
# for bigger orgs consider department or team names
name_prefix = ""

# Set the base_domain used to generate the FQDN of the cluster
# [cluster_name].[provider_name].[base_domain]
# e.g. kbst-apps-fr-par.scw.infra.example.com
# The domain must be registered with Scaleway Domains and DNS
base_domain = ""

# The Scaleway region to deploy the cluster in
# e.g. "fr-par", "nl-ams", "pl-waw"
region = ""

default_node_pool = {
# Commercial node type — must be available in every zone listed below.
# Run `scw k8s node-pool list-available-types` to list types per zone.
node_type = "PRO2-XXS"

# Availability zones to distribute the default node pool across.
# One pool is created per zone. Must be explicitly specified.
# e.g. fr-par: ["fr-par-1", "fr-par-2", "fr-par-3"]
# e.g. nl-ams: ["nl-ams-1", "nl-ams-2", "nl-ams-3"]
# e.g. pl-waw: ["pl-waw-1", "pl-waw-2", "pl-waw-3"]
zones = []

min_size = 1
max_size = 2
}
}

# ops environment, inherits from apps
ops = {}
}
}
24 changes: 24 additions & 0 deletions quickstart/src/configurations/scw/scw_zero_providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
provider "scaleway" {
# region is read from SCW_DEFAULT_REGION environment variable
# or can be set explicitly, e.g.:
# region = "fr-par"
}

provider "kustomization" {
alias = "scw_zero"
kubeconfig_raw = module.scw_zero.kubeconfig
}

locals {
scw_zero_kubeconfig = yamldecode(module.scw_zero.kubeconfig)
}

provider "kubernetes" {
alias = "scw_zero"

host = local.scw_zero_kubeconfig["clusters"][0]["cluster"]["server"]
token = local.scw_zero_kubeconfig["users"][0]["user"]["token"]
cluster_ca_certificate = base64decode(
local.scw_zero_kubeconfig["clusters"][0]["cluster"]["certificate-authority-data"]
)
}
13 changes: 13 additions & 0 deletions quickstart/src/configurations/scw/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
terraform {
required_providers {
scaleway = {
source = "scaleway/scaleway"
}

kustomization = {
source = "kbst/kustomization"
}
}

required_version = ">= 0.15"
}
36 changes: 36 additions & 0 deletions scaleway/cluster/ingress.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
resource "scaleway_lb_ip" "current" {
count = try(coalesce(local.cfg.disable_default_ingress, null), false) ? 0 : 1

project_id = local.cfg.project_id

tags = concat(module.cluster_metadata.tags, try(coalesce(local.cfg.extra_tags, null), []))
}

resource "scaleway_domain_zone" "current" {
count = try(coalesce(local.cfg.disable_default_ingress, null), false) ? 0 : 1

project_id = local.cfg.project_id

domain = local.cfg.base_domain
subdomain = trimsuffix(module.cluster_metadata.fqdn, ".${local.cfg.base_domain}")
}

resource "scaleway_domain_record" "host" {
count = try(coalesce(local.cfg.disable_default_ingress, null), false) ? 0 : 1

dns_zone = scaleway_domain_zone.current[0].id
name = ""
type = "A"
data = scaleway_lb_ip.current[0].ip_address
ttl = 300
}

resource "scaleway_domain_record" "wildcard" {
count = try(coalesce(local.cfg.disable_default_ingress, null), false) ? 0 : 1

dns_zone = scaleway_domain_zone.current[0].id
name = "*"
type = "A"
data = scaleway_lb_ip.current[0].ip_address
ttl = 300
}
34 changes: 34 additions & 0 deletions scaleway/cluster/kubeconfig.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
locals {
kubeconfig = yamlencode({
apiVersion = "v1"
kind = "Config"
clusters = [
{
cluster = {
server = scaleway_k8s_cluster.current.kubeconfig[0].host
certificate-authority-data = scaleway_k8s_cluster.current.kubeconfig[0].cluster_ca_certificate
}
name = scaleway_k8s_cluster.current.name
}
]
users = [
{
user = {
token = scaleway_k8s_cluster.current.kubeconfig[0].token
}
name = scaleway_k8s_cluster.current.name
}
]
contexts = [
{
context = {
cluster = scaleway_k8s_cluster.current.name
user = scaleway_k8s_cluster.current.name
}
name = scaleway_k8s_cluster.current.name
}
]
current-context = scaleway_k8s_cluster.current.name
preferences = {}
})
}
Loading
Loading