Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/templates/experimental/rke2.yaml
2647 views
1
# Deploy kubernetes via rke2 (which installs a bundled containerd).
2
# $ limactl start ./rke2.yaml
3
# $ limactl shell rke2 sudo 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 rke2 --format 'unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml')
9
# $ kubectl get no
10
# NAME STATUS ROLES AGE VERSION
11
# lima-rke2 Ready control-plane,etcd,master 68s v1.27.3+rke2r1
12
#
13
# For more details of RKE2, please refer to https://docs.rke2.io/
14
15
minimumLimaVersion: 2.0.0
16
17
base: template:_images/ubuntu-lts
18
19
# Mounts are disabled in this template, but can be enabled optionally.
20
mounts: []
21
22
# containerd is managed by rke2, not by Lima, so the values are set to false here.
23
containerd:
24
system: false
25
user: false
26
27
provision:
28
- mode: system
29
script: |
30
#!/bin/sh
31
if [ ! -d /var/lib/rancher/rke2 ]; then
32
curl -sfL https://get.rke2.io | INSTALL_RKE2_CHANNEL=v1.34 sh -
33
fi
34
env | grep "http_proxy\|https_proxy\|no_proxy" > /etc/default/rke2-server
35
sed -i "s/http_proxy/CONTAINERD_HTTP_PROXY/g" /etc/default/rke2-server
36
sed -i "s/https_proxy/CONTAINERD_HTTPS_PROXY/g" /etc/default/rke2-server
37
sed -i "s/no_proxy/CONTAINERD_NO_PROXY/g" /etc/default/rke2-server
38
39
systemctl start rke2-server.service
40
41
probes:
42
- script: |
43
#!/bin/bash
44
set -eux -o pipefail
45
if ! timeout 30s bash -c "until test -f /etc/rancher/rke2/rke2.yaml; do sleep 3; done"; then
46
echo >&2 "rke2 is not running yet"
47
exit 1
48
fi
49
hint: |
50
The rke2 kubeconfig file has not yet been created.
51
Run "limactl shell rke2 sudo journalctl -u rke2-server" to check the log.
52
If that is still empty, check the bottom of the log at "/var/log/cloud-init-output.log".
53
copyToHost:
54
- guest: "/etc/rancher/rke2/rke2.yaml"
55
host: "{{.Dir}}/copied-from-guest/kubeconfig.yaml"
56
deleteOnStop: true
57
message: |
58
To run `kubectl` on the host (assumes kubectl is installed), run the following commands:
59
------
60
export KUBECONFIG="{{.Dir}}/copied-from-guest/kubeconfig.yaml"
61
kubectl ...
62
------
63
64