Skip to content

Commit

Permalink
Add config to list the latest supported k8s versions from AKS via ter…
Browse files Browse the repository at this point in the history
…raform
  • Loading branch information
sgibson91 committed Sep 17, 2024
1 parent c768b88 commit 09aded8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
21 changes: 21 additions & 0 deletions terraform/azure/cluster.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# This data resource and output provides information on the latest available k8s
# versions supported by Azure Kubernetes Service. This can be used when specifying
# versions to upgrade to via the kubernetes_version variable.
#
# To get the output of relevance, run:
#
# terraform plan -var-file=projects/$CLUSTER_NAME.tfvars
#
# ref: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/kubernetes_service_versions
data "azurerm_kubernetes_service_versions" "k8s_version_prefixes" {
location = var.location

for_each = var.k8s_version_prefixes
version_prefix = each.value
}
output "latest_supported_k8s_versions" {
value = { #data.azurerm_kubernetes_service_versions.current.versions
for k, v in data.azurerm_kubernetes_service_versions.k8s_version_prefixes: k => v.latest_version
}
}

# ref: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster
resource "azurerm_kubernetes_cluster" "jupyterhub" {
name = "hub-cluster"
Expand Down
14 changes: 12 additions & 2 deletions terraform/azure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,20 @@ variable "kubernetes_version" {
Version of kubernetes the cluster should use.
`az aks get-versions --location westus2 -o table` will
display the list of available versions.
display the list of available versions. Or the terraform
output called latest_supported_k8s_versions if running against
an existing cluster.
EOT
}

variable "k8s_version_prefixes" {
type = set(string)
default = [ "1.29", "1.30", "1." ]
description = <<-EOT
A list of k8s version prefixes that can be evaluated to their latest version by
the output defined in cluster.tf called latest_supported_k8s_versions.
EOT
}

variable "global_container_registry_name" {
type = string
Expand Down Expand Up @@ -188,4 +198,4 @@ variable "budget_alert_amount" {
Amount of *forecasted spend* at which to send a billing alert. Current practice
is to set this to the average of the last 3 months expenditure + 20%.
EOT
}
}

0 comments on commit 09aded8

Please sign in to comment.