Terraform wrapper to make a Kubernetes cluster.
devops
digitalocean
digitalocean-kubernetes
iac
kubernetes
kubernetes-cluster
terraform
terraform-module
CC0 isn't OSI-approved, which blocks OpenTofu registry compatibility. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> |
||
|---|---|---|
| .gitignore | ||
| .terraform-docs.yml | ||
| .terraform-version | ||
| cluster.tf | ||
| LICENSE | ||
| main.tf | ||
| outputs.tf | ||
| README.md | ||
| variables.tf | ||
Kubernetes Cluster
Builds a DigitalOcean Kubernetes cluster in a way that makes more sense to me, and is more easily wrapped in a manner to keep the Terraform code DRY.
Usage
module "cluster" {
source = "santiagon610/k8s-cluster/digitalocean"
version = "~> 2"
cluster_name = "my-awesome-cluster"
region = "nyc1"
vpc_uuid = data.digitalocean_vpc.production.id
cluster_tags = ["production"]
initial_node_pool = {
name = "primary"
size = "s-4vcpu-8gb"
min_nodes = 1
max_nodes = 4
auto_scale = true
labels = {
pizza = "pepperoni"
environment = "prod"
}
}
maintenance_policy = {
start_time = "22:00"
day = "monday"
}
}
Caveats
- If
var.k8s_versionis defined and not blank, the module will treat the version of Kubernetes as pinned and will disable automatic upgrades, and as a result will remove the maintenance policy. Although this does not make make thevar.k8s_versioninput mutually exclusive withvar.maintenance_policy, they do render one another essentially inert.
Authentication
Set the DIGITALOCEAN_TOKEN environment variable to your DigitalOcean API
token.
License
Requirements
| Name | Version |
|---|---|
| terraform | >= 1.3.0 |
| digitalocean | >= 2.100.0 |
Providers
| Name | Version |
|---|---|
| digitalocean | >= 2.100.0 |
Modules
No modules.
Resources
| Name | Type |
|---|---|
| digitalocean_kubernetes_cluster.this | resource |
| digitalocean_kubernetes_node_pool.additional | resource |
| digitalocean_kubernetes_versions.this | data source |
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| additional_node_pools | Configuration for additional node pools | map(object({ |
{} |
no |
| cluster_name | Display name of Kubernetes cluster | string |
n/a | yes |
| cluster_tags | Tags to apply to Kubernetes cluster within DigitalOcean console | list(string) |
[] |
no |
| do_registry_integration | Enable integration with DigitalOcean Container Registry | bool |
true |
no |
| ha | Decides whether the control plane is configured for high availability | bool |
false |
no |
| initial_node_pool | Configuration for initial node pool | object({ |
{ |
no |
| k8s_version | Version of k8s control plane to use. If blank, uses data.digitalocean_kubernetes_versions.this.latest_version |
string |
"" |
no |
| maintenance_policy | Maintenance policy for Kubernetes control plane. Ignored if var.k8s_version is defined. |
object({ |
{ |
no |
| region | DigitalOcean region in which to build Kubernetes cluster | string |
"nyc1" |
no |
| vpc_uuid | UUID of the VPC network in which to build Kubernetes cluster | string |
n/a | yes |
Outputs
| Name | Description |
|---|---|
| kubeconfig | Kubernetes configuration for the cluster, provided in HCL and YAML. |