Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/templates/k0s.yaml
2612 views
1
# Deploy kubernetes via k0s (which installs a bundled containerd).
2
# $ limactl start ./k0s.yaml
3
# $ limactl shell k0s kubectl
4
#
5
# It can be accessed from the host by exporting the kubeconfig file;
6
# the ports are already forwarded automatically by lima:
7
#
8
# $ export KUBECONFIG=$(limactl list k0s --format 'unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml')
9
# $ kubectl get no
10
# NAME STATUS ROLES AGE VERSION
11
# lima-k0s Ready control-plane 2m48s v1.33.2+k0s
12
13
minimumLimaVersion: 2.0.0
14
15
base: template:_images/ubuntu-lts
16
17
# Mounts are disabled in this template, but can be enabled optionally.
18
mounts: []
19
20
# containerd is managed by k0s, not by Lima, so the values are set to false here.
21
containerd:
22
system: false
23
user: false
24
25
provision:
26
- mode: system
27
script: |
28
#!/bin/bash
29
set -eux -o pipefail
30
command -v k0s >/dev/null 2>&1 && exit 0
31
32
# install k0s prerequisites
33
curl -sfL https://get.k0s.sh | sh
34
35
- mode: system
36
script: |
37
#!/bin/bash
38
set -eux -o pipefail
39
40
# start k0s as a single node cluster
41
if ! systemctl status k0scontroller >/dev/null 2>&1; then
42
k0s install controller --single
43
fi
44
45
systemctl start k0scontroller
46
47
probes:
48
- description: "k0s to be running"
49
script: |
50
#!/bin/bash
51
set -eux -o pipefail
52
if ! timeout 30s bash -c "until sudo test -f /var/lib/k0s/pki/admin.conf; do sleep 3; done"; then
53
echo >&2 "k0s kubeconfig file has not yet been created"
54
exit 1
55
fi
56
hint: |
57
The k0s control plane is not ready yet.
58
Run "limactl shell k0s sudo journalctl -u k0scontroller" to debug.
59
60
copyToHost:
61
- guest: "/var/lib/k0s/pki/admin.conf"
62
host: "{{.Dir}}/copied-from-guest/kubeconfig.yaml"
63
deleteOnStop: true
64
message: |
65
To run `kubectl` on the host (assumes kubectl is installed), run the following commands:
66
------
67
export KUBECONFIG="{{.Dir}}/copied-from-guest/kubeconfig.yaml"
68
kubectl ...
69
------
70
71