|
| 1 | +--- |
| 2 | +apiVersion: cluster.x-k8s.io/v1beta1 |
| 3 | +kind: Cluster |
| 4 | +metadata: |
| 5 | + name: ${CLUSTER_NAME} |
| 6 | + namespace: ${NAMESPACE} |
| 7 | +spec: |
| 8 | + clusterNetwork: |
| 9 | + pods: |
| 10 | + cidrBlocks: ${POD_CIDR:=["10.240.0.0/12"]} |
| 11 | + controlPlaneRef: |
| 12 | + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 |
| 13 | + kind: KubeadmControlPlane |
| 14 | + name: ${CLUSTER_NAME}-controlplane |
| 15 | + namespace: ${NAMESPACE} |
| 16 | + infrastructureRef: |
| 17 | + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 |
| 18 | + kind: MetalStackCluster |
| 19 | + name: ${CLUSTER_NAME} |
| 20 | + namespace: ${NAMESPACE} |
| 21 | +--- |
| 22 | +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 |
| 23 | +kind: MetalStackCluster |
| 24 | +metadata: |
| 25 | + name: ${CLUSTER_NAME} |
| 26 | + namespace: ${NAMESPACE} |
| 27 | +spec: |
| 28 | + projectID: ${METAL_PROJECT_ID} |
| 29 | + partition: ${METAL_PARTITION} |
| 30 | + firewall: |
| 31 | + size: ${FIREWALL_MACHINE_SIZE} |
| 32 | + image: ${FIREWALL_MACHINE_IMAGE} |
| 33 | + networks: ${FIREWALL_NETWORKS:=[internet]} |
| 34 | +--- |
| 35 | +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 |
| 36 | +kind: MetalStackMachineTemplate |
| 37 | +metadata: |
| 38 | + name: ${CLUSTER_NAME}-controlplane |
| 39 | + namespace: ${NAMESPACE} |
| 40 | +spec: |
| 41 | + template: |
| 42 | + spec: |
| 43 | + size: ${CONTROL_PLANE_MACHINE_SIZE} |
| 44 | + image: ${CONTROL_PLANE_MACHINE_IMAGE} |
| 45 | +--- |
| 46 | +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 |
| 47 | +kind: MetalStackMachineTemplate |
| 48 | +metadata: |
| 49 | + name: ${CLUSTER_NAME}-worker |
| 50 | +spec: |
| 51 | + template: |
| 52 | + spec: |
| 53 | + size: ${WORKER_MACHINE_SIZE} |
| 54 | + image: ${WORKER_MACHINE_IMAGE} |
| 55 | +--- |
| 56 | +kind: KubeadmControlPlane |
| 57 | +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 |
| 58 | +metadata: |
| 59 | + name: ${CLUSTER_NAME}-controlplane |
| 60 | +spec: |
| 61 | + replicas: ${CONTROL_PLANE_MACHINE_COUNT} |
| 62 | + version: ${KUBERNETES_VERSION} |
| 63 | + machineTemplate: |
| 64 | + nodeDrainTimeout: 10m |
| 65 | + infrastructureRef: |
| 66 | + kind: MetalStackMachineTemplate |
| 67 | + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 |
| 68 | + name: ${CLUSTER_NAME}-controlplane |
| 69 | + kubeadmConfigSpec: |
| 70 | + format: ignition |
| 71 | + clusterConfiguration: |
| 72 | + controlPlaneEndpoint: ${CONTROL_PLANE_ENDPOINT} |
| 73 | + initConfiguration: |
| 74 | + localAPIEndpoint: |
| 75 | + bindPort: ${CONTROL_PLANE_PORT:=443} |
| 76 | + nodeRegistration: {} |
| 77 | + joinConfiguration: |
| 78 | + controlPlane: {} |
| 79 | + nodeRegistration: {} |
| 80 | + ignition: |
| 81 | + containerLinuxConfig: |
| 82 | + additionalConfig: | |
| 83 | + systemd: |
| 84 | + units: |
| 85 | + - name: cluster-api-init.service |
| 86 | + enable: true |
| 87 | + contents: |- |
| 88 | + [Unit] |
| 89 | + Description=Prepares the node for bootstrapping with cluster-api kubeadm |
| 90 | + Before=kubeadm.service |
| 91 | + After=network-online.target |
| 92 | + Wants=network-online.target |
| 93 | + [Service] |
| 94 | + Type=oneshot |
| 95 | + Restart=on-failure |
| 96 | + RestartSec=5 |
| 97 | + StartLimitBurst=0 |
| 98 | + EnvironmentFile=/etc/environment |
| 99 | + ExecStart=/var/lib/cluster-api-init/bootstrap.sh |
| 100 | + [Install] |
| 101 | + WantedBy=multi-user.target |
| 102 | + files: |
| 103 | + - path: /var/lib/cluster-api-init/bootstrap.sh |
| 104 | + owner: "root:root" |
| 105 | + permissions: "0744" |
| 106 | + content: ${BOOTSTRAP_SCRIPT:=" |
| 107 | + #!/usr/bin/env bash |
| 108 | + set -eo pipefail |
| 109 | + set +x |
| 110 | + |
| 111 | + apt update |
| 112 | + apt install conntrack |
| 113 | + |
| 114 | + CNI_PLUGINS_VERSION="v1.3.0" |
| 115 | + DEST="/opt/cni/bin" |
| 116 | + mkdir -p "$DEST" |
| 117 | + curl -L "https://github.com/containernetworking/plugins/releases/download/$CNI_PLUGINS_VERSION/cni-plugins-linux-amd64-$CNI_PLUGINS_VERSION.tgz" | tar -C "$DEST" -xz |
| 118 | + |
| 119 | + RELEASE="${KUBERNETES_VERSION}" |
| 120 | + cd /usr/local/bin |
| 121 | + curl -L --remote-name-all https://dl.k8s.io/release/${RELEASE}/bin/linux/amd64/{kubeadm,kubelet,kubectl} |
| 122 | + chmod +x {kubeadm,kubelet,kubectl} |
| 123 | + |
| 124 | + RELEASE_VERSION="v0.16.2" |
| 125 | + curl -sSL "https://raw.githubusercontent.com/kubernetes/release/$RELEASE_VERSION/cmd/krel/templates/latest/kubelet/kubelet.service" | sed "s:/usr/bin:/usr/local/bin:g" | tee /usr/lib/systemd/system/kubelet.service |
| 126 | + mkdir -p /usr/lib/systemd/system/kubelet.service.d |
| 127 | + curl -sSL "https://raw.githubusercontent.com/kubernetes/release/$RELEASE_VERSION/cmd/krel/templates/latest/kubeadm/10-kubeadm.conf" | sed "s:/usr/bin:/usr/local/bin:g" | tee /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf |
| 128 | + |
| 129 | + systemctl enable kubelet.service |
| 130 | +"} |
| 131 | + - path: /etc/containerd/config.toml |
| 132 | + owner: "root:root" |
| 133 | + permissions: "0644" |
| 134 | + content: | |
| 135 | + disabled_plugins = [] |
| 136 | +--- |
| 137 | +apiVersion: cluster.x-k8s.io/v1beta1 |
| 138 | +kind: MachineDeployment |
| 139 | +metadata: |
| 140 | + name: ${CLUSTER_NAME}-md-0 |
| 141 | + labels: |
| 142 | + cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME} |
| 143 | + nodepool: nodepool-0 |
| 144 | +spec: |
| 145 | + clusterName: ${CLUSTER_NAME} |
| 146 | + replicas: ${WORKER_MACHINE_COUNT} |
| 147 | + selector: |
| 148 | + matchLabels: |
| 149 | + cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME} |
| 150 | + nodepool: nodepool-0 |
| 151 | + template: |
| 152 | + metadata: |
| 153 | + labels: |
| 154 | + cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME} |
| 155 | + nodepool: nodepool-0 |
| 156 | + spec: |
| 157 | + nodeDrainTimeout: 120s |
| 158 | + clusterName: ${CLUSTER_NAME} |
| 159 | + version: "${KUBERNETES_VERSION}" |
| 160 | + bootstrap: |
| 161 | + configRef: |
| 162 | + name: ${CLUSTER_NAME}-md-0 |
| 163 | + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 |
| 164 | + kind: KubeadmConfigTemplate |
| 165 | + infrastructureRef: |
| 166 | + name: ${CLUSTER_NAME}-worker |
| 167 | + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 |
| 168 | + kind: MetalStackMachineTemplate |
| 169 | +--- |
| 170 | +apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 |
| 171 | +kind: KubeadmConfigTemplate |
| 172 | +metadata: |
| 173 | + name: ${CLUSTER_NAME}-md-0 |
| 174 | +spec: |
| 175 | + template: |
| 176 | + spec: |
| 177 | + format: ignition |
| 178 | + clusterConfiguration: |
| 179 | + controlPlaneEndpoint: ${CONTROL_PLANE_ENDPOINT} |
| 180 | + joinConfiguration: |
| 181 | + nodeRegistration: {} |
| 182 | + ignition: |
| 183 | + containerLinuxConfig: |
| 184 | + additionalConfig: | |
| 185 | + systemd: |
| 186 | + units: |
| 187 | + - name: cluster-api-init.service |
| 188 | + enable: true |
| 189 | + contents: |- |
| 190 | + [Unit] |
| 191 | + Description=Prepares the node for bootstrapping with cluster-api kubeadm |
| 192 | + Before=kubeadm.service |
| 193 | + After=network-online.target |
| 194 | + Wants=network-online.target |
| 195 | + [Service] |
| 196 | + Type=oneshot |
| 197 | + Restart=on-failure |
| 198 | + RestartSec=5 |
| 199 | + StartLimitBurst=0 |
| 200 | + EnvironmentFile=/etc/environment |
| 201 | + ExecStart=/var/lib/cluster-api-init/bootstrap.sh |
| 202 | + [Install] |
| 203 | + WantedBy=multi-user.target |
| 204 | + files: |
| 205 | + - path: /var/lib/cluster-api-init/bootstrap.sh |
| 206 | + owner: "root:root" |
| 207 | + permissions: "0744" |
| 208 | + content: ${BOOTSTRAP_SCRIPT} |
| 209 | + - path: /etc/containerd/config.toml |
| 210 | + owner: "root:root" |
| 211 | + permissions: "0644" |
| 212 | + content: | |
| 213 | + disabled_plugins = [] |
0 commit comments