Upgrade Kubernetes Cluster
This page outlines the process for upgrading the Cluster Control Plane and Node Pool for Terraform-based infrastructure deployments.
When to upgrade
Each new release of the Terraform script artifacts may specify a different version of the Managed Kubernetes Service for each supported cloud provider: AWS (Amazon Web Services), ACS (Azure Cloud Services) or GCP (Google Cloud Platform).
Because Kubernetes version upgrades can introduce breaking changes, simply re-running deploy-cluster.sh may fail or produce unexpected results. To avoid this, you should follow a targeted upgrade process that focuses specifically on updating the Control Plane and Node Pool, without affecting the rest of the infrastructure.
You can also use this process if you need to upgrade the Cluster version independently of the Terraform artifact version.
Upgrade the Control Plane and Node Pool
-
Open the Terraform
variables.tffile for your relevant cloud provider (for example, AWS, ACS, or GCP) and update thecluster_versionvariable to match the Kubernetes version you are upgrading to.vi terraform/aws/variables.tf variable "cluster_version" { .... default = "1.32" }vi terraform/azure/variables.tf variable "cluster_version" { .... default = "1.32" }vi terraform/gcp/variables.tf variable "cluster_version" { .... default = "1.32" } -
Run the
manage-cluster.shscript../scripts/manage-cluster.sh.\scripts\manage-cluster.bat -
Authenticate to cloud provider.
./scripts/terraform.sh authenticate./scripts/terraform.sh authenticate./scripts/terraform.sh authenticate -
Run the
terraform initcommand../scripts/terraform.sh init cluster -
Switch to the directory of the relevant cloud provider.
cd terraform/awscd terraform/azurecd terraform/gcp -
Export the required environment variables to run Terraform.
export TF_VAR_cluster_name=$CLOUD-$ENV export TF_VAR_region=$REGIONexport TF_VAR_cluster_name=$CLOUD-$ENV export TF_VAR_region=$REGIONexport TF_VAR_cluster_name=$CLOUD-$ENV export TF_VAR_region=$REGION export TF_VAR_project=$PROJECT zones=$(gcloud compute zones list --filter="region:${TF_VAR_region}" --format='value(name)' | sort | head -1) export TF_VAR_zones="[\"${zones}\"]" -
Run the
terraform taintcommand to mark the Node Pool for replacement.terraform taint module.kx-aws.module.eks.module.eks_managed_node_group[\"default\"].aws_eks_node_group.this[0]terraform taint module.kx-azure.null_resource.upgrade_default_node_poolThis command is not applicable to GCP.
-
Run the
terraform applycommand to upgrade the Control Plane and Node Pool.terraform apply -target=module.kx-aws.module.eks.module.eks_managed_node_group[\"default\"].aws_eks_node_group.this[0] -target=module.kx-aws.module.eks.aws_eks_cluster.this[0]terraform apply -target=module.kx-azure.azurerm_kubernetes_cluster.cluster -target=module.kx-azure.null_resource.upgrade_default_node_poolterraform apply -target=module.kx-gcp.module.gke.google_container_cluster.primary -target=module.kx-gcp.module.gke.google_container_node_pool.pools[\"gcp-demo-default-node-pool\"] (assumes cluster name is `gcp-demo`)