@@ -209,7 +209,7 @@ write_files:
209209{{ if ne .CloudConfig "" }}{{ .CloudConfig | indent 4 }}{{ end }}
210210
211211- path: "/usr/local/bin/setup"
212- permissions: "0777 "
212+ permissions: "0755 "
213213 content: |
214214 #!/bin/bash
215215 set -xeuo pipefail
@@ -230,16 +230,33 @@ write_files:
230230 systemctl enable --now docker
231231 systemctl enable --now kubelet
232232
233- kubeadm join \
234- --token {{ .BoostrapToken }} \
235- --discovery-token-ca-cert-hash sha256:{{ .KubeadmCACertHash }} \
236- {{- if semverCompare ">=1.9.X" .KubeletVersion }}
237- --ignore-preflight-errors=CRI \
238- {{- end }}
239- {{ .ServerAddr }}
233+ if [[ ! -x /usr/local/bin/health-monitor.sh ]]; then
234+ curl -Lfo /usr/local/bin/health-monitor.sh \
235+ https://raw.githubusercontent.com/kubermatic/machine-controller/8b5b66e4910a6228dfaecccaa0a3b05ec4902f8e/pkg/userdata/scripts/health-monitor.sh
236+ chmod +x /usr/local/bin/health-monitor.sh
237+ fi
238+
239+ if ! [[ -e /etc/kubernetes/pki/ca.crt ]]; then
240+ kubeadm join \
241+ --token {{ .BoostrapToken }} \
242+ --discovery-token-ca-cert-hash sha256:{{ .KubeadmCACertHash }} \
243+ {{- if semverCompare ">=1.9.X" .KubeletVersion }}
244+ --ignore-preflight-errors=CRI \
245+ {{- end }}
246+ {{ .ServerAddr }}
247+ fi
248+
249+ if [[ ! -x /usr/local/bin/health-monitor.sh ]]; then
250+ curl -Lfo /usr/local/bin/health-monitor.sh \
251+ https://raw.githubusercontent.com/kubermatic/machine-controller/8b5b66e4910a6228dfaecccaa0a3b05ec4902f8e/pkg/userdata/scripts/health-monitor.sh
252+ chmod +x /usr/local/bin/health-monitor.sh
253+ fi
254+
255+ systemctl enable --now --no-block kubelet-healthcheck.service
256+ systemctl enable --now --no-block docker-healthcheck.service
240257
241258- path: "/usr/local/bin/supervise.sh"
242- permissions: "0777 "
259+ permissions: "0755 "
243260 content: |
244261 #!/bin/bash
245262 set -xeuo pipefail
@@ -261,6 +278,32 @@ write_files:
261278 RemainAfterExit=true
262279 ExecStart=/usr/local/bin/supervise.sh /usr/local/bin/setup
263280
281+ - path: /etc/systemd/system/kubelet-healthcheck.service
282+ permissions: "0644"
283+ content: |
284+ [Unit]
285+ Requires=kubelet.service
286+ After=kubelet.service
287+
288+ [Service]
289+ ExecStart=/usr/local/bin/health-monitor.sh kubelet
290+
291+ [Install]
292+ WantedBy=multi-user.target
293+
294+ - path: /etc/systemd/system/docker-healthcheck.service
295+ permissions: "0644"
296+ content: |
297+ [Unit]
298+ Requires=docker.service
299+ After=docker.service
300+
301+ [Service]
302+ ExecStart=/usr/local/bin/health-monitor.sh container-runtime
303+
304+ [Install]
305+ WantedBy=multi-user.target
306+
264307runcmd:
265308- systemctl enable --now setup.service
266309`
0 commit comments