From ccf5b1525dfa7a17f5cae21f8d8395a6f21b45d8 Mon Sep 17 00:00:00 2001 From: Carter Date: Mon, 6 Feb 2023 16:02:09 -0800 Subject: [PATCH] Upgrade 1.24 to kernel 5.10 (#1118) --- doc/USER_GUIDE.md | 11 ++++++++++- eks-worker-al2.json | 27 +++++++++++++++++---------- scripts/install-worker.sh | 7 ------- scripts/upgrade_kernel.sh | 9 ++++++--- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/doc/USER_GUIDE.md b/doc/USER_GUIDE.md index 0ed73532b..c565cff4d 100644 --- a/doc/USER_GUIDE.md +++ b/doc/USER_GUIDE.md @@ -249,7 +249,16 @@ $ curl -sSL "http://localhost:8001/api/v1/nodes/ip-192-168-92-220.us-east-2.comp By default, the `amazon-eks-ami` uses a [source_ami_filter](https://github.com/awslabs/amazon-eks-ami/blob/e3f1b910f83ad1f27e68312e50474ea6059f052d/eks-worker-al2.json#L46) that selects the latest [hvm](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html) AL2 AMI for the given architecture as the base AMI. For more information on what kernel versions are running on published Amazon EKS optimized Linux AMIs, see [the public documentation](https://docs.aws.amazon.com/eks/latest/userguide/eks-linux-ami-versions.html). -When building an AMI, you can set the `kernel_version` to `4.14` or `5.4` to customize the kernel version. The [upgrade_kernel.sh script](https://github.com/awslabs/amazon-eks-ami/blob/master/scripts/upgrade_kernel.sh#L26) contains the logic for updating and upgrading the kernel. For Kubernetes versions 1.18 and below, it uses the `4.14` kernel if not set, and it will install the latest patches. For Kubernetes version 1.19 and above, it uses the `5.4` kernel if not set. +When building an AMI, you can set `kernel_version` to customize the kernel version. Valid values are: +- `4.14` +- `5.4` +- `5.10` + +If `kernel_version` is not set: +- For Kubernetes 1.23 and below, `5.4` is used. +- For Kubernetes 1.24 and above, `5.10` is used. + +The [upgrade_kernel.sh script](../scripts/upgrade_kernel.sh) contains the logic for updating and upgrading the kernel. --- diff --git a/eks-worker-al2.json b/eks-worker-al2.json index 020758d36..873978909 100644 --- a/eks-worker-al2.json +++ b/eks-worker-al2.json @@ -119,16 +119,6 @@ "ADDITIONAL_YUM_REPOS={{user `additional_yum_repos`}}" ] }, - { - "type": "shell", - "remote_folder": "{{ user `remote_folder`}}", - "expect_disconnect": true, - "script": "{{template_dir}}/scripts/upgrade_kernel.sh", - "environment_vars": [ - "KUBERNETES_VERSION={{user `kubernetes_version`}}", - "KERNEL_VERSION={{user `kernel_version`}}" - ] - }, { "type": "shell", "pause_before": "90s", @@ -147,6 +137,23 @@ "source": "{{template_dir}}/log-collector-script/linux/", "destination": "/tmp/worker/log-collector-script/" }, + { + "type": "shell", + "inline": [ + "sudo chmod -R a+x /tmp/worker/bin/", + "sudo mv /tmp/worker/bin/* /usr/bin/" + ] + }, + { + "type": "shell", + "remote_folder": "{{ user `remote_folder`}}", + "expect_disconnect": true, + "script": "{{template_dir}}/scripts/upgrade_kernel.sh", + "environment_vars": [ + "KUBERNETES_VERSION={{user `kubernetes_version`}}", + "KERNEL_VERSION={{user `kernel_version`}}" + ] + }, { "type": "shell", "remote_folder": "{{ user `remote_folder`}}", diff --git a/scripts/install-worker.sh b/scripts/install-worker.sh index c68af36cf..56524243b 100644 --- a/scripts/install-worker.sh +++ b/scripts/install-worker.sh @@ -48,13 +48,6 @@ else exit 1 fi -################################################################################ -### Utilities ################################################################## -################################################################################ - -sudo chmod -R a+x $TEMPLATE_DIR/bin/ -sudo mv $TEMPLATE_DIR/bin/* /usr/bin/ - ################################################################################ ### Packages ################################################################### ################################################################################ diff --git a/scripts/upgrade_kernel.sh b/scripts/upgrade_kernel.sh index 5736d0f5c..134bd454b 100755 --- a/scripts/upgrade_kernel.sh +++ b/scripts/upgrade_kernel.sh @@ -5,9 +5,12 @@ set -o nounset set -o errexit if [[ -z "$KERNEL_VERSION" ]]; then - KERNEL_VERSION=5.4 - - echo "kernel_version is unset. Setting to $KERNEL_VERSION" + if vercmp "$KUBERNETES_VERSION" gteq "1.24.0"; then + KERNEL_VERSION=5.10 + else + KERNEL_VERSION=5.4 + fi + echo "kernel_version is unset. Setting to $KERNEL_VERSION based on Kubernetes version $KUBERNETES_VERSION." fi if [[ $KERNEL_VERSION == "4.14" ]]; then