Skip to content

Commit 50f354c

Browse files
authored
Create k0s.yaml
1 parent d7f297a commit 50f354c

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

templates/k0s.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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: 1.1.0
14+
15+
base:
16+
- template://_images/ubuntu-lts
17+
18+
# Mounts are disabled in this template, but can be enabled optionally.
19+
mounts: []
20+
21+
# containerd is managed by k0s, not by Lima, so the values are set to false here.
22+
containerd:
23+
system: false
24+
user: false
25+
26+
provision:
27+
- mode: system
28+
script: |
29+
#!/bin/bash
30+
set -eux -o pipefail
31+
command -v k0s >/dev/null 2>&1 && exit 0
32+
33+
# install k0s prerequisites
34+
curl -sfL https://get.k0s.sh | sh
35+
36+
- mode: system
37+
script: |
38+
#!/bin/bash
39+
set -eux -o pipefail
40+
41+
# start k0s as a single node cluster
42+
if ! systemctl status k0scontroller >/dev/null 2>&1; then
43+
k0s install controller --single
44+
fi
45+
46+
systemctl start k0scontroller
47+
48+
probes:
49+
- description: "k0s to be running"
50+
script: |
51+
#!/bin/bash
52+
set -eux -o pipefail
53+
if ! timeout 30s bash -c "until sudo test -f /var/lib/k0s/pki/admin.conf; do sleep 3; done"; then
54+
echo >&2 "k0s kubeconfig file has not yet been created"
55+
exit 1
56+
fi
57+
hint: |
58+
The k0s control plane is not ready yet.
59+
Run "limactl shell k0s sudo journalctl -u k0scontroller" to debug.
60+
61+
copyToHost:
62+
- guest: "/var/lib/k0s/pki/admin.conf"
63+
host: "{{.Dir}}/copied-from-guest/kubeconfig.yaml"
64+
deleteOnStop: true
65+
message: |
66+
To run `kubectl` on the host (assumes kubectl is installed), run the following commands:
67+
------
68+
export KUBECONFIG="{{.Dir}}/copied-from-guest/kubeconfig.yaml"
69+
kubectl ...
70+
------

0 commit comments

Comments
 (0)