Skip to content
Draft
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
7 changes: 5 additions & 2 deletions do/k8s/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
source = "digitalocean/digitalocean"
version = "~> 2.29.0"
}
}
Expand All @@ -26,11 +26,14 @@ resource "digitalocean_kubernetes_cluster" "k8s_cluster" {
name = "default-pool"
size = var.k8s.node_size
node_count = var.k8s.node_count
auto_scale = var.k8s.min_nodes != null && var.k8s.max_nodes != null
min_nodes = var.k8s.min_nodes
max_nodes = var.k8s.max_nodes
}
}

resource "digitalocean_container_registry" "container_registry" {
name = var.registry
name = var.registry
subscription_tier_slug = var.container_registry_plan
}

Expand Down
12 changes: 11 additions & 1 deletion do/k8s/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,22 @@ variable "registry" {
variable "k8s" {
type = object({
node_size = string
node_count = string
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node count should be a number, not a string

node_count = optional(number)
min_nodes = optional(number)
max_nodes = optional(number)
})
default = {
node_size = "s-2vcpu-2gb"
node_count = 1
}

validation {
condition = (
(var.k8s.node_count != null && (var.k8s.min_nodes == null && var.k8s.max_nodes == null)) ||
(var.k8s.node_count == null && (var.k8s.min_nodes != null && var.k8s.max_nodes != null))
)
error_message = "You need to indicate either node count or min_nodes with max_nodes for enabling autoscaling, not both options"
}
}

variable "container_registry_plan" {
Expand Down