Skip to content

Commit

Permalink
switch to not using apt for kubeadm, kubelet, and kubectl
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyDumaine committed Jun 13, 2024
1 parent bd7e02e commit 7728923
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
19 changes: 13 additions & 6 deletions templates/flavors/kubeadm/default/kubeadmConfigTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
19 changes: 13 additions & 6 deletions templates/flavors/kubeadm/default/kubeadmControlPlane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 7728923

Please sign in to comment.