|
| 1 | +# Deploy nomad with containerd |
| 2 | +# $ limactl start ./nomad.yaml |
| 3 | +# $ limactl shell nomad nomad |
| 4 | +# |
| 5 | +# See <http://localhost:4646> |
| 6 | +# |
| 7 | +# More examples can be found at: |
| 8 | +# https://github.com/Roblox/nomad-driver-containerd/tree/master/example |
| 9 | + |
| 10 | +# This example requires Lima v0.7.0 or later. |
| 11 | +images: |
| 12 | + # Image is set to focal (20.04 LTS) for long-term stability |
| 13 | + # Hint: run `limactl prune` to invalidate the "current" cache |
| 14 | + - location: "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img" |
| 15 | + arch: "x86_64" |
| 16 | + - location: "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-arm64.img" |
| 17 | + arch: "aarch64" |
| 18 | +mounts: |
| 19 | + - location: "~" |
| 20 | + writable: false |
| 21 | + - location: "/tmp/lima" |
| 22 | + writable: true |
| 23 | +containerd: |
| 24 | + system: true |
| 25 | + user: false |
| 26 | +# See https://learn.hashicorp.com/tutorials/nomad/get-started-install |
| 27 | +provision: |
| 28 | + - mode: system |
| 29 | + script: | |
| 30 | + #!/bin/sh |
| 31 | + command -v nomad >/dev/null 2>&1 && exit 0 |
| 32 | + curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - |
| 33 | + echo "deb https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list |
| 34 | + apt-get update |
| 35 | + apt-get install -y nomad consul golang-cfssl |
| 36 | + sed -e '/^client/a \ \ cni_path = "/usr/local/libexec/cni"\n\ \ cni_config_dir = "/etc/cni/net.d"' -i /etc/nomad.d/nomad.hcl |
| 37 | + # install containerd-driver |
| 38 | + DRIVER_VERSION=0.9.2 |
| 39 | + case $(uname -m) in |
| 40 | + amd64|x86_64) |
| 41 | + curl -sSL -o containerd-driver https://github.com/Roblox/nomad-driver-containerd/releases/download/v${DRIVER_VERSION}/containerd-driver |
| 42 | + ;; |
| 43 | + arm64|aarch64) |
| 44 | + curl -sSL -o containerd-driver https://github.com/Roblox/nomad-driver-containerd/releases/download/v${DRIVER_VERSION}/containerd-driver-arm64 |
| 45 | + ;; |
| 46 | + esac |
| 47 | + sudo install -D containerd-driver /opt/nomad/data/plugins/containerd-driver |
| 48 | + cat <<EOF | sudo tee -a /etc/nomad.d/nomad.hcl |
| 49 | +
|
| 50 | + plugin "containerd-driver" { |
| 51 | + config { |
| 52 | + enabled = true |
| 53 | + containerd_runtime = "io.containerd.runc.v2" |
| 54 | + stats_interval = "5s" |
| 55 | + } |
| 56 | + } |
| 57 | + EOF |
| 58 | + systemctl enable --now nomad consul |
| 59 | + - mode: user |
| 60 | + script: | |
| 61 | + #!/bin/sh |
| 62 | + nomad -autocomplete-install |
| 63 | +probes: |
| 64 | + - script: | |
| 65 | + #!/bin/bash |
| 66 | + set -eux -o pipefail |
| 67 | + if ! timeout 30s bash -c "until command -v nomad >/dev/null 2>&1; do sleep 3; done"; then |
| 68 | + echo >&2 "nomad is not installed yet" |
| 69 | + exit 1 |
| 70 | + fi |
| 71 | + hint: See "/var/log/cloud-init-output.log". in the guest |
0 commit comments