Skip to content

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

  1. Open the Terraform variables.tf file for your relevant cloud provider (for example, AWS, ACS, or GCP) and update the cluster_version variable 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"
    }
    
  2. Run the manage-cluster.sh script.

    ./scripts/manage-cluster.sh
    
    .\scripts\manage-cluster.bat
    
  3. Authenticate to cloud provider.

    ./scripts/terraform.sh authenticate
    
    ./scripts/terraform.sh authenticate
    
    ./scripts/terraform.sh authenticate
    
  4. Run the terraform init command.

    ./scripts/terraform.sh init cluster
    
  5. Switch to the directory of the relevant cloud provider.

    cd terraform/aws
    
    cd terraform/azure
    
    cd terraform/gcp
    
  6. Export the required environment variables to run Terraform.

    export TF_VAR_cluster_name=$CLOUD-$ENV
    export TF_VAR_region=$REGION   
    
    export TF_VAR_cluster_name=$CLOUD-$ENV
    export TF_VAR_region=$REGION
    
    export 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}\"]"
    
  7. Run the terraform taint command 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_pool
    

    This command is not applicable to GCP.

  8. Run the terraform apply command 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_pool
    
    terraform 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`)