From d36d9669703817b772b53563c2057dd6171e8c2e Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Thu, 21 Dec 2023 12:39:48 -0700 Subject: [PATCH] clone k8s repo to control nodes at first boot --- 00-provisioning/butane/full.yaml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/00-provisioning/butane/full.yaml b/00-provisioning/butane/full.yaml index bef82e1..678d173 100644 --- a/00-provisioning/butane/full.yaml +++ b/00-provisioning/butane/full.yaml @@ -48,13 +48,19 @@ storage: net.bridge.bridge-nf-call-iptables=1 net.ipv4.ip_forward=1 # Runs on first boot, script to install kubelet dependencies - - path: /usr/local/bin/install-kubelet.sh + - path: /usr/local/bin/first-boot.sh mode: 0744 overwrite: true contents: inline: | #!/bin/bash rpm-ostree install kubelet kubeadm kubectl cri-o vim etcd + + # Control plane node hook + if [[ $(hostname) = *control* ]]; then + git clone https://deadbeef.codes/steven/deadbeef.codes-k8s.git /home/steven/ + chown -R steven:steven /home/steven/deadbeef.codes-k8s + fi systemctl reboot - path: /home/steven/cluster-config.yaml mode: 0600 @@ -94,37 +100,37 @@ passwd: # setting login credentials groups: [ sudo, docker ] systemd: units: - - name: install-kubelet.service + - name: first-boot.service enabled: true contents: | [Unit] Before=systemd-user-sessions.service Wants=network-online.target After=network-online.target - ConditionPathExists=!/var/lib/install-kubelet + ConditionPathExists=!/var/lib/first-boot [Service] Type=oneshot - ExecStart=/usr/local/bin/install-kubelet.sh - ExecStartPost=/usr/bin/touch /var/lib/install-kubelet + ExecStart=/usr/local/bin/first-boot.sh + ExecStartPost=/usr/bin/touch /var/lib/first-boot RemainAfterExit=yes [Install] WantedBy=multi-user.target - - name: enable-kubelet.service + - name: second-boot.service enabled: true contents: | [Unit] Before=systemd-user-sessions.service Wants=network-online.target After=network-online.target - ConditionPathExists=/var/lib/install-kubelet - ConditionPathExists=!/var/lib/enable-kubelet + ConditionPathExists=/var/lib/first-boot + ConditionPathExists=!/var/lib/second-boot [Service] Type=oneshot ExecStart=/usr/bin/systemctl enable --now crio kubelet - ExecStartPost=/usr/bin/touch /var/lib/enable-kubelet + ExecStartPost=/usr/bin/touch /var/lib/second-boot RemainAfterExit=yes [Install]