Skip to content

Commit

Permalink
Upgrade 1.24 to kernel 5.10 (#1118)
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermckinnon committed Feb 7, 2023
1 parent 3fb4010 commit ccf5b15
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
11 changes: 10 additions & 1 deletion doc/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down
27 changes: 17 additions & 10 deletions eks-worker-al2.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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`}}",
Expand Down
7 changes: 0 additions & 7 deletions scripts/install-worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###################################################################
################################################################################
Expand Down
9 changes: 6 additions & 3 deletions scripts/upgrade_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

1 comment on commit ccf5b15

@longc
Copy link

@longc longc commented on ccf5b15 Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a problem with the packer template after "upgrade kernel" process moved to a lower position, after the kernel upgrade the ec2 instance restarted, the files in /tmp/worker all gone, so the eks worker installation process will fail, I have to apply the following patch "eks-worker-al2.json" to get the build working again.

patch eks-worker-al2.json < eks-worker-al2.json.patch

--- eks-worker-al2.json.20230217	2023-02-17 19:18:06.000000000 +0000
+++ eks-worker-al2.json.20230309	2023-03-09 14:55:31.000000000 +0000
@@ -124,18 +124,13 @@
       "type": "shell",
       "remote_folder": "{{ user `remote_folder`}}",
       "inline": [
-        "mkdir -p /tmp/worker/log-collector-script/"
+        "mkdir -p /tmp/worker/bin/"
       ]
     },
     {
       "type": "file",
-      "source": "{{template_dir}}/files/",
-      "destination": "/tmp/worker/"
-    },
-    {
-      "type": "file",
-      "source": "{{template_dir}}/log-collector-script/linux/",
-      "destination": "/tmp/worker/log-collector-script/"
+      "source": "{{template_dir}}/files/bin/",
+      "destination": "/tmp/worker/bin/"
     },
     {
       "type": "shell",
@@ -158,6 +153,23 @@
     {
       "type": "shell",
       "remote_folder": "{{ user `remote_folder`}}",
+      "inline": [
+        "mkdir -p /tmp/worker/log-collector-script/"
+      ]
+    },
+    {
+      "type": "file",
+      "source": "{{template_dir}}/files/",
+      "destination": "/tmp/worker/"
+    },
+    {
+      "type": "file",
+      "source": "{{template_dir}}/log-collector-script/linux/",
+      "destination": "/tmp/worker/log-collector-script/"
+    },
+    {
+      "type": "shell",
+      "remote_folder": "{{ user `remote_folder`}}",
       "script": "{{template_dir}}/scripts/install-worker.sh",
       "environment_vars": [
         "KUBERNETES_VERSION={{user `kubernetes_version`}}",

Please sign in to comment.