Skip to content

Create k0s template #3728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Container image builders:

Container orchestration:
- [`faasd`](./faasd.yaml): [Faasd](https://docs.openfaas.com/deployment/edge/)
- [`k0s`](./k0s.yaml): [k0s](https://k0sproject.io/) Zero Friction Kubernetes
- [`k3s`](./k3s.yaml): Kubernetes via k3s
- [`k8s`](./k8s.yaml): Kubernetes via kubeadm
- [`experimental/u7s`](./experimental/u7s.yaml): [Usernetes](https://github.com/rootless-containers/usernetes): Rootless Kubernetes
Expand Down
69 changes: 69 additions & 0 deletions templates/k0s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Deploy kubernetes via k0s (which installs a bundled containerd).
# $ limactl start ./k0s.yaml
# $ limactl shell k0s kubectl
#
# It can be accessed from the host by exporting the kubeconfig file;
# the ports are already forwarded automatically by lima:
#
# $ export KUBECONFIG=$(limactl list k0s --format 'unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml')
# $ kubectl get no
# NAME STATUS ROLES AGE VERSION
# lima-k0s Ready control-plane 2m48s v1.33.2+k0s

minimumLimaVersion: 1.1.0

base: template://_images/ubuntu-lts

# Mounts are disabled in this template, but can be enabled optionally.
mounts: []

# containerd is managed by k0s, not by Lima, so the values are set to false here.
containerd:
system: false
user: false

provision:
- mode: system
script: |
#!/bin/bash
set -eux -o pipefail
command -v k0s >/dev/null 2>&1 && exit 0

# install k0s prerequisites
curl -sfL https://get.k0s.sh | sh

- mode: system
script: |
#!/bin/bash
set -eux -o pipefail

# start k0s as a single node cluster
if ! systemctl status k0scontroller >/dev/null 2>&1; then
k0s install controller --single
fi

systemctl start k0scontroller

probes:
- description: "k0s to be running"
script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 30s bash -c "until sudo test -f /var/lib/k0s/pki/admin.conf; do sleep 3; done"; then
echo >&2 "k0s kubeconfig file has not yet been created"
exit 1
fi
hint: |
The k0s control plane is not ready yet.
Run "limactl shell k0s sudo journalctl -u k0scontroller" to debug.

copyToHost:
- guest: "/var/lib/k0s/pki/admin.conf"
host: "{{.Dir}}/copied-from-guest/kubeconfig.yaml"
deleteOnStop: true
message: |
To run `kubectl` on the host (assumes kubectl is installed), run the following commands:
------
export KUBECONFIG="{{.Dir}}/copied-from-guest/kubeconfig.yaml"
kubectl ...
------
Loading