| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | minimumLimaVersion: 2.0.0 |
| 26 | |
| 27 | base: template:_images/ubuntu-lts |
| 28 | |
| 29 | |
| 30 | mounts: [] |
| 31 | |
| 32 | containerd: |
| 33 | system: false |
| 34 | user: false |
| 35 | provision: |
| 36 | - mode: system |
| 37 | script: | |
| 38 | #!/bin/sh |
| 39 | if [ ! -d /var/lib/rancher/k3s ]; then |
| 40 | {{- if .Param.proxy }} |
| 41 | INSTALL_K3S_ARTIFACT_URL={{.Param.proxy}}/HTTPS///github.com/k3s-io/k3s/releases/download |
| 42 | export INSTALL_K3S_ARTIFACT_URL |
| 43 | {{- end}} |
| 44 | {{if .Param.mirror }} |
| 45 | mkdir -p /etc/rancher/k3s |
| 46 | cat <<EOF >/etc/rancher/k3s/registries.yaml |
| 47 | mirrors: |
| 48 | "*": |
| 49 | endpoint: |
| 50 | - "{{.Param.mirror}}" |
| 51 | EOF |
| 52 | {{end}} |
| 53 | {{if not ( and .Param.url .Param.token )}} |
| 54 | curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --write-kubeconfig-mode 644" sh - |
| 55 | {{else}} |
| 56 | curl -sfL https://get.k3s.io | K3S_URL={{.Param.url}} K3S_TOKEN={{.Param.token}} sh - |
| 57 | {{end}} |
| 58 | fi |
| 59 | probes: |
| 60 | - script: | |
| 61 | #!/bin/bash |
| 62 | set -eux -o pipefail |
| 63 | {{if not ( and .Param.url .Param.token )}} |
| 64 | if ! timeout 30s bash -c "until test -f /etc/rancher/k3s/k3s.yaml; do sleep 3; done"; then |
| 65 | echo >&2 "k3s is not running yet" |
| 66 | exit 1 |
| 67 | fi |
| 68 | {{end}} |
| 69 | hint: | |
| 70 | The k3s kubeconfig file has not yet been created. |
| 71 | Run "limactl shell k3s sudo journalctl -u k3s" to check the log. |
| 72 | If that is still empty, check the bottom of the log at "/var/log/cloud-init-output.log". |
| 73 | copyToHost: |
| 74 | - guest: "/etc/rancher/k3s/k3s.yaml" |
| 75 | host: "{{.Dir}}/copied-from-guest/kubeconfig.yaml" |
| 76 | skipIfMissing: true |
| 77 | deleteOnStop: true |
| 78 | message: | |
| 79 | {{- if not ( and .Param.url .Param.token ) -}} |
| 80 | To run `kubectl` on the host (assumes kubectl is installed), run the following commands: |
| 81 | ------ |
| 82 | export KUBECONFIG="{{.Dir}}/copied-from-guest/kubeconfig.yaml" |
| 83 | kubectl ... |
| 84 | ------ |
| 85 | {{end}} |
| 86 | param: |
| 87 | |
| 88 | |
| 89 | proxy: "" |
| 90 | |
| 91 | |
| 92 | mirror: "" |
| 93 | url: "" |
| 94 | token: "" |