Skip to content

Commit

Permalink
[fix]: tweaks for pre-init script (#105)
Browse files Browse the repository at this point in the history
* fail script early on error or unset variables
* fix parsing of version to handle v prefix
  • Loading branch information
AshleyDumaine authored Feb 13, 2024
1 parent b7e4ae2 commit 98b808f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions templates/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
key: kubeadm-pre-init.sh
permissions: "0500"
preKubeadmCommands:
- /kubeadm-pre-init.sh '{{ ds.meta_data.label }}' "${KUBERNETES_VERSION}"
- /kubeadm-pre-init.sh '{{ ds.meta_data.label }}' ${KUBERNETES_VERSION#[vV]}
clusterConfiguration:
apiServer:
extraArgs:
Expand Down Expand Up @@ -162,7 +162,7 @@ spec:
key: kubeadm-pre-init.sh
permissions: "0500"
preKubeadmCommands:
- /kubeadm-pre-init.sh '{{ ds.meta_data.label }}' "${KUBERNETES_VERSION}"
- /kubeadm-pre-init.sh '{{ ds.meta_data.label }}' ${KUBERNETES_VERSION#[vV]}
joinConfiguration:
nodeRegistration:
kubeletExtraArgs:
Expand Down Expand Up @@ -194,10 +194,11 @@ stringData:
net.ipv4.ip_forward = 1
kubeadm-pre-init.sh: |
#!/bin/bash
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
hostnamectl set-hostname "$1" && hostname -F /etc/hostname
mkdir -p -m 755 /etc/apt/keyrings
VERSION=${2%.*}
VERSION=$${2%.*}
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
apt-get update -y
Expand Down

0 comments on commit 98b808f

Please sign in to comment.