This document outlines the procedure for safely upgrading Kubernetes versions on EKS node groups in the GistPin infrastructure.
The upgrade process automates the safe rolling upgrade of Kubernetes node groups with the following features:
- Comprehensive pre-upgrade validation checks
- Cordoning and draining of nodes before termination
- Gradual rolling replacement of nodes
- Post-upgrade validation
- Automated rollback capability
Before running any upgrade, ensure you have:
-
Required tools installed:
- AWS CLI (configured with appropriate permissions)
- kubectl (configured to access your cluster)
- jq (for JSON processing)
-
AWS permissions required:
eks:DescribeClustereks:DescribeNodegroupeks:UpdateNodegroupVersionec2:DescribeSubnets- Permissions to update kubeconfig
-
Cluster readiness:
- The cluster control plane must already be upgraded to the target Kubernetes version
- You can only upgrade one minor version at a time (e.g., 1.27 → 1.28 is supported, 1.27 → 1.29 is not)
- The node group must have enough capacity to add new nodes during the rolling upgrade (max size > current desired size)
The pre-upgrade-checks.sh script automatically verifies all prerequisites before an upgrade can begin:
./infrastructure/scripts/pre-upgrade-checks.sh <cluster-name> <node-group-name> <target-version>- Dependency validation: Verifies AWS CLI, kubectl, and jq are installed
- Cluster existence: Confirms the specified EKS cluster exists and is accessible
- Node group eligibility:
- Verifies the node group exists
- Checks that the target version is different from current version
- Validates only one minor version upgrade is attempted
- Confirms target version matches cluster control plane version
- Resource capacity: Ensures node group has enough max capacity to add new nodes
- Cluster health:
- All nodes are in Ready state
- No problematic PodDisruptionBudgets that would block draining
- All kube-system pods are running
- Subnet capacity: Verifies sufficient IP addresses are available in subnets
- Node group status: Confirms the node group is in ACTIVE state with no ongoing operations
To perform a rolling upgrade of a node group:
./infrastructure/scripts/upgrade-node-group.sh <cluster-name> <node-group-name> <target-version>- Pre-flight: Runs all pre-upgrade checks to ensure eligibility
- Initiate EKS upgrade: Triggers the AWS EKS node group version update
- Wait for new nodes: Waits for EKS to provision new nodes with the target version
- Process old nodes sequentially:
- Cordon: Marks the node as unschedulable to prevent new pods from being assigned
- Drain: Evicts all existing pods from the node (respects PodDisruptionBudgets)
- Waits for workloads to reschedule onto new nodes
- Post-upgrade validation: After all nodes are replaced, verifies:
- All nodes are running the target Kubernetes version
- All nodes are in Ready state
- All pods are running correctly
- The node group is back to ACTIVE state
If an upgrade fails or issues are discovered after upgrade, you can rollback to the previous version:
./infrastructure/scripts/upgrade-node-group.sh <cluster-name> <node-group-name> <original-version> --rollback- The rollback script retrieves the node group details
- Initiates an EKS node group version update back to the original version
- Waits for the rollback operation to complete
- Verifies all nodes are running the original version
- Performs health checks to ensure cluster stability after rollback
- Test first: Always test the upgrade procedure in a staging environment first
- Schedule during low traffic: Run upgrades during periods of lower application traffic
- Monitor closely: Keep an eye on cluster metrics, application logs, and node health during the upgrade
- Backup critical data: Ensure all persistent volumes have recent backups before performing infrastructure changes
- Upgrade sequentially: If upgrading multiple node groups, upgrade them one at a time to maintain capacity
- Verify workload resiliency: Ensure your applications are designed to tolerate node failures and rescheduling
- Node draining fails: This is often due to PodDisruptionBudgets that block evictions. Check the pre-upgrade warnings for PDBs with 0 disruptions allowed.
- New nodes fail to join: Check subnet IP capacity, security group configurations, and AWS service limits.
- Upgrade times out: The script has built-in timeouts. If this happens frequently, you may need to adjust timings for larger clusters.
- Workload issues after upgrade: Check application logs for compatibility issues with the new Kubernetes version. Roll back immediately if critical issues are found.
In case of issues during upgrade that require immediate assistance, follow the emergency procedures outlined in emergency-procedures.md.