From 7728923509d8b3311d99d3fb7e8b54f515055526 Mon Sep 17 00:00:00 2001 From: Ashley Dumaine Date: Wed, 12 Jun 2024 10:01:06 -0400 Subject: [PATCH] switch to not using apt for kubeadm, kubelet, and kubectl --- .../default/kubeadmConfigTemplate.yaml | 19 +++++++++++++------ .../kubeadm/default/kubeadmControlPlane.yaml | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/templates/flavors/kubeadm/default/kubeadmConfigTemplate.yaml b/templates/flavors/kubeadm/default/kubeadmConfigTemplate.yaml index 335156990..c08f70b4f 100644 --- a/templates/flavors/kubeadm/default/kubeadmConfigTemplate.yaml +++ b/templates/flavors/kubeadm/default/kubeadmConfigTemplate.yaml @@ -11,16 +11,23 @@ spec: content: | #!/bin/bash set -euo pipefail - export DEBIAN_FRONTEND=noninteractive - mkdir -p -m 755 /etc/apt/keyrings PATCH_VERSION=$${1#[v]} VERSION=$${PATCH_VERSION%.*} curl -fsSL https://raw.githubusercontent.com/linode/cluster-api-provider-linode/869bcdad9cf7daae533023c7869f62683d2a7f47/scripts/add-kubeadm-required-files.sh | bash - curl -fsSL "https://pkgs.k8s.io/core:/stable:/v$VERSION/deb/Release.key" | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg - echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v$VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list + + export DEBIAN_FRONTEND=noninteractive apt-get update -y - apt-get install -y kubelet=$PATCH_VERSION* kubeadm=$PATCH_VERSION* kubectl=$PATCH_VERSION* containerd - apt-mark hold kubelet kubeadm kubectl containerd + apt-get install -y containerd socat conntrack + + DOWNLOAD_DIR="/usr/local/bin" + curl -L "https://github.com/kubernetes-sigs/cri-tools/releases/download/v$${VERSION}.0/crictl-v$${VERSION}.0-linux-amd64.tar.gz" | tar -C $$DOWNLOAD_DIR -xz + cd $${DOWNLOAD_DIR} + curl -L --remote-name-all https://dl.k8s.io/release/${KUBERNETES_VERSION}/bin/linux/amd64/{kubeadm,kubelet} + chmod +x {kubeadm,kubelet} + curl -sSL https://raw.githubusercontent.com/kubernetes/release/v0.16.2/cmd/krel/templates/latest/kubelet/kubelet.service | sed "s:/usr/bin:$${DOWNLOAD_DIR}:g" | tee /usr/lib/systemd/system/kubelet.service + mkdir -p /usr/lib/systemd/system/kubelet.service.d + curl -sSL https://raw.githubusercontent.com/kubernetes/release/v0.16.2/cmd/krel/templates/latest/kubeadm/10-kubeadm.conf | sed "s:/usr/bin:$${DOWNLOAD_DIR}:g" | tee /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" permissions: "0500" preKubeadmCommands: - /kubeadm-pre-init.sh ${KUBERNETES_VERSION} diff --git a/templates/flavors/kubeadm/default/kubeadmControlPlane.yaml b/templates/flavors/kubeadm/default/kubeadmControlPlane.yaml index 08d4bda3e..70b20a3ae 100644 --- a/templates/flavors/kubeadm/default/kubeadmControlPlane.yaml +++ b/templates/flavors/kubeadm/default/kubeadmControlPlane.yaml @@ -16,16 +16,23 @@ spec: content: | #!/bin/bash set -euo pipefail - export DEBIAN_FRONTEND=noninteractive - mkdir -p -m 755 /etc/apt/keyrings PATCH_VERSION=$${1#[v]} VERSION=$${PATCH_VERSION%.*} curl -fsSL https://raw.githubusercontent.com/linode/cluster-api-provider-linode/869bcdad9cf7daae533023c7869f62683d2a7f47/scripts/add-kubeadm-required-files.sh | bash - curl -fsSL "https://pkgs.k8s.io/core:/stable:/v$VERSION/deb/Release.key" | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg - echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v$VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list + + export DEBIAN_FRONTEND=noninteractive apt-get update -y - apt-get install -y kubelet=$PATCH_VERSION* kubeadm=$PATCH_VERSION* kubectl=$PATCH_VERSION* containerd - apt-mark hold kubelet kubeadm kubectl containerd + apt-get install -y containerd socat conntrack + + DOWNLOAD_DIR="/usr/local/bin" + curl -L "https://github.com/kubernetes-sigs/cri-tools/releases/download/v$${VERSION}.0/crictl-v$${VERSION}.0-linux-amd64.tar.gz" | tar -C $$DOWNLOAD_DIR -xz + cd $${DOWNLOAD_DIR} + curl -L --remote-name-all https://dl.k8s.io/release/${KUBERNETES_VERSION}/bin/linux/amd64/{kubeadm,kubelet} + chmod +x {kubeadm,kubelet} + curl -sSL https://raw.githubusercontent.com/kubernetes/release/v0.16.2/cmd/krel/templates/latest/kubelet/kubelet.service | sed "s:/usr/bin:$${DOWNLOAD_DIR}:g" | tee /usr/lib/systemd/system/kubelet.service + mkdir -p /usr/lib/systemd/system/kubelet.service.d + curl -sSL https://raw.githubusercontent.com/kubernetes/release/v0.16.2/cmd/krel/templates/latest/kubeadm/10-kubeadm.conf | sed "s:/usr/bin:$${DOWNLOAD_DIR}:g" | tee /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" permissions: "0500" preKubeadmCommands: - /kubeadm-pre-init.sh ${KUBERNETES_VERSION}