|
10 | 10 | # NAME STATUS ROLES AGE VERSION |
11 | 11 | # lima-k8s Ready control-plane,master 44s v1.22.3 |
12 | 12 |
|
| 13 | +# A multi-node cluster can be created by starting multiple instances of this template |
| 14 | +# connected via the `lima:user-v2` network. |
| 15 | +# |
| 16 | +# $ limactl start --name k8s-0 --network lima:user-v2 template:k8s |
| 17 | +# $ limactl shell k8s-0 sudo kubeadm token create --print-join-command |
| 18 | +# (The join command printed here) |
| 19 | +# |
| 20 | +# $ limactl start --name k8s-1 --network lima:user-v2 template:k8s |
| 21 | +# $ limactl shell k8s-1 sudo kubeadm reset --force |
| 22 | +# $ limactl shell k8s-1 sudo <JOIN_COMMAND_FROM_ABOVE> |
| 23 | + |
13 | 24 | minimumLimaVersion: 2.0.0 |
14 | 25 |
|
15 | 26 | base: template://_images/ubuntu-lts |
@@ -108,9 +119,12 @@ provision: |
108 | 119 | kubectl apply -f https://github.com/flannel-io/flannel/releases/download/v0.26.7/kube-flannel.yml |
109 | 120 | # Control plane node isolation |
110 | 121 | kubectl taint nodes --all node-role.kubernetes.io/control-plane- |
111 | | - # Replace the server address with localhost, so that it works also from the host |
112 | | - sed -e "/server:/ s|https://.*:\([0-9]*\)$|https://127.0.0.1:\1|" -i $KUBECONFIG |
113 | | - mkdir -p ${HOME:-/root}/.kube && cp -f $KUBECONFIG ${HOME:-/root}/.kube/config |
| 122 | + # Symlink the kubeconfig file to the default location for kubectl |
| 123 | + mkdir -p /root/.kube && ln -sf $KUBECONFIG /root/.kube/config |
| 124 | + # Replace the server address with localhost, so that it works from the host. |
| 125 | + # The original kubeconfig is kept unmodified, so that `kubeadm token create --print-join-command` |
| 126 | + # can still print the reachable address. |
| 127 | + sed -e "/server:/ s|https://.*:\([0-9]*\)$|https://127.0.0.1:\1|" $KUBECONFIG >/root/.kube/config.localhost |
114 | 128 | - mode: system |
115 | 129 | script: | |
116 | 130 | #!/bin/bash |
@@ -162,7 +176,7 @@ probes: |
162 | 176 | set -eux -o pipefail |
163 | 177 | kubectl wait -n kube-system --timeout=180s --for=condition=available deploy coredns |
164 | 178 | copyToHost: |
165 | | -- guest: "/etc/kubernetes/admin.conf" |
| 179 | +- guest: "/root/.kube/config.localhost" |
166 | 180 | host: "{{.Dir}}/copied-from-guest/kubeconfig.yaml" |
167 | 181 | deleteOnStop: true |
168 | 182 | message: | |
|
0 commit comments