Skip to content

Commit 108ea03

Browse files
authored
feat: Upgrade eks and addons to 1.21, improve k8s upgrade docs (#212)
* feat: Upgrade eks and addons to 1.21, improve k8s upgrade docs * fix: Moved import statements in k8s cluster doc
1 parent f03f6d1 commit 108ea03

3 files changed

Lines changed: 68 additions & 46 deletions

File tree

doc-site/docs/guides/kubernetes-cluster.md

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Operating your Kubernetes Cluster
33
sidebar_label: Kubernetes Cluster operations
44
sidebar_position: 2
55
---
6+
import Tabs from '@theme/Tabs';
7+
import TabItem from '@theme/TabItem';
68

79
# Kubernetes resources
810

@@ -141,36 +143,84 @@ This process can vary a bit depending on the amount of free resources you have a
141143
- Re-enable the cluster autoscaler
142144
- `k scale deployments/cluster-autoscaler -n kube-system --replicas=1`
143145

144-
*In the case that you determine you don't want to terminate the instance but you have already drained it, the cluster won't schedule any new pods to that node until you uncordon it:*
146+
:::note
147+
In the case that you determine you don't want to terminate the instance but you have already drained it, the cluster won't schedule any new pods to that node until you uncordon it:
145148
- `k uncordon <node name>`
149+
:::
146150

147151
## How do I upgrade a cluster to a new version of EKS?
148152

149-
Occasionally you may need to upgrade an EKS cluster. This is usually a pretty painless process, and there’s a ton of documentation online about it.
153+
Occasionally you may need to upgrade an EKS cluster. This is usually a pretty painless process and there’s a ton of documentation online about it.
150154

151-
As part of this process you will need to upgrade the cluster itself, and some core components. Kubernetes has various applications that run as deployments or daemonsets in the kube-system namespace like coredns, kube-proxy and the AWS VPC CNI provider called aws-node.
155+
As part of this process you will need to upgrade the cluster itself, and some core components. Kubernetes has various applications that run as deployments or daemonsets in the `kube-system` namespace like `coredns`, `kube-proxy` and the AWS VPC CNI provider called `aws-node`.
152156

153157
This document has great instructions on upgrading all of the different pieces, including listing the appropriate versions of the core components for each version of Kubernetes.
154158

155159
[https://docs.aws.amazon.com/eks/latest/userguide/update-cluster.html](https://docs.aws.amazon.com/eks/latest/userguide/update-cluster.html)
156160

157-
When doing this from terraform you should be able to go into the tf and change the version of the cluster. It should start the upgrade process, rather than tearing down the cluster and rebuilding it. This will make the cluster inaccessible through the AWS console for about 20 minutes, ***though everything in the cluster should continue to work normally, serve traffic, etc.***
161+
When doing this from terraform you should be able to go into the tf and change the version of the cluster and addons and apply. It should start the upgrade process, rather than tearing down the cluster and rebuilding it. This will make the cluster inaccessible through the AWS console for about 20 minutes.
162+
:::tip
163+
Everything in the cluster should continue to work normally, serve traffic, etc. during this process because the worker nodes and all your workloads are not affected at this point.
164+
:::
165+
166+
To get the latest version of the EKS addons, you can use these AWS CLI commands:
167+
<Tabs
168+
values={[
169+
{label: 'vpc-cni', value: 'vpc-cni'},
170+
{label: 'kube-proxy', value: 'kube-proxy'},
171+
{label: 'coredns', value: 'coredns'},
172+
]}
173+
>
174+
<TabItem value="vpc-cni">
175+
The item marked with "True" is the default for that version.
158176

177+
```shell
178+
aws eks describe-addon-versions \
179+
--addon-name vpc-cni \
180+
--kubernetes-version <version, e.g. 1.21 > \
181+
--query "addons[].addonVersions[].[addonVersion, compatibilities[].defaultVersion]" \
182+
--output text
183+
```
184+
185+
</TabItem>
186+
<TabItem value="kube-proxy">
187+
The item marked with "True" is the default for that version.
188+
189+
```shell
190+
aws eks describe-addon-versions \
191+
--addon-name kube-proxy \
192+
--kubernetes-version <version, e.g. 1.21 > \
193+
--query "addons[].addonVersions[].[addonVersion, compatibilities[].defaultVersion]" \
194+
--output text
195+
```
196+
197+
</TabItem>
198+
<TabItem value="coredns">
199+
The item marked with "True" is the default for that version.
200+
201+
```shell
202+
aws eks describe-addon-versions \
203+
--addon-name coredns \
204+
--kubernetes-version <version, e.g. 1.21 > \
205+
--query "addons[].addonVersions[].[addonVersion, compatibilities[].defaultVersion]" \
206+
--output text
207+
```
208+
209+
</TabItem>
210+
</Tabs>
159211
The process should be:
160212

161-
- Update the API version number in terraform
162-
- Update the AMI for the ASG to the AMI for the corresponding version of EKS in eks.tf and apply terraform
163-
- See this page: [https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html](https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html)
164-
- This should update the worker group, but not affect any of the running nodes
165-
- Update any core components if necessary, as mentioned in the aws update-cluster documentation
166-
- Run terraform apply
167-
- Drain and remove the old nodes from the cluster. New ones will come up in their place with the new AMI
168-
- `k get nodes`
169-
- `k drain --ignore-daemonsets <node name>`
170-
- Then terminate the instance in AWS Console
171-
- Do the drain/delete process with one node at a time. Wait for a new node to be available before running the process on a second one. This will prevent any traffic from being lost.
213+
- Update the addon versions versions in `<env>/main.tf` to match the correct versions for the new cluster version. See the tabs above or [read the AWS docs here](https://docs.aws.amazon.com/eks/latest/userguide/eks-add-ons.html)
214+
- Update the `eks_cluster_version` in terraform
215+
- Run `terraform apply`
216+
- Update your nodes to the new version
217+
- `aws eks update-nodegroup-version --cluster-name <cluster name> --nodegroup-name <cluster name>-main` ( if you've made changes, specify the correct node group here)
218+
219+
OR
172220

221+
- Go into the AWS EKS console and hit update under Configuration > Compute
173222

223+
This will bring up new nodes, gracefully drain your workloads onto them while preventing new pods from being scheduled to the old ones, then take down the old nodes. If your workloads are set up with multiple replicas there should be no downtime during this process.
174224

175225
## More resources
176226

templates/docs/kubernetes.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -138,34 +138,6 @@ This process can vary a bit depending on the amount of free resources you have a
138138
*In the case that you determine you don't want to terminate the instance but you have already drained it, the cluster won't schedule any new pods to that node until you uncordon it:*
139139
- `k uncordon <node name>`
140140

141-
## How do I upgrade a cluster to a new version of EKS?
142-
143-
Occasionally you may need to upgrade an EKS cluster. This is usually a pretty painless process, and there’s a ton of documentation online about it.
144-
145-
As part of this process you will need to upgrade the cluster itself, and some core components. Kubernetes has various applications that run as deployments or daemonsets in the kube-system namespace like coredns, kube-proxy and the AWS VPC CNI provider called aws-node.
146-
147-
This document has great instructions on upgrading all of the different pieces, including listing the appropriate versions of the core components for each version of Kubernetes.
148-
149-
[https://docs.aws.amazon.com/eks/latest/userguide/update-cluster.html](https://docs.aws.amazon.com/eks/latest/userguide/update-cluster.html)
150-
151-
When doing this from terraform you should be able to go into the tf and change the version of the cluster. It should start the upgrade process, rather than tearing down the cluster and rebuilding it. This will make the cluster inaccessible through the AWS console for about 20 minutes, ***though everything in the cluster should continue to work normally, serve traffic, etc.***
152-
153-
The process should be:
154-
155-
- Update the API version number in terraform
156-
- Update the AMI for the ASG to the AMI for the corresponding version of EKS in eks.tf and apply terraform
157-
- See this page: [https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html](https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html)
158-
- This should update the worker group, but not affect any of the running nodes
159-
- Update any core components if necessary, as mentioned in the aws update-cluster documentation
160-
- Run terraform apply
161-
- Drain and remove the old nodes from the cluster. New ones will come up in their place with the new AMI
162-
- `k get nodes`
163-
- `k drain --ignore-daemonsets <node name>`
164-
- Then terminate the instance in AWS Console
165-
- Do the drain/delete process with one node at a time. Wait for a new node to be available before running the process on a second one. This will prevent any traffic from being lost.
166-
167-
168-
169141
## More resources
170142

171143
[https://kubernetes.io/docs/reference/kubectl/cheatsheet/](https://kubernetes.io/docs/reference/kubectl/cheatsheet/)

templates/terraform/environments/stage/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ module "stage" {
6767
ecr_repositories = [ local.project ]
6868

6969
# EKS configuration
70-
eks_cluster_version = "1.20"
70+
eks_cluster_version = "1.21"
7171
# Cluster addons. These often need to be updated when upgrading the cluster version.
7272
# See: https://docs.aws.amazon.com/eks/latest/userguide/eks-add-ons.html
7373
eks_addon_vpc_cni_version = "v1.7.10-eksbuild.1"
74-
eks_addon_kube_proxy_version = "v1.20.4-eksbuild.2"
75-
eks_addon_coredns_version = "v1.8.3-eksbuild.1"
74+
eks_addon_kube_proxy_version = "v1.21.2-eksbuild.2"
75+
eks_addon_coredns_version = "v1.8.4-eksbuild.1"
7676

7777
eks_node_groups = {
7878
main = {

0 commit comments

Comments
 (0)