Skip to content

Commit

Permalink
feat(doks-public): upgrade kubernetes to 1.23 (#78)
Browse files Browse the repository at this point in the history
* feat(kub 1.23): upgrade kubernetes to 1.23

as per jenkins-infra/helpdesk#3053

* feat(doks/doks-public) split kubernetes versions per cluster: 1.22 for doks and 1.23 for doks-public

Signed-off-by: Damien Duportal <damien.duportal@gmail.com>

* fixup

Signed-off-by: Damien Duportal <damien.duportal@gmail.com>

* fixup

Signed-off-by: Damien Duportal <damien.duportal@gmail.com>

Signed-off-by: Damien Duportal <damien.duportal@gmail.com>
Co-authored-by: Damien Duportal <damien.duportal@gmail.com>
  • Loading branch information
smerle33 and dduportal authored Oct 20, 2022
1 parent 3dc6c94 commit ca24a08
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
8 changes: 0 additions & 8 deletions data.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
data "digitalocean_kubernetes_versions" "k8s" {
version_prefix = var.kubernetes_version
}

data "digitalocean_sizes" "k8s" {
filter {
key = "regions"
values = [var.region]
}
}

output "dok8s-versions" {
value = data.digitalocean_kubernetes_versions.k8s.valid_versions
}
13 changes: 9 additions & 4 deletions doks-cluster.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
data "digitalocean_kubernetes_versions" "doks" {
version_prefix = "1.22."
}

resource "digitalocean_kubernetes_cluster" "doks_cluster" {
name = local.cluster_name
region = var.region
version = local.doks_version
name = local.cluster_name
region = var.region
# `doctl kubernetes options versions` doesn't return anything if the minor k8s version isn't supported anymore, note it can fail the build.
version = data.digitalocean_kubernetes_versions.doks.latest_version
auto_upgrade = var.auto_upgrade
surge_upgrade = true
tags = ["managed-by:terraform"]
Expand All @@ -25,6 +30,6 @@ resource "digitalocean_kubernetes_cluster" "doks_cluster" {
size = local.minimal_node_pool_size
auto_scale = false
node_count = 1
tags = ["node-pool-minimal", local.cluster_name]
tags = ["minimal-node-pool", local.cluster_name]
}
}
13 changes: 9 additions & 4 deletions doks-public-cluster.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
data "digitalocean_kubernetes_versions" "doks-public" {
version_prefix = "1.23."
}

resource "digitalocean_kubernetes_cluster" "doks_public_cluster" {
name = local.public_cluster_name
region = var.region
version = local.doks_version
name = local.public_cluster_name
region = var.region
# `doctl kubernetes options versions` doesn't return anything if the minor k8s version isn't supported anymore, note it can fail the build.
version = data.digitalocean_kubernetes_versions.doks-public.latest_version
auto_upgrade = var.auto_upgrade
surge_upgrade = true
tags = ["managed-by:terraform"]
Expand All @@ -23,6 +28,6 @@ resource "digitalocean_kubernetes_cluster" "doks_public_cluster" {
auto_scale = true
min_nodes = 1
max_nodes = var.autoscaled_node_pool_max_nodes
tags = ["node-pool-publi", local.public_cluster_name]
tags = ["public-node-pool", local.public_cluster_name]
}
}
6 changes: 2 additions & 4 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ resource "random_string" "suffix" {
}

locals {
cluster_name = lower("jenkins-infra-doks-${random_string.suffix.result}")
public_cluster_name = lower("jenkins-infra-doks-public-${random_string.suffix.result}")
# `doctl kubernetes options versions` doesn't return anything if the minor k8s version isn't supported anymore, note it can fail the build.
doks_version = data.digitalocean_kubernetes_versions.k8s.latest_version
cluster_name = lower("jenkins-infra-doks-${random_string.suffix.result}")
public_cluster_name = lower("jenkins-infra-doks-public-${random_string.suffix.result}")
minimal_node_pool_size = "s-1vcpu-2gb" # Available sizes: `doctl compute size list`
public_node_pool_size = "s-4vcpu-8gb" # Available sizes: `doctl compute size list`
}
6 changes: 0 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ variable "region" {
description = "DOKS region (availables regions: `doctl kubernetes options regions`)"
}

variable "kubernetes_version" {
type = string
default = "1.22."
description = "Kubernetes version in format '<MAJOR>.<MINOR>.'"
}

variable "autoscaled_node_pool_size" {
type = string
default = "c-16" # CPU optimized, 16vCPU/32GB (at 2022/02/17)
Expand Down

0 comments on commit ca24a08

Please sign in to comment.