11# Deploy kubernetes via kubeadm.
22# $ limactl start ./k8s.yaml
3- # $ limactl shell k8s sudo kubectl
3+ # $ limactl shell k8s kubectl
44
55# It can be accessed from the host by exporting the kubeconfig file;
66# the ports are already forwarded automatically by lima:
@@ -126,6 +126,14 @@ provision:
126126 # Replace the server address with localhost, so that it works also from the host
127127 sed -e "/server:/ s|https://.*:\([0-9]*\)$|https://127.0.0.1:\1|" -i $KUBECONFIG
128128 mkdir -p ${HOME:-/root}/.kube && cp -f $KUBECONFIG ${HOME:-/root}/.kube/config
129+ - mode : system
130+ script : |
131+ #!/bin/bash
132+ set -eux -o pipefail
133+ export KUBECONFIG=/etc/kubernetes/admin.conf
134+ mkdir -p ${LIMA_CIDATA_HOME}/.kube
135+ cp -f $KUBECONFIG ${LIMA_CIDATA_HOME}/.kube/config
136+ chown -R ${LIMA_CIDATA_USER} ${LIMA_CIDATA_HOME}/.kube
129137probes :
130138- description : " kubeadm to be installed"
131139 script : |
@@ -151,15 +159,15 @@ probes:
151159 script : |
152160 #!/bin/bash
153161 set -eux -o pipefail
154- if ! timeout 300s bash -c "until sudo kubectl version >/dev/null 2>&1; do sleep 3; done"; then
162+ if ! timeout 300s bash -c "until kubectl version >/dev/null 2>&1; do sleep 3; done"; then
155163 echo >&2 "kubernetes cluster is not up and running yet"
156164 exit 1
157165 fi
158166 - description : " coredns deployment to be running"
159167 script : |
160168 #!/bin/bash
161169 set -eux -o pipefail
162- sudo kubectl wait -n kube-system --timeout=180s --for=condition=available deploy coredns
170+ kubectl wait -n kube-system --timeout=180s --for=condition=available deploy coredns
163171copyToHost :
164172- guest : " /etc/kubernetes/admin.conf"
165173 host : " {{.Dir}}/copied-from-guest/kubeconfig.yaml"
0 commit comments