The module creates a managed Kubernetes cluster (DOKS) in DigitalOcean. Key features:
maintenance node poolSupported Kubernetes versions are 1.35 and newer. DigitalOcean Kubernetes Supported Releases.
Once you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:
shellterraform login solutions.corewide.com
Initialize mandatory providers:
Copy and paste into your Terraform configuration and insert the variables:
hclmodule "tf_do_k8s_doks" {
source = "solutions.corewide.com/digitalocean/tf-do-k8s-doks/digitalocean"
version = "~> 5.4.0"
# specify module inputs here or try one of the examples below
...
}
Initialize the setup:
shellterraform init
Corewide DevOps team strictly follows Semantic Versioning
Specification
to
provide our clients with products that have predictable upgrades between versions. We
recommend
pinning
patch versions of our modules using pessimistic
constraint operator (~>) to prevent breaking changes during upgrades.
To get new features during the upgrades (without breaking compatibility), use
~> 5.4 and run
terraform init -upgrade
For the safest setup, use strict pinning with version = "5.4.0"
|
Module
25% off
|
$750
|
| TOTAL | $750 |
The module creates a managed Kubernetes cluster (DOKS) in DigitalOcean. Key features:
maintenance node poolSupported Kubernetes versions are 1.35 and newer. DigitalOcean Kubernetes Supported Releases.
All notable changes to this project are documented here.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
cluster_autoscaler variable2.881.35destinations sub-parameter of the routing_agent variable (defaults to ["0.0.0.0/0"])1.343.8.3 to 3.13.1) and application (from 0.6.2 to 0.8.1) versions1.331.4 due to using terraform_data resource for keeping the DOKS engine patch version3.12.73(Last version compatible with Helm Terraform provider version 2.0)
routing_agent variable for default network routes overrideRoute custom resource deployment for custom network gateways definitionalekc/kubectl provider dependency, see the Upgrade Notes sectiondigitalocean provider version constraints from ~> 2.16 to ~> 2.501.32BREAKING CHANGE: now the node pools management has been rearranged by unconditionally creating the default maintenance node pool and adding random suffix to the extra node pools
default_node_poolmetrics_server variable to allow Node Selector configuration1.29metrics_server variable parametersvpc is a mandatory input now1.24BREAKING CHANGE: now all node pools have corresponding names in the state instead of abstract indexes which aren't compatible with a new version
metrics-server deployment as Helm releasecluster_ha variable renamed to cluster_ha_enabledfor_each meta-argument instead of count in order to store and reference Node Pool resources with corresponding names instead of abstract indexescluster_maintenance.surge_upgrade variable enables the surge cluster upgrade that speeds up the upgrade and reduces disruptions to workloads using up to 10 additional nodescluster_ha variable to enable new high-availability (multi-master) control planecreate_before_destroy meta-argument in Cluster and Node Pools resources in order to prevent failure during cluster and node pools resources recreationcluster_version - Kubernetes 1.23 and newer are allowed1.23cluster output containing sensitive data now marked as sensitivev3.x to v4.xModule from version 4.0.0 rearranged the node pools management by unconditionally creating the default maintenance node pool and adding random suffix to the extra node pools which is changed on the node pool recreation.
After the module version is upgraded you must update the node selectors for Kubernetes resources to match new custom node pool labels:
from:
yamldoks.digitalocean.com/node-pool: <node-pool-name>
to:
yaml<cluster_name>/node-pool-name: <node-pool-name>
Then apply the new module version.
v4.0.x to v4.1.xThe module from v4.1 has changed the minimal supported Kubernetes version to 1.32. You can skip this chapter if you already use K8s version 1.32 or higher.
The cluster version upgrade itself should pass without downtime. Since it also depends on the apps and services hosted on the cluster, to make sure the cluster version upgrade will pass well, please align with the documentation:
The upgrade should roll one version at a time: from v1.29 to v1.30, then from v1.30 to v1.31, and then from v1.31 to v1.32, and so on.
v4.1.x to v4.2.xThe module from v4.2 has changed the minimal supported digitalocean provider version to 2.50. You can skip this chapter if you already use digitalocean provider version 2.50 or higher.
The module uses the kubectl provider to manage Kubernetes custom resources.
Add the provider block to the required_providers block:
hclterraform {
required_providers {
...
kubectl = {
source = "alekc/kubectl"
version = "~> 2.0"
}
}
}
Fill in required configuration parameters in the provider block and upgrade Terraform configuration:
bashterraform init -upgrade
v4.x to v5.xModule from v5.0 has changed Helm Terraform provider version, which isn't compatible with older versions. After the module version is upgraded, re-init the module to upgrade the provider version. Upgrade the Helm provider version at the project level:
hclterraform {
required_providers {
helm = {
source = "hashicorp/helm"
version = "~> 3.1"
}
}
}
Upgrade project dependencies:
bashterraform init --upgrade
Apply the changes to make sure the state of the resources is up-to-date with the new provider version:
bashterraform apply
v5.0.x to v5.1.xThe module from v5.1 has changed the minimal supported Kubernetes version to 1.33. You can skip this chapter if you already use K8s version 1.33 or higher.
The cluster version upgrade itself should pass without downtime. Since it also depends on the apps and services hosted on the cluster, to make sure the cluster version upgrade will pass well, please align with the documentation:
The upgrade should roll one version at a time.
v5.1.x to v5.2.xThe module from v5.2 has several adjustments that require attention:
Minimal supported Kubernetes version changed to 1.34. You can skip this chapter if you have already used K8s version 1.34 or higher. The cluster version upgrade itself should pass without downtime. Since it also depends on the apps and services hosted on the cluster, to make sure the cluster version upgrade will pass well, please align with the documentation:
The upgrade should roll one version at a time: from v1.33 to v1.34, then from v1.34 to v1.35, and so on
3.13.1 and 0.8.1, respectivelyUpdate the declaration of the module according to the requirements and examples to match the designed configuration.
Now the configuration can be applied:
bashterraform apply
v5.3.x to v5.4.xThe module from v5.4 has changed the minimal supported Kubernetes version to 1.35. You can skip this chapter if you already use K8s version 1.35 or higher.
The cluster version upgrade itself should pass without downtime. Since it also depends on the apps and services hosted on the cluster, to make sure the cluster version upgrade will pass well, please align with the documentation:
The upgrade should roll one version at a time: from v1.34 to v1.35, then from v1.35 to v1.36, and so on.
Create Kubernetes cluster with a single default node pool without auto-scaling:
hclprovider "helm" {
kubernetes = {
host = module.doks.cluster.kube_config[0].host
cluster_ca_certificate = base64decode(module.doks.cluster.kube_config[0].cluster_ca_certificate)
token = module.doks.cluster.kube_config[0].token
}
}
module "doks" {
source = "solutions.corewide.com/digitalocean/tf-do-k8s-doks/digitalocean"
version = "~> 5.4"
name_prefix = "foo"
region = "fra1"
vpc = "506f78a4-e098-11e5-ad9f-000f53306ae1"
node_pools = [
{
name = "node-pool-application"
min_size = 3
},
]
cluster_tags = [
"production",
"app",
]
}
Create Kubernetes cluster with multiple node pools with auto-scaling and auto upgrade:
hclprovider "helm" {
kubernetes = {
host = module.doks.cluster.kube_config[0].host
cluster_ca_certificate = base64decode(module.doks.cluster.kube_config[0].cluster_ca_certificate)
token = module.doks.cluster.kube_config[0].token
}
}
module "doks" {
source = "solutions.corewide.com/digitalocean/tf-do-k8s-doks/digitalocean"
version = "~> 5.4"
name_prefix = "foo"
region = "fra1"
vpc = "506f78a4-e098-11e5-ad9f-000f53306ae1"
cluster_maintenance = {
auto_upgrade = true
surge_upgrade = true
}
cluster_tags = [
"production",
"app",
]
default_node_pool = {
node_size = "s-4vcpu-8gb"
max_size = 3
}
node_pools = [
{
name = "frontend"
min_size = 2
max_size = 3
},
{
name = "backend"
min_size = 2
max_size = 5
},
]
}
Create Kubernetes cluster with routing agent enabled and custom network gateway defined:
hclprovider "helm" {
kubernetes = {
host = module.doks.cluster.kube_config[0].host
cluster_ca_certificate = base64decode(module.doks.cluster.kube_config[0].cluster_ca_certificate)
token = module.doks.cluster.kube_config[0].token
}
}
provider "kubectl" {
apply_retry_count = 15
host = module.doks.cluster.kube_config[0].host
cluster_ca_certificate = base64decode(module.doks.cluster.kube_config[0].cluster_ca_certificate)
token = module.doks.cluster.kube_config[0].token
}
module "doks" {
source = "solutions.corewide.com/digitalocean/tf-do-k8s-doks/digitalocean"
version = "~> 5.4"
name_prefix = "foo"
region = "fra1"
vpc = "506f78a4-e098-11e5-ad9f-000f53306ae1"
routing_agent = {
enabled = true
gateways = ["10.114.0.3"]
}
node_pools = [
{
name = "node-pool-application"
min_size = 3
},
]
cluster_tags = [
"production",
"app",
]
}
| Variable | Description | Type | Default | Required | Sensitive |
|---|---|---|---|---|---|
cluster_tags |
A list of tag names to be applied to the Kubernetes cluster | list(string) |
yes | no | |
name_prefix |
Naming prefix for all the resources created by the module | string |
yes | no | |
region |
The region where the DigitalOcean Kubernetes cluster should be created in | string |
yes | no | |
vpc |
The ID of the VPC where the Kubernetes cluster will be located | string |
yes | no | |
cluster_ha_enabled |
Whether high availability (multi-master) should be enabled for the cluster | bool |
false |
no | no |
cluster_maintenance |
A set of parameters that defines automatic upgrade of the Kubernetes cluster version | object |
{} |
no | no |
cluster_maintenance.auto_upgrade |
Indicates whether the cluster will be automatically upgraded to new patch releases during its maintenance window | bool |
false |
no | no |
cluster_maintenance.maintenance_window_day |
The day of the maintenance window policy. May be one of monday through sunday, or any to indicate an arbitrary week day |
string |
sunday |
no | no |
cluster_maintenance.maintenance_window_start_time |
The start time in UTC of the maintenance window policy in 24-hour clock format (from 00:00 to 23:59) |
string |
01:00 |
no | no |
cluster_maintenance.surge_upgrade |
Indicates whether the cluster will create duplicate upgraded nodes to prevent downtime while upgrading cluster to new patch releases during its maintenance window | bool |
false |
no | no |
cluster_version |
Version of Kubernetes used for the cluster (Major.Minor) |
string |
1.35 |
no | no |
default_node_pool |
Map of the default node pool parameters | object |
{} |
no | no |
default_node_pool.max_size |
If auto-scaling is enabled, this represents the maximum number of nodes that the node pool can be scaled up to | number |
1 |
no | no |
default_node_pool.min_size |
If auto-scaling is enabled, this represents the minimum number of nodes that the node pool can be scaled down to | number |
1 |
no | no |
default_node_pool.node_size |
The type of Droplet to be used as workers in the node pool | string |
s-2vcpu-2gb |
no | no |
metrics_server |
Map of metrics server parameters | object |
{} |
no | no |
metrics_server.app_version |
application version of metrics server to be installed | string |
v0.8.1 |
no | no |
metrics_server.chart_version |
chart version to create metrics server from | string |
3.13.1 |
no | no |
metrics_server.custom_values |
map of custom values to apply to metrics server | map(any) |
{} |
no | no |
node_pools |
List of node pool parameters to create extra node pools | list(object) |
[] |
no | no |
node_pools[*].labels |
A map of key/value pairs to apply to nodes in the pool | map(string) |
{} |
no | no |
node_pools[*].max_size |
If auto-scaling is enabled, this represents the maximum number of nodes that the node pool can be scaled up to | number |
1 |
no | no |
node_pools[*].min_size |
If auto-scaling is enabled, this represents the minimum number of nodes that the node pool can be scaled down to | number |
1 |
no | no |
node_pools[*].name |
A name for the node pool | string |
yes | no | |
node_pools[*].node_size |
The type of Droplet to be used as workers in the node pool | string |
s-2vcpu-2gb |
no | no |
node_pools[*].tags |
A list of tag names to be applied to the node pool | list(string) |
[] |
no | no |
routing_agent |
Routing agent configration parameters | object |
{} |
no | no |
routing_agent.destinations |
List of destination nodes IP ranges | list(string) |
['0.0.0.0/0'] |
no | no |
routing_agent.enabled |
Toggle a routing agent for the cluster | bool |
false |
no | no |
routing_agent.gateways |
List of gateway IP addresses that override the default route | list(string) |
[] |
no | no |
| Output | Description | Type | Sensitive |
|---|---|---|---|
cluster |
Contains attributes of Kubernetes cluster | resource |
yes |
node_pools |
Contains attributes of all node pools | computed |
no |
| Dependency | Version | Kind |
|---|---|---|
terraform |
>= 1.4 |
CLI |
alekc/kubectl |
~> 2.0 |
provider |
digitalocean/digitalocean |
~> 2.73 |
provider |
hashicorp/helm |
~> 3.0 |
provider |
These components are included as is under the terms of their corresponding licenses.
| Component | License |
|---|---|
| Metrics Server | Apache-2.0 |