Skip to content

Commit 7bd26b1

Browse files
committed
Added k0s template
Signed-off-by: Andrei Gaivoronskii <[email protected]>
1 parent d7f297a commit 7bd26b1

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

templates/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Container image builders:
5555

5656
Container orchestration:
5757
- [`faasd`](./faasd.yaml): [Faasd](https://docs.openfaas.com/deployment/edge/)
58+
- [`k0s`](./k0s.yaml): [k0s](https://k0sproject.io/) Zero Friction Kubernetes
5859
- [`k3s`](./k3s.yaml): Kubernetes via k3s
5960
- [`k8s`](./k8s.yaml): Kubernetes via kubeadm
6061
- [`experimental/u7s`](./experimental/u7s.yaml): [Usernetes](https://github.com/rootless-containers/usernetes): Rootless Kubernetes

templates/k0s.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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: 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+
------

0 commit comments

Comments
 (0)