From ed741847b66e9ab9cd1fa09347c0e160139a97e7 Mon Sep 17 00:00:00 2001 From: Anurag <81210977+kranurag7@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:35:29 +0530 Subject: [PATCH] use TRIMMED_KUBERNETES_VERSION to download pkgs This commit used TRIMMED_KUBERNETES_VERSION as an env variable to download packages. This way we can update with ease. Signed-off-by: Anurag <81210977+kranurag7@users.noreply.github.com> --- templates/cluster-templates/bases/hcloud-kcp-ubuntu.yaml | 5 +++-- .../bases/hetznerbaremetal-kcp-ubuntu.yaml | 5 +++-- templates/cluster-templates/bases/kct-md-0-ubuntu.yaml | 5 +++-- templates/cluster-templates/cluster-class.yaml | 5 +++-- .../1.24.1-ubuntu-20-04-containerd/scripts/kubernetes.sh | 7 ++++--- .../1.25.2-ubuntu-22-04-containerd/scripts/kubernetes.sh | 7 ++++--- .../1.27.3-ubuntu-22-04-containerd/scripts/kubernetes.sh | 7 ++++--- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/templates/cluster-templates/bases/hcloud-kcp-ubuntu.yaml b/templates/cluster-templates/bases/hcloud-kcp-ubuntu.yaml index 3e8d25546..2f907e41f 100644 --- a/templates/cluster-templates/bases/hcloud-kcp-ubuntu.yaml +++ b/templates/cluster-templates/bases/hcloud-kcp-ubuntu.yaml @@ -190,6 +190,7 @@ spec: - export CRUN=1.9.2 # update: datasource=github-tags depName=containers/crun versioning=semver-coerced - export CONTAINERD=1.7.7 # update: datasource=github-tags depName=containerd/containerd extractVersion=^v(?.*)$ versioning=semver - export KUBERNETES_VERSION=$(echo ${KUBERNETES_VERSION} | sed 's/^v//') + - export TRIMMED_KUBERNETES_VERSION=$(echo ${KUBERNETES_VERSION} | sed 's/^v//' | awk -F . '{print $1 "." $2}') - ARCH=amd64 - if [ "$(uname -m)" = "aarch64" ]; then ARCH=arm64; fi - localectl set-locale LANG=en_US.UTF-8 @@ -208,8 +209,8 @@ spec: - rm -f /etc/cni/net.d/10-containerd-net.conflist - chmod -R 644 /etc/cni && chown -R root:root /etc/cni - systemctl daemon-reload && systemctl enable containerd && systemctl start containerd - - curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.27/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:/v1.27/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list + - curl -fsSL https://pkgs.k8s.io/core:/stable:/v$TRIMMED_KUBERNETES_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$TRIMMED_KUBERNETES_VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list - apt-get update - apt-get install -y kubelet=$KUBERNETES_VERSION-1.1 kubeadm=$KUBERNETES_VERSION-1.1 kubectl=$KUBERNETES_VERSION-1.1 bash-completion && apt-mark hold kubelet kubectl kubeadm && systemctl enable kubelet - kubeadm config images pull --kubernetes-version $KUBERNETES_VERSION diff --git a/templates/cluster-templates/bases/hetznerbaremetal-kcp-ubuntu.yaml b/templates/cluster-templates/bases/hetznerbaremetal-kcp-ubuntu.yaml index a47ad66a8..92c0603b8 100644 --- a/templates/cluster-templates/bases/hetznerbaremetal-kcp-ubuntu.yaml +++ b/templates/cluster-templates/bases/hetznerbaremetal-kcp-ubuntu.yaml @@ -209,6 +209,7 @@ spec: - export CRUN=1.9.2 # update: datasource=github-tags depName=containers/crun versioning=semver-coerced - export CONTAINERD=1.7.7 # update: datasource=github-tags depName=containerd/containerd extractVersion=^v(?.*)$ versioning=semver - export KUBERNETES_VERSION=$(echo ${KUBERNETES_VERSION} | sed 's/^v//') + - export TRIMMED_KUBERNETES_VERSION=$(echo ${KUBERNETES_VERSION} | sed 's/^v//' | awk -F . '{print $1 "." $2}') - localectl set-locale LANG=en_US.UTF-8 - localectl set-locale LANGUAGE=en_US.UTF-8 - apt-get update -y @@ -225,8 +226,8 @@ spec: - rm -f /etc/cni/net.d/10-containerd-net.conflist - chmod -R 644 /etc/cni && chown -R root:root /etc/cni - systemctl daemon-reload && systemctl enable containerd && systemctl start containerd - - curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.27/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:/v1.27/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list + - curl -fsSL https://pkgs.k8s.io/core:/stable:/v$TRIMMED_KUBERNETES_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$TRIMMED_KUBERNETES_VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list - apt-get update - apt-get install -y kubelet=$KUBERNETES_VERSION-1.1 kubeadm=$KUBERNETES_VERSION-1.1 kubectl=$KUBERNETES_VERSION-1.1 bash-completion && apt-mark hold kubelet kubectl kubeadm && systemctl enable kubelet - kubeadm config images pull --kubernetes-version $KUBERNETES_VERSION diff --git a/templates/cluster-templates/bases/kct-md-0-ubuntu.yaml b/templates/cluster-templates/bases/kct-md-0-ubuntu.yaml index 3e6168aa8..1cb6f0119 100644 --- a/templates/cluster-templates/bases/kct-md-0-ubuntu.yaml +++ b/templates/cluster-templates/bases/kct-md-0-ubuntu.yaml @@ -77,6 +77,7 @@ spec: - export CRUN=1.9.2 # update: datasource=github-tags depName=containers/crun versioning=semver-coerced - export CONTAINERD=1.7.7 # update: datasource=github-tags depName=containerd/containerd extractVersion=^v(?.*)$ versioning=semver - export KUBERNETES_VERSION=$(echo ${KUBERNETES_VERSION} | sed 's/^v//') + - export TRIMMED_KUBERNETES_VERSION=$(echo ${KUBERNETES_VERSION} | sed 's/^v//' | awk -F . '{print $1 "." $2}') - ARCH=amd64 - if [ "$(uname -m)" = "aarch64" ]; then ARCH=arm64; fi - localectl set-locale LANG=en_US.UTF-8 @@ -95,8 +96,8 @@ spec: - rm -f /etc/cni/net.d/10-containerd-net.conflist - chmod -R 644 /etc/cni && chown -R root:root /etc/cni - systemctl daemon-reload && systemctl enable containerd && systemctl start containerd - - curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.27/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:/v1.27/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list + - curl -fsSL https://pkgs.k8s.io/core:/stable:/v$TRIMMED_KUBERNETES_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$TRIMMED_KUBERNETES_VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list - apt-get update - apt-get install -y kubelet=$KUBERNETES_VERSION-1.1 kubeadm=$KUBERNETES_VERSION-1.1 kubectl=$KUBERNETES_VERSION-1.1 bash-completion && apt-mark hold kubelet kubectl kubeadm && systemctl enable kubelet - kubeadm config images pull --kubernetes-version $KUBERNETES_VERSION diff --git a/templates/cluster-templates/cluster-class.yaml b/templates/cluster-templates/cluster-class.yaml index 5b381610f..10b53262b 100644 --- a/templates/cluster-templates/cluster-class.yaml +++ b/templates/cluster-templates/cluster-class.yaml @@ -560,6 +560,7 @@ spec: - export CRUN=1.6 - export CONTAINERD=1.6.8 - export KUBERNETES_VERSION=1.25.3 + - export TRIMMED_KUBERNETES_VERSION=$(echo ${KUBERNETES_VERSION} | sed 's/^v//' | awk -F . '{print $1 "." $2}') - localectl set-locale LANG=en_US.UTF-8 - localectl set-locale LANGUAGE=en_US.UTF-8 - apt-get update -y @@ -577,8 +578,8 @@ spec: - rm -f /etc/cni/net.d/10-containerd-net.conflist - chmod -R 644 /etc/cni && chown -R root:root /etc/cni - systemctl daemon-reload && systemctl enable containerd && systemctl start containerd - - curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.25/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:/v1.25/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list + - curl -fsSL https://pkgs.k8s.io/core:/stable:/v$TRIMMED_KUBERNETES_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$TRIMMED_KUBERNETES_VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list - apt-get update - apt-get install -y kubelet=$KUBERNETES_VERSION-1.1 kubeadm=$KUBERNETES_VERSION-1.1 kubectl=$KUBERNETES_VERSION-1.1 bash-completion && apt-mark hold kubelet kubectl diff --git a/templates/node-image/1.24.1-ubuntu-20-04-containerd/scripts/kubernetes.sh b/templates/node-image/1.24.1-ubuntu-20-04-containerd/scripts/kubernetes.sh index 50d72489c..dbb487b00 100644 --- a/templates/node-image/1.24.1-ubuntu-20-04-containerd/scripts/kubernetes.sh +++ b/templates/node-image/1.24.1-ubuntu-20-04-containerd/scripts/kubernetes.sh @@ -18,12 +18,13 @@ set -o errexit set -o nounset set -o pipefail -curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.24/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:/v1.24/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list +KUBERNETES_VERSION=1.24.1 # https://kubernetes.io/releases/#release-history +TRIMMED_KUBERNETES_VERSION=$(echo ${KUBERNETES_VERSION} | sed 's/^v//' | awk -F . '{print $1 "." $2}') +curl -fsSL https://pkgs.k8s.io/core:/stable:/v$TRIMMED_KUBERNETES_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$TRIMMED_KUBERNETES_VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list apt-get update # Check actual version: https://github.com/kubernetes/kubernetes/releases -KUBERNETES_VERSION=1.24.1 # https://kubernetes.io/releases/#release-history apt-get install -y kubelet=$KUBERNETES_VERSION-1.1 kubeadm=$KUBERNETES_VERSION-1.1 kubectl=$KUBERNETES_VERSION-1.1 bash-completion apt-mark hold kubelet kubectl kubeadm diff --git a/templates/node-image/1.25.2-ubuntu-22-04-containerd/scripts/kubernetes.sh b/templates/node-image/1.25.2-ubuntu-22-04-containerd/scripts/kubernetes.sh index 7521f6e2c..45bfc8dde 100644 --- a/templates/node-image/1.25.2-ubuntu-22-04-containerd/scripts/kubernetes.sh +++ b/templates/node-image/1.25.2-ubuntu-22-04-containerd/scripts/kubernetes.sh @@ -18,12 +18,13 @@ set -o errexit set -o nounset set -o pipefail -curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.25/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:/v1.25/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list +KUBERNETES_VERSION=1.25.2 # https://kubernetes.io/releases/#release-history +TRIMMED_KUBERNETES_VERSION=$(echo ${KUBERNETES_VERSION} | sed 's/^v//' | awk -F . '{print $1 "." $2}') +curl -fsSL https://pkgs.k8s.io/core:/stable:/v$TRIMMED_KUBERNETES_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$TRIMMED_KUBERNETES_VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list apt-get update # Check actual version: https://github.com/kubernetes/kubernetes/releases -KUBERNETES_VERSION=1.25.2 # https://kubernetes.io/releases/#release-history apt-get install -y kubelet=$KUBERNETES_VERSION-1.1 kubeadm=$KUBERNETES_VERSION-1.1 kubectl=$KUBERNETES_VERSION-1.1 bash-completion apt-mark hold kubelet kubectl kubeadm diff --git a/templates/node-image/1.27.3-ubuntu-22-04-containerd/scripts/kubernetes.sh b/templates/node-image/1.27.3-ubuntu-22-04-containerd/scripts/kubernetes.sh index 1255877b4..52ec6c3ad 100644 --- a/templates/node-image/1.27.3-ubuntu-22-04-containerd/scripts/kubernetes.sh +++ b/templates/node-image/1.27.3-ubuntu-22-04-containerd/scripts/kubernetes.sh @@ -18,12 +18,13 @@ set -o errexit set -o nounset set -o pipefail -curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.27/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:/v1.27/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list +KUBERNETES_VERSION=1.27.3 # https://kubernetes.io/releases/#release-history +TRIMMED_KUBERNETES_VERSION=$(echo ${KUBERNETES_VERSION} | sed 's/^v//' | awk -F . '{print $1 "." $2}') +curl -fsSL https://pkgs.k8s.io/core:/stable:/v$TRIMMED_KUBERNETES_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$TRIMMED_KUBERNETES_VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list apt-get update # Check actual version: https://github.com/kubernetes/kubernetes/releases -KUBERNETES_VERSION=1.27.3 # https://kubernetes.io/releases/#release-history apt-get install -y kubelet=$KUBERNETES_VERSION-1.1 kubeadm=$KUBERNETES_VERSION-1.1 kubectl=$KUBERNETES_VERSION-1.1 bash-completion apt-mark hold kubelet kubectl kubeadm