Skip to content

Commit 6fba254

Browse files
authored
Merge pull request #1650 from Hirozy/master
Add example config to deploy kubernetes via RKE2
2 parents 6a4073f + ff07e5e commit 6fba254

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

examples/experimental/rke2.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
# This example requires Lima v0.7.0 or later.
16+
17+
18+
images:
19+
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
20+
- location: "https://cloud-images.ubuntu.com/releases/22.04/release-20230518/ubuntu-22.04-server-cloudimg-amd64.img"
21+
arch: "x86_64"
22+
digest: "sha256:afb820a9260217fd4c5c5aacfbca74aa7cd2418e830dc64ca2e0642b94aab161"
23+
- location: "https://cloud-images.ubuntu.com/releases/22.04/release-20230518/ubuntu-22.04-server-cloudimg-arm64.img"
24+
arch: "aarch64"
25+
digest: "sha256:b47f8be40b5f91c37874817c3324a72cea1982a5fdad031d9b648c9623c3b4e2"
26+
# Fallback to the latest release image.
27+
# Hint: run `limactl prune` to invalidate the cache
28+
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img"
29+
arch: "x86_64"
30+
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-arm64.img"
31+
arch: "aarch64"
32+
33+
# Mounts are disabled in this example, but can be enabled optionally.
34+
mounts: []
35+
36+
# containerd is managed by rke2, not by Lima, so the values are set to false here.
37+
containerd:
38+
system: false
39+
user: false
40+
41+
provision:
42+
- mode: system
43+
script: |
44+
#!/bin/sh
45+
if [ ! -d /var/lib/rancher/rke2 ]; then
46+
curl -sfL https://get.rke2.io | INSTALL_RKE2_CHANNEL=v1.27 sh -
47+
fi
48+
env | grep "http_proxy\|https_proxy\|no_proxy" > /etc/default/rke2-server
49+
sed -i "s/http_proxy/CONTAINERD_HTTP_PROXY/g" /etc/default/rke2-server
50+
sed -i "s/https_proxy/CONTAINERD_HTTPS_PROXY/g" /etc/default/rke2-server
51+
sed -i "s/no_proxy/CONTAINERD_NO_PROXY/g" /etc/default/rke2-server
52+
53+
systemctl start rke2-server.service
54+
55+
probes:
56+
- script: |
57+
#!/bin/bash
58+
set -eux -o pipefail
59+
if ! timeout 30s bash -c "until test -f /etc/rancher/rke2/rke2.yaml; do sleep 3; done"; then
60+
echo >&2 "rke2 is not running yet"
61+
exit 1
62+
fi
63+
hint: |
64+
The rke2 kubeconfig file has not yet been created.
65+
Run "limactl shell rke2 sudo journalctl -u rke2-server" to check the log.
66+
If that is still empty, check the bottom of the log at "/var/log/cloud-init-output.log".
67+
copyToHost:
68+
- guest: "/etc/rancher/rke2/rke2.yaml"
69+
host: "{{.Dir}}/copied-from-guest/kubeconfig.yaml"
70+
message: |
71+
To run `kubectl` on the host (assumes kubectl is installed), run the following commands:
72+
------
73+
export KUBECONFIG="{{.Dir}}/copied-from-guest/kubeconfig.yaml"
74+
kubectl ...
75+
------

0 commit comments

Comments
 (0)