# How to upgrade SharedTier EKS

## Find the EKS cluster Pulumi Stack configuration file

Enter [main/pool/eks-sharedtier](https://github.com/tidbcloud/shared-cd/tree/main/pool/eks-sharedtier), find the EKS Pulumi Stack configuration file to be upgraded, such as Pulumi.dev-us-east-1-s01.yaml

## Modify the configuration file to

### Upgrade the k8s version(EKS is not allowed to downgrade)

eks-sharedtier:k8s-version: “1.21” # Upgrade the k8s version to 1.21

### Replace the node ami

[Amazon EKS optimized Amazon Linux AMIs](https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html), found the corresponding k8s version, corresponding region (see aws:region in the configuration file), x86 AMI ID

eks-sharedtier:ami-id: ami-0c385d0d99fce057d

## Submit the PR and merge

Merge corresponding branch after review
* main (development environment)
* staging (staging environment)
* prod (production environment)

Wait for the branch CI to run successfully, the overall process is about 50 minutes (39 nodes in total)

## Upgrade process

* first upgrade the control plane, about 40 minutes
* each ASG concurrent upgrade
* **first delete the node**and then start the new node, alternately (about 10 minutes),
* delete the node takes a long time, but will not block start the new node

![](media/asg-upgrade.png)

## View the result
```bash
kubectl version --short # k8s control plane version(Server Version)
Client Version: v1.21.5
Server Version: v1.21.2-eks-0389ca3

kubectl get no # work node version(VERSION Column)
NAME STATUS ROLES AGE     VERSION
ip-10-0-100-133.ec2.internal Ready <none> 6m      v1.21.4-eks-033ce7e
ip-10-0-101-7.ec2.internal   Ready <none> 3m11s   v1.21.4-eks- 033ce7e
ip-10-0-105-108.ec2.internal Ready <none> 8m41s   v1.21.4-eks-033ce7e
ip-10-0-106-186.ec2.internal Ready <none> 9m31s   v1.21.4-eks- 033ce7e
ip-10-0-106-211.ec2.internal Ready <none> 6m36s   v1.21.4-eks-033ce7e
```

## Possible problems

Because the node be deleted first during the ASG upgrade process, the TiDB cluster of SharedTier users may be interrupted twice.
