Skip to content

Repository files navigation

terraform-scaleway-kapsule-cluster

Creates a Scaleway Kubernetes Kapsule cluster.

There is no maintained Kapsule module in the Scaleway ecosystem. The most-used one defaults kubernetes_version to a release that went end-of-life years ago, and its CNI validation rejects valid plugins while accepting ones no supported version offers. This module exists to be the boring, correct alternative.

Pair it with terraform-scaleway-kapsule-pool for node pools and terraform-scaleway-kapsule-acl to restrict the API server.

Usage

module "cluster" {
  source  = "mitis-cloud/kapsule-cluster/scaleway"
  version = "~> 1.0"

  name               = "platform"
  kubernetes_version = "1.36"
  type               = "kapsule-dedicated-4"

  private_network_id = module.vpc.private_network_ids["main"]
  pod_cidr           = "10.32.0.0/14"
  service_cidr       = "10.36.0.0/16"
  service_dns_ip     = "10.36.0.10"

  autoscaler = {
    expander = "price"
  }

  tags = {
    environment = "production"
  }
}

Scaleway behaviour worth knowing

auto_upgrade forces a minor-only version pin. With auto-upgrade enabled the API rejects a patch pin:

only minor version x.y can be used with auto upgrade enabled

Auto-upgrade owns the patch level, so you give it "1.36". With auto-upgrade disabled you must give a full "1.36.4" instead. The module enforces both directions at plan time rather than letting you discover it at apply.

kubernetes_version has no default, on purpose. Scaleway supports each minor for 14 months and force-upgrades unsupported clusters within 30 days. A module default is a liability here, so this one asks.

The API server is always public. Scaleway does not support a control plane without a public IP. Network placement gives you nothing; restrict access with an ACL. Note also that control-plane reachability depends on a Load Balancer in the region's primary zone — that holds even for HA dedicated control planes, so a primary-zone outage takes the control plane down regardless of how many zones your nodes span.

Four settings are immutable. private_network_id, pod_cidr, service_cidr and service_dns_ip all force replacement of the entire cluster. Get them right on the first apply.

delete_additional_resources defaults to false. True lets a cluster deletion also remove the Load Balancers and Block Storage volumes it created — including the volumes backing your PersistentVolumes. The default is the safe one; it trades orphaned resources for not losing data to a terraform destroy.

Free control planes cap etcd at 55 MB. That is small once Argo CD Applications and similar custom resources accumulate. Dedicated tiers raise it to 200 MB but carry a 30-day commitment, and the Organization quota permits only one dedicated control plane until identity validation is completed.

Examples

  • complete — private-network cluster with autoscaler tuning.

Requirements

Name Version
terraform >= 1.5.0
scaleway >= 2.81, < 3.0

Providers

Name Version
scaleway >= 2.81, < 3.0

Resources

Name Type
scaleway_k8s_cluster.this resource

Inputs

Name Description Type Default Required
kubernetes_version Kubernetes version.

Deliberately has no default. Every stale Scaleway module in the wild pins a
default that has since gone end-of-life, and silently inheriting a dead version
is worse than being asked.

When auto_upgrade.enable is true this MUST be minor-only, e.g. "1.36"; the
API rejects a patch pin with only minor version x.y can be used with auto<br/>upgrade enabled, because auto-upgrade owns the patch level. With auto-upgrade
disabled a full "1.36.4" is required instead. The module enforces both
directions at plan time.
string n/a yes
name Cluster name. string n/a yes
admission_plugins Additional Kubernetes admission plugins to enable. list(string) [] no
apiserver_cert_sans Additional Subject Alternative Names on the API server certificate. list(string) [] no
auto_upgrade Patch-level auto-upgrade window. Does not cross minor versions; the minor must still be bumped deliberately.
object({
enable = optional(bool, true)
maintenance_window_day = optional(string, "sunday")
maintenance_window_start_hour = optional(number, 3)
})
{} no
autoscaler Cluster autoscaler tuning. Any field left null keeps Scaleway's default.

expander accepts random, most_pods, least_waste, priority or price.
price makes scale-up prefer the cheapest node group that fits the pending pods,
which matters on Scaleway because there is no spot market to lean on.
object({
disable_scale_down = optional(bool)
scale_down_delay_after_add = optional(string)
scale_down_unneeded_time = optional(string)
scale_down_utilization_threshold = optional(number)
estimator = optional(string)
expander = optional(string)
expendable_pods_priority_cutoff = optional(number)
balance_similar_node_groups = optional(bool)
ignore_daemonsets_utilization = optional(bool)
max_graceful_termination_sec = optional(number)
skip_nodes_with_local_storage = optional(bool)
})
{} no
cni CNI plugin. Cilium is Scaleway's default. string "cilium" no
create Whether to create any resources. bool true no
delete_additional_resources On cluster deletion, also delete resources the cluster created out-of-band:
Load Balancers, and the Block Storage volumes backing PersistentVolumes.

Defaults to false so a destroy cannot silently take persistent data with it. The
cost of false is orphaned resources that must be cleaned up by hand.
bool false no
description Cluster description. string null no
feature_gates Kubernetes feature gates to enable, for example HPAScaleToZero. list(string) [] no
open_id_connect Configure the API server to trust an external OIDC provider for user authentication. Unrelated to authenticating against the Scaleway API, which has no OIDC support.
object({
issuer_url = string
client_id = string
username_claim = optional(string)
username_prefix = optional(string)
groups_claim = optional(list(string))
groups_prefix = optional(string)
required_claim = optional(list(string))
})
null no
pod_cidr CIDR for pod addresses. Must not overlap the private network or the service CIDR. IMMUTABLE. string null no
private_network_id Private network to attach the cluster to. Scaleway creates one automatically when
null, assigning it a /22.

IMMUTABLE: changing it replaces the entire cluster.
string null no
project_id Scaleway Project ID. Defaults to the provider's project when null. string null no
region Scaleway region. Defaults to the provider's region when null. string null no
service_cidr CIDR for ClusterIP services. Must not overlap the private network or the pod CIDR. IMMUTABLE. string null no
service_dns_ip Address of the cluster DNS service. Must sit inside service_cidr. IMMUTABLE. string null no
tags Tags applied to the cluster. Rendered as key=value strings, since Scaleway tags are a list rather than a map. map(string) {} no
timeouts Custom operation timeouts. Cluster creation typically takes around three minutes.
object({
create = optional(string)
update = optional(string)
delete = optional(string)
})
{} no
type Control plane offer.

kapsule is free but caps etcd at 55 MB and carries no SLA. Dedicated tiers
raise that to 200 MB and add an HA API server, audit logs and a 99.5% SLA, but
carry a 30-day commitment, and the Organization quota permits only one dedicated
control plane until identity validation is completed.

Prefix with multicloud for Kosmos clusters, which accept external nodes but
cannot use Private Networks.
string "kapsule" no
upgrade_pools Upgrade node pools alongside the control plane when the cluster version changes. bool true no

Outputs

Name Description
apiserver_url API server endpoint.

Always public: Scaleway does not support a control plane without a public IP.
Restrict access with an ACL rather than by network placement.
id Composite ID of the cluster, in {region}/{uuid} form. This is what the pool and ACL modules expect.
kubeconfig Full kubeconfig for the cluster. Sensitive: it carries a cluster-admin credential.
kubeconfig_cluster_ca_certificate Cluster CA certificate from the generated kubeconfig.
kubeconfig_host API server host from the generated kubeconfig, for wiring the kubernetes or helm providers.
kubeconfig_token Bearer token from the generated kubeconfig.
kubernetes_version Kubernetes version currently reported by the cluster, which is the resolved patch level when auto-upgrade is enabled.
name Cluster name.
status Cluster status reported by Scaleway.
upgrade_available Whether Scaleway offers a newer version for this cluster.
uuid Bare UUID of the cluster, for APIs and CLI commands that reject the composite form.
wildcard_dns Scaleway-managed wildcard DNS suffix for the cluster.

License

Apache 2.0. See LICENSE.

Releases

Packages

Contributors

Languages