|
| 1 | +#cloud-config |
| 2 | + |
| 3 | +write_files: |
| 4 | + - path: /etc/systemd/system/containerd-installation.service |
| 5 | + permissions: 0644 |
| 6 | + owner: root |
| 7 | + content: | |
| 8 | + # installed by cloud-init |
| 9 | + [Unit] |
| 10 | + Description=Download and install containerd binaries and configurations. |
| 11 | + After=network-online.target |
| 12 | +
|
| 13 | + [Service] |
| 14 | + Type=oneshot |
| 15 | + RemainAfterExit=yes |
| 16 | + ExecStartPre=/bin/mkdir -p /home/containerd |
| 17 | + ExecStartPre=/bin/mount --bind /home/containerd /home/containerd |
| 18 | + ExecStartPre=/bin/mount -o remount,exec /home/containerd |
| 19 | + ExecStartPre=/usr/bin/curl --fail --retry 5 --retry-delay 3 --silent --show-error -H "X-Google-Metadata-Request: True" -o /home/containerd/configure.sh http://metadata.google.internal/computeMetadata/v1/instance/attributes/containerd-configure-sh |
| 20 | + ExecStartPre=/bin/chmod 544 /home/containerd/configure.sh |
| 21 | + ExecStart=/home/containerd/configure.sh |
| 22 | +
|
| 23 | + [Install] |
| 24 | + WantedBy=containerd.target |
| 25 | +
|
| 26 | + - path: /etc/systemd/system/containerd.service |
| 27 | + permissions: 0644 |
| 28 | + owner: root |
| 29 | + content: | |
| 30 | + # installed by cloud-init |
| 31 | + [Unit] |
| 32 | + Description=containerd container runtime |
| 33 | + Documentation=https://containerd.io |
| 34 | + After=containerd-installation.service |
| 35 | +
|
| 36 | + [Service] |
| 37 | + Restart=always |
| 38 | + RestartSec=5 |
| 39 | + Delegate=yes |
| 40 | + KillMode=process |
| 41 | + OOMScoreAdjust=-999 |
| 42 | + LimitNOFILE=1048576 |
| 43 | + # Having non-zero Limit*s causes performance problems due to accounting overhead |
| 44 | + # in the kernel. We recommend using cgroups to do container-local accounting. |
| 45 | + LimitNPROC=infinity |
| 46 | + LimitCORE=infinity |
| 47 | + TasksMax=infinity |
| 48 | + ExecStartPre=/sbin/modprobe overlay |
| 49 | + ExecStart=/home/containerd/usr/local/bin/containerd |
| 50 | +
|
| 51 | + [Install] |
| 52 | + WantedBy=containerd.target |
| 53 | +
|
| 54 | + - path: /etc/systemd/system/containerd.target |
| 55 | + permissions: 0644 |
| 56 | + owner: root |
| 57 | + content: | |
| 58 | + [Unit] |
| 59 | + Description=Containerd |
| 60 | +
|
| 61 | + [Install] |
| 62 | + WantedBy=multi-user.target |
| 63 | +
|
| 64 | +runcmd: |
| 65 | + # Stop the existing containerd service if there is one. (for Docker 18.09+) |
| 66 | + - systemctl is-active containerd && systemctl stop containerd |
| 67 | + - systemctl daemon-reload |
| 68 | + - systemctl enable containerd-installation.service |
| 69 | + - systemctl enable containerd.service |
| 70 | + - systemctl enable containerd.target |
| 71 | + - systemctl start containerd.target |
| 72 | + # Start docker after containerd is running. (for Docker 18.09+) |
| 73 | + - systemctl is-active docker || systemctl start docker |
0 commit comments