|
| 1 | +#cloud-config |
| 2 | + |
| 3 | +write_files: |
| 4 | +# Setup cri-containerd. |
| 5 | + - path: /etc/systemd/system/cri-containerd-installation.service |
| 6 | + permissions: 0644 |
| 7 | + owner: root |
| 8 | + content: | |
| 9 | + # installed by cloud-init |
| 10 | + [Unit] |
| 11 | + Description=Download and install cri-containerd binaries and configurations. |
| 12 | + After=network-online.target |
| 13 | +
|
| 14 | + [Service] |
| 15 | + Type=oneshot |
| 16 | + RemainAfterExit=yes |
| 17 | + ExecStartPre=/bin/mkdir -p /home/cri-containerd |
| 18 | + ExecStartPre=/bin/mount --bind /home/cri-containerd /home/cri-containerd |
| 19 | + ExecStartPre=/bin/mount -o remount,exec /home/cri-containerd |
| 20 | + ExecStartPre=/usr/bin/curl --fail --retry 5 --retry-delay 3 --silent --show-error -H "X-Google-Metadata-Request: True" -o /home/cri-containerd/configure.sh http://metadata.google.internal/computeMetadata/v1/instance/attributes/cri-containerd-configure-sh |
| 21 | + ExecStartPre=/bin/chmod 544 /home/cri-containerd/configure.sh |
| 22 | + ExecStart=/home/cri-containerd/configure.sh |
| 23 | +
|
| 24 | + [Install] |
| 25 | + WantedBy=cri-containerd.target |
| 26 | +
|
| 27 | + - path: /etc/containerd/config.toml |
| 28 | + permissions: 0644 |
| 29 | + owner: root |
| 30 | + content: | |
| 31 | + # installed by cloud-init |
| 32 | + oom_score = -999 |
| 33 | +
|
| 34 | + [plugins.linux] |
| 35 | + shim = "/home/cri-containerd/usr/local/bin/containerd-shim" |
| 36 | + runtime = "/home/cri-containerd/usr/local/sbin/runc" |
| 37 | +
|
| 38 | + - path: /etc/systemd/system/containerd.service |
| 39 | + permissions: 0644 |
| 40 | + owner: root |
| 41 | + content: | |
| 42 | + # installed by cloud-init |
| 43 | + [Unit] |
| 44 | + Description=containerd container runtime |
| 45 | + Documentation=https://containerd.io |
| 46 | + After=cri-containerd-installation.service |
| 47 | +
|
| 48 | + [Service] |
| 49 | + Restart=always |
| 50 | + RestartSec=5 |
| 51 | + Delegate=yes |
| 52 | + KillMode=process |
| 53 | + LimitNOFILE=1048576 |
| 54 | + # Having non-zero Limit*s causes performance problems due to accounting overhead |
| 55 | + # in the kernel. We recommend using cgroups to do container-local accounting. |
| 56 | + LimitNPROC=infinity |
| 57 | + LimitCORE=infinity |
| 58 | + ExecStartPre=/sbin/modprobe overlay |
| 59 | + ExecStart=/home/cri-containerd/usr/local/bin/containerd --log-level debug |
| 60 | +
|
| 61 | + [Install] |
| 62 | + WantedBy=cri-containerd.target |
| 63 | +
|
| 64 | + - path: /etc/systemd/system/cri-containerd.service |
| 65 | + permissions: 0644 |
| 66 | + owner: root |
| 67 | + content: | |
| 68 | + # installed by cloud-init |
| 69 | + [Unit] |
| 70 | + Description=Kubernetes containerd CRI shim |
| 71 | + Requires=network-online.target |
| 72 | + After=cri-containerd-installation.service |
| 73 | +
|
| 74 | + [Service] |
| 75 | + Restart=always |
| 76 | + RestartSec=5 |
| 77 | + LimitNOFILE=1048576 |
| 78 | + # Having non-zero Limit*s causes performance problems due to accounting overhead |
| 79 | + # in the kernel. We recommend using cgroups to do container-local accounting. |
| 80 | + LimitNPROC=infinity |
| 81 | + LimitCORE=infinity |
| 82 | + # cri-containerd on master uses the cni binary and config in the |
| 83 | + # release tarball. |
| 84 | + ExecStart=/home/cri-containerd/usr/local/bin/cri-containerd \ |
| 85 | + --logtostderr --v=4 \ |
| 86 | + --network-bin-dir=/home/cri-containerd/opt/cni/bin \ |
| 87 | + --network-conf-dir=/home/cri-containerd/etc/cni/net.d |
| 88 | +
|
| 89 | + [Install] |
| 90 | + WantedBy=cri-containerd.target |
| 91 | +
|
| 92 | + - path: /etc/systemd/system/cri-containerd-monitor.service |
| 93 | + permissions: 0644 |
| 94 | + owner: root |
| 95 | + content: | |
| 96 | + [Unit] |
| 97 | + Description=Kubernetes health monitoring for cri-containerd and containerd |
| 98 | + After=containerd.service cri-containerd.service |
| 99 | +
|
| 100 | + [Service] |
| 101 | + Restart=always |
| 102 | + RestartSec=10 |
| 103 | + RemainAfterExit=yes |
| 104 | + RemainAfterExit=yes |
| 105 | + ExecStartPre=/bin/chmod 544 /home/cri-containerd/opt/cri-containerd/cluster/health-monitor.sh |
| 106 | + ExecStart=/bin/bash -c 'CRICTL=/home/cri-containerd/usr/local/bin/crictl \ |
| 107 | + /home/cri-containerd/opt/cri-containerd/cluster/health-monitor.sh' |
| 108 | +
|
| 109 | + [Install] |
| 110 | + WantedBy=cri-containerd.target |
| 111 | +
|
| 112 | + # TODO(random-liu): Guarantee order. |
| 113 | + - path: /etc/systemd/system/cri-containerd.target |
| 114 | + permissions: 0644 |
| 115 | + owner: root |
| 116 | + content: | |
| 117 | + [Unit] |
| 118 | + Description=CRI Containerd |
| 119 | +
|
| 120 | + [Install] |
| 121 | + WantedBy=kubernetes.target |
| 122 | +
|
| 123 | +# Setup kubernetes. |
| 124 | + - path: /etc/systemd/system/kube-master-installation.service |
| 125 | + permissions: 0644 |
| 126 | + owner: root |
| 127 | + content: | |
| 128 | + [Unit] |
| 129 | + Description=Download and install k8s binaries and configurations |
| 130 | + After=network-online.target |
| 131 | +
|
| 132 | + [Service] |
| 133 | + Type=oneshot |
| 134 | + RemainAfterExit=yes |
| 135 | + ExecStartPre=/bin/mkdir -p /home/kubernetes/bin |
| 136 | + ExecStartPre=/bin/mount --bind /home/kubernetes/bin /home/kubernetes/bin |
| 137 | + ExecStartPre=/bin/mount -o remount,exec /home/kubernetes/bin |
| 138 | + ExecStartPre=/usr/bin/curl --fail --retry 5 --retry-delay 3 --silent --show-error -H "X-Google-Metadata-Request: True" -o /home/kubernetes/bin/configure.sh http://metadata.google.internal/computeMetadata/v1/instance/attributes/configure-sh |
| 139 | + ExecStartPre=/bin/chmod 544 /home/kubernetes/bin/configure.sh |
| 140 | + ExecStart=/home/kubernetes/bin/configure.sh |
| 141 | +
|
| 142 | + [Install] |
| 143 | + WantedBy=kubernetes.target |
| 144 | +
|
| 145 | + - path: /etc/systemd/system/kube-master-configuration.service |
| 146 | + permissions: 0644 |
| 147 | + owner: root |
| 148 | + content: | |
| 149 | + [Unit] |
| 150 | + Description=Configure kubernetes master |
| 151 | + After=kube-master-installation.service |
| 152 | +
|
| 153 | + [Service] |
| 154 | + Type=oneshot |
| 155 | + RemainAfterExit=yes |
| 156 | + ExecStartPre=/bin/chmod 544 /home/kubernetes/bin/configure-helper.sh |
| 157 | + ExecStart=/home/kubernetes/bin/configure-helper.sh |
| 158 | +
|
| 159 | + [Install] |
| 160 | + WantedBy=kubernetes.target |
| 161 | +
|
| 162 | + - path: /etc/systemd/system/kubelet-monitor.service |
| 163 | + permissions: 0644 |
| 164 | + owner: root |
| 165 | + content: | |
| 166 | + [Unit] |
| 167 | + Description=Kubernetes health monitoring for kubelet |
| 168 | + After=kube-master-configuration.service |
| 169 | +
|
| 170 | + [Service] |
| 171 | + Restart=always |
| 172 | + RestartSec=10 |
| 173 | + RemainAfterExit=yes |
| 174 | + RemainAfterExit=yes |
| 175 | + ExecStartPre=/bin/chmod 544 /home/kubernetes/bin/health-monitor.sh |
| 176 | + ExecStart=/home/kubernetes/bin/health-monitor.sh kubelet |
| 177 | +
|
| 178 | + [Install] |
| 179 | + WantedBy=kubernetes.target |
| 180 | +
|
| 181 | + - path: /etc/systemd/system/kube-logrotate.timer |
| 182 | + permissions: 0644 |
| 183 | + owner: root |
| 184 | + content: | |
| 185 | + [Unit] |
| 186 | + Description=Hourly kube-logrotate invocation |
| 187 | +
|
| 188 | + [Timer] |
| 189 | + OnCalendar=hourly |
| 190 | +
|
| 191 | + [Install] |
| 192 | + WantedBy=kubernetes.target |
| 193 | +
|
| 194 | + - path: /etc/systemd/system/kube-logrotate.service |
| 195 | + permissions: 0644 |
| 196 | + owner: root |
| 197 | + content: | |
| 198 | + [Unit] |
| 199 | + Description=Kubernetes log rotation |
| 200 | + After=kube-master-configuration.service |
| 201 | +
|
| 202 | + [Service] |
| 203 | + Type=oneshot |
| 204 | + ExecStart=-/usr/sbin/logrotate /etc/logrotate.conf |
| 205 | +
|
| 206 | + [Install] |
| 207 | + WantedBy=kubernetes.target |
| 208 | +
|
| 209 | + - path: /etc/systemd/system/kubernetes.target |
| 210 | + permissions: 0644 |
| 211 | + owner: root |
| 212 | + content: | |
| 213 | + [Unit] |
| 214 | + Description=Kubernetes |
| 215 | +
|
| 216 | + [Install] |
| 217 | + WantedBy=multi-user.target |
| 218 | +
|
| 219 | +runcmd: |
| 220 | + - systemctl daemon-reload |
| 221 | + - systemctl enable containerd.service |
| 222 | + - systemctl enable cri-containerd-installation.service |
| 223 | + - systemctl enable cri-containerd.service |
| 224 | + - systemctl enable cri-containerd-monitor.service |
| 225 | + - systemctl enable cri-containerd.target |
| 226 | + - systemctl enable kube-master-installation.service |
| 227 | + - systemctl enable kube-master-configuration.service |
| 228 | + - systemctl enable kubelet-monitor.service |
| 229 | + - systemctl enable kube-logrotate.timer |
| 230 | + - systemctl enable kube-logrotate.service |
| 231 | + - systemctl enable kubernetes.target |
| 232 | + - systemctl start kubernetes.target |
0 commit comments