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.

    AWS

    ACS

    GCP

    console

    Copy
    vi terraform/aws/variables.tf
    variable "cluster_version" {
    ....
    default = "1.32"
    }                                        

    console

    Copy
    vi terraform/azure/variables.tf
    variable "cluster_version" {
    ....
    default = "1.32"
    }

    console

    Copy
    vi terraform/gcp/variables.tf
    variable "cluster_version" {
    ....
    default = "1.32"
    }
  2. Run the manage-cluster.sh script.

    Linux

    Windows

    console

    Copy
    ./scripts/manage-cluster.sh

    console

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

    AWS

    ACS

    GCP

    console

    Copy
    ./scripts/terraform.sh authenticate                                

    console

    Copy
    ./scripts/terraform.sh authenticate

    console

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

    console

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

    AWS

    ACS

    GCP

    console

    Copy
    cd terraform/aws                                

    console

    Copy
    cd terraform/azure

    console

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

    AWS

    ACS

    GCP

    console

    Copy
    export TF_VAR_cluster_name=$CLOUD-$ENV
    export TF_VAR_region=$REGION                                

    console

    Copy
    export TF_VAR_cluster_name=$CLOUD-$ENV
    export TF_VAR_region=$REGION

    console

    Copy
    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.

    AWS

    ACS

    GCP

    console

    Copy
    terraform taint module.kx-aws.module.eks.module.eks_managed_node_group[\"default\"].aws_eks_node_group.this[0]
                                        

    console

    Copy
    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.

    AWS

    ACS

    GCP

    console

    Copy
    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]                                

    console

    Copy
    terraform apply -target=module.kx-azure.azurerm_kubernetes_cluster.cluster -target=module.kx-azure.null_resource.upgrade_default_node_pool

    console

    Copy
    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`)