clone k8s repo to control nodes at first boot

This commit is contained in:
Steven Polley 2023-12-21 12:39:48 -07:00
parent abf8ea60af
commit d36d966970

View File

@ -48,13 +48,19 @@ storage:
net.bridge.bridge-nf-call-iptables=1 net.bridge.bridge-nf-call-iptables=1
net.ipv4.ip_forward=1 net.ipv4.ip_forward=1
# Runs on first boot, script to install kubelet dependencies # 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 mode: 0744
overwrite: true overwrite: true
contents: contents:
inline: | inline: |
#!/bin/bash #!/bin/bash
rpm-ostree install kubelet kubeadm kubectl cri-o vim etcd 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 systemctl reboot
- path: /home/steven/cluster-config.yaml - path: /home/steven/cluster-config.yaml
mode: 0600 mode: 0600
@ -94,37 +100,37 @@ passwd: # setting login credentials
groups: [ sudo, docker ] groups: [ sudo, docker ]
systemd: systemd:
units: units:
- name: install-kubelet.service - name: first-boot.service
enabled: true enabled: true
contents: | contents: |
[Unit] [Unit]
Before=systemd-user-sessions.service Before=systemd-user-sessions.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
ConditionPathExists=!/var/lib/install-kubelet ConditionPathExists=!/var/lib/first-boot
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/usr/local/bin/install-kubelet.sh ExecStart=/usr/local/bin/first-boot.sh
ExecStartPost=/usr/bin/touch /var/lib/install-kubelet ExecStartPost=/usr/bin/touch /var/lib/first-boot
RemainAfterExit=yes RemainAfterExit=yes
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
- name: enable-kubelet.service - name: second-boot.service
enabled: true enabled: true
contents: | contents: |
[Unit] [Unit]
Before=systemd-user-sessions.service Before=systemd-user-sessions.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
ConditionPathExists=/var/lib/install-kubelet ConditionPathExists=/var/lib/first-boot
ConditionPathExists=!/var/lib/enable-kubelet ConditionPathExists=!/var/lib/second-boot
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/usr/bin/systemctl enable --now crio kubelet 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 RemainAfterExit=yes
[Install] [Install]