From a9079eb77e3dc60d74ce0afc8f29f032787d6f42 Mon Sep 17 00:00:00 2001 From: Mathieu Bruneau Date: Sun, 4 Feb 2024 10:19:10 -0500 Subject: [PATCH] feat: Update to 1.29 (#817) * Updates to EKS 1.29.0 and eksctl to 0.169.0 Added scripts to automate updates * Added alias k and bash completion for it --- cluster/eksctl/cluster.yaml | 44 +++++++++++++++------------------- cluster/terraform/variables.tf | 4 ++-- docs/eks_version_upgrades.md | 2 +- hack/lib/kubectl-version.sh | 2 +- hack/upgrade-k8s.sh | 41 +++++++++++++++++++++++++++++++ lab/scripts/installer.sh | 8 +++---- lab/scripts/setup.sh | 4 +++- website/docusaurus.config.js | 4 ++-- 8 files changed, 73 insertions(+), 36 deletions(-) create mode 100755 hack/upgrade-k8s.sh diff --git a/cluster/eksctl/cluster.yaml b/cluster/eksctl/cluster.yaml index 286c926aa..d0ef68b9d 100644 --- a/cluster/eksctl/cluster.yaml +++ b/cluster/eksctl/cluster.yaml @@ -1,44 +1,38 @@ apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig - availabilityZones: -- ${AWS_REGION}a -- ${AWS_REGION}b -- ${AWS_REGION}c - + - ${AWS_REGION}a + - ${AWS_REGION}b + - ${AWS_REGION}c metadata: name: ${EKS_CLUSTER_NAME} region: ${AWS_REGION} - version: '1.27' + version: '1.29' tags: karpenter.sh/discovery: ${EKS_CLUSTER_NAME} created-by: eks-workshop-v2 env: ${EKS_CLUSTER_NAME} - iam: withOIDC: true - vpc: cidr: 10.42.0.0/16 clusterEndpoints: privateAccess: true publicAccess: true - addons: -- name: vpc-cni - version: 1.14.1 - configurationValues: "{\"env\":{\"ENABLE_PREFIX_DELEGATION\":\"true\", \"ENABLE_POD_ENI\":\"true\", \"POD_SECURITY_GROUP_ENFORCING_MODE\":\"standard\"},\"enableNetworkPolicy\": \"true\"}" - resolveConflicts: overwrite - + - name: vpc-cni + version: 1.14.1 + configurationValues: "{\"env\":{\"ENABLE_PREFIX_DELEGATION\":\"true\", \"ENABLE_POD_ENI\":\"true\", \"POD_SECURITY_GROUP_ENFORCING_MODE\":\"standard\"},\"enableNetworkPolicy\": \"true\"}" + resolveConflicts: overwrite managedNodeGroups: -- name: default - desiredCapacity: 3 - minSize: 3 - maxSize: 6 - instanceType: m5.large - privateNetworking: true - releaseVersion: 1.27.3-20230816 - updateConfig: - maxUnavailablePercentage: 50 - labels: - workshop-default: 'yes' + - name: default + desiredCapacity: 3 + minSize: 3 + maxSize: 6 + instanceType: m5.large + privateNetworking: true + releaseVersion: "1.29.0-20240129" + updateConfig: + maxUnavailablePercentage: 50 + labels: + workshop-default: 'yes' diff --git a/cluster/terraform/variables.tf b/cluster/terraform/variables.tf index b110a338e..faefa9f12 100644 --- a/cluster/terraform/variables.tf +++ b/cluster/terraform/variables.tf @@ -6,13 +6,13 @@ variable "cluster_name" { variable "cluster_version" { description = "EKS cluster version." type = string - default = "1.27" + default = "1.29" } variable "ami_release_version" { description = "Default EKS AMI release version for node groups" type = string - default = "1.27.3-20230816" + default = "1.29.0-20240129" } variable "vpc_cidr" { diff --git a/docs/eks_version_upgrades.md b/docs/eks_version_upgrades.md index 88d657ba1..0ddd9a64d 100644 --- a/docs/eks_version_upgrades.md +++ b/docs/eks_version_upgrades.md @@ -39,4 +39,4 @@ There are various places that reference the Kubernetes versions (Kubernetes, kub 1. IDE installer: `lab/scripts/installer.sh` 1. eksctl: `cluster/eksctl/cluster.yaml` 1. Terraform: `cluster/terraform/variables.tf` -1. Common kubectl: `/hack/lib/kubectl-version.sh` \ No newline at end of file +1. Common kubectl: `hack/lib/kubectl-version.sh` \ No newline at end of file diff --git a/hack/lib/kubectl-version.sh b/hack/lib/kubectl-version.sh index 3f43740b2..fb7fa4432 100644 --- a/hack/lib/kubectl-version.sh +++ b/hack/lib/kubectl-version.sh @@ -1 +1 @@ -export KUBECTL_VERSION='v1.27.7' \ No newline at end of file +export KUBECTL_VERSION='v1.29.0' \ No newline at end of file diff --git a/hack/upgrade-k8s.sh b/hack/upgrade-k8s.sh new file mode 100755 index 000000000..6bcd03bef --- /dev/null +++ b/hack/upgrade-k8s.sh @@ -0,0 +1,41 @@ +#!/bin/sh -x + +if [ -z "$1" ] || [ -z "$2" ]; then + echo "We need a k8s version and eksctl version to update to, e.g. ./$0 1.29.0 0.169.0" + exit 1 +fi + +K8SLong=$1 +K8S="${K8SLong%.*}" +EKSCTL=$2 + +ARCH=amd64 +PLATFORM=$(uname -s)_$ARCH + +#AMI=`aws ec2 describe-images --owners amazon --filters "Name=name,Values=amazon-eks-node-$K8S*" --query "Images[1].[Name,Description]" --output text` +AMI_API=`aws ec2 describe-images --owners amazon --filters "Name=name,Values=amazon-eks-node-$K8S*" --query "Images[1].[Name]" --output text` + +AMI=$( echo ${AMI_API} | sed "s/amazon-eks-node-.*-v\(.*\)/$K8SLong-\\1/") + + +sed -i "s/KUBERNETES_VERSION: '.*'/KUBERNETES_VERSION: '$K8S'/" website/docusaurus.config.js +sed -i "s/KUBERNETES_NODE_VERSION: '.*'/KUBERNETES_NODE_VERSION: '$K8S-eks-tbdl'/" website/docusaurus.config.js #Find the right version + +sed -i "s/kubectl_version='.*'/kubectl_version='$K8SLong'/" lab/scripts/installer.sh +kubectl_checksum=`curl -L "https://dl.k8s.io/release/v$K8SLong/bin/linux/amd64/kubectl.sha256"` +sed -i "s/kubectl_checksum='.*'/kubectl_checksum='$kubectl_checksum'/" lab/scripts/installer.sh + +sed -i "s/eksctl_version='.*'/eksctl_version='$EKSCTL'/" lab/scripts/installer.sh +EKSCTL_CHECKSUM=`curl -sL "https://github.com/eksctl-io/eksctl/releases/download/v$EKSCTL/eksctl_checksums.txt" | grep $PLATFORM | cut -f1 -d" "` +sed -i "s/eksctl_checksum='.*'/eksctl_checksum='$EKSCTL_CHECKSUM'/" lab/scripts/installer.sh + +#sed -i "s/version: '.*'/version: '$K8S'/" cluster/eksctl/cluster.yaml +yq -i ".metadata.version = \"$K8S\"" cluster/eksctl/cluster.yaml +yq -i ".managedNodeGroups[0].releaseVersion = \"$AMI\"" cluster/eksctl/cluster.yaml + +# Using line numbers in Terraform to target only the right resources +sed -i "9s/default.*= \".*\"/default = \"$K8S\"/" cluster/terraform/variables.tf +sed -i "15s/default.*= \".*\"/default = \"$AMI\"/" cluster/terraform/variables.tf + + +sed -i "s/KUBECTL_VERSION='.*'/KUBECTL_VERSION='v$K8SLong'/" hack/lib/kubectl-version.sh \ No newline at end of file diff --git a/lab/scripts/installer.sh b/lab/scripts/installer.sh index 26b677f6b..900d3aa34 100644 --- a/lab/scripts/installer.sh +++ b/lab/scripts/installer.sh @@ -2,14 +2,14 @@ set -e -kubectl_version='1.27.7' -kubectl_checksum='e5fe510ba6f421958358d3d43b3f0b04c2957d4bc3bb24cf541719af61a06d79' +kubectl_version='1.29.0' +kubectl_checksum='0e03ab096163f61ab610b33f37f55709d3af8e16e4dcc1eb682882ef80f96fd5' helm_version='3.10.1' helm_checksum='c12d2cd638f2d066fec123d0bd7f010f32c643afdf288d39a4610b1f9cb32af3' -eksctl_version='0.164.0' -eksctl_checksum='2ed5de811dd26a3ed041ca3e6f26717288dc02dfe87ac752ae549ed69576d03e' +eksctl_version='0.169.0' +eksctl_checksum='0491ed2ddbeeb73c226ca2b1f99fc1b401dc638f17343d955a4b9797c2e540d9' kubeseal_version='0.18.4' kubeseal_checksum='2e765b87889bfcf06a6249cde8e28507e3b7be29851e4fac651853f7638f12f3' diff --git a/lab/scripts/setup.sh b/lab/scripts/setup.sh index 59978a7f3..3671b3a1c 100644 --- a/lab/scripts/setup.sh +++ b/lab/scripts/setup.sh @@ -49,4 +49,6 @@ echo "export RESOURCES_PRECREATED='${RESOURCES_PRECREATED}'" > ~/.bashrc.d/infra echo "export ANALYTICS_ENDPOINT='${ANALYTICS_ENDPOINT}'" > ~/.bashrc.d/analytics.bash -/usr/local/bin/kubectl completion bash >> ~/.bashrc.d/kubectl_completion.bash \ No newline at end of file +/usr/local/bin/kubectl completion bash >> ~/.bashrc.d/kubectl_completion.bash +echo "alias k=kubectl" >> ~/.bashrc.d/kubectl_completion.bash +echo "complete -F __start_kubectl k" >> ~/.bashrc.d/kubectl_completion.bash \ No newline at end of file diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 9a3425176..87c1430e9 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -62,8 +62,8 @@ const config = { MANIFESTS_REF: manifestsRef, MANIFESTS_OWNER: manifestsOwner, MANIFESTS_REPOSITORY: manifestsRepository, - KUBERNETES_VERSION: '1.27', - KUBERNETES_NODE_VERSION: '1.27.3-eks-48e63af' + KUBERNETES_VERSION: '1.29', + KUBERNETES_NODE_VERSION: '1.29-eks-tbdl' } }], [remarkIncludeCode, { manifestsDir }],