1 {{- range $clusterName, $cluster := .Values.clusters }}
3 apiVersion: controlplane.cluster.x-k8s.io/v1alpha4
4 kind: KubeadmControlPlane
6 name: {{ $clusterName }}
12 node-labels: metal3.io/uuid={{ "{{" }} ds.meta_data.uuid {{ "}}" }}
13 cpu-manager-policy: static
14 topology-manager-policy: best-effort
15 kube-reserved: cpu=200m,memory=512Mi
16 name: '{{ "{{" }} ds.meta_data.name {{ "}}" }}'
21 node-labels: metal3.io/uuid={{ "{{" }} ds.meta_data.uuid {{ "}}" }}
22 name: '{{ "{{" }} ds.meta_data.name {{ "}}" }}'
24 {{- if $cluster.networks }}
25 # Without touching up /etc/hosts, kubeadm may pick the wrong
26 # (i.e. provisioning network) address for the node IP
27 - sed -i "1i $(ip -4 addr show dev {{ $cluster.networks.baremetal.interface }} | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -1) $(hostname)" /etc/hosts
29 - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
30 - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
31 - curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
32 - add-apt-repository "deb https://apt.kubernetes.io/ kubernetes-xenial main"
34 - apt-get install -y ca-certificates
35 {{- if $cluster.keepalived }}
36 - apt-get install -y keepalived
37 - systemctl enable --now keepalived
39 - /usr/local/bin/install-container-runtime.sh
40 - apt-get install -y kubelet={{ $cluster.kubeVersion }} kubeadm={{ $cluster.kubeVersion }} kubectl={{ $cluster.kubeVersion }}
41 - systemctl enable --now kubelet
43 - mkdir -p /home/ubuntu/.kube
44 - cp /etc/kubernetes/admin.conf /home/ubuntu/.kube/config
45 - chown ubuntu:ubuntu /home/ubuntu/.kube/config
46 # This must be done after kubeadm as the cabpk provider relies on
47 # files in /var/run, which won't persist after a reboot
48 - /usr/local/bin/set_kernel_cmdline.sh
50 {{ include "clusters.keepalived" $cluster | indent 4 }}
51 {{ include "clusters.containerRuntime" $cluster | indent 4 }}
52 - path: /etc/systemd/system/containerd.service.d/override.conf
54 {{ $.Files.Get "resources/override.conf" | indent 8 }}
55 - path: /usr/local/bin/set_kernel_cmdline.sh
58 {{ $.Files.Get "resources/set_kernel_cmdline.sh" | indent 8 }}
60 - name: {{ $cluster.userData.name }}
62 lockPassword: False # Necessary to allow password login
63 passwd: {{ $cluster.userData.hashedPassword }}
65 - {{ $cluster.userData.sshAuthorizedKey }}
66 sudo: "ALL=(ALL) NOPASSWD:ALL"
69 - {{ $cluster.userData.sshAuthorizedKey }}
72 apiVersion: infrastructure.cluster.x-k8s.io/v1alpha5
73 kind: Metal3MachineTemplate
74 name: {{ $clusterName }}-controlplane
76 replicas: {{ $cluster.numControlPlaneMachines }}
81 version: {{ $cluster.k8sVersion }}