Skip to content

Commit 03c29a5

Browse files
committed
Add external kubeconfig to the k8s example
Need to also add certificate for 127.0.0.1 Signed-off-by: Anders F Björklund <[email protected]>
1 parent 4902c29 commit 03c29a5

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

examples/k8s.yaml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# Example to use Kubernetes instead of nerdctl
2-
# $ limactl start ./k8s.yaml
3-
# $ limactl shell k8s kubectl
1+
# Deploy kubernetes via kubeadm.
2+
3+
# It can be accessed from the host by exporting the kubeconfig file;
4+
# the ports are already forwarded automatically by lima:
5+
#
6+
# $ export KUBECONFIG=$PWD/kubeconfig.yaml
7+
# $ limactl shell k8s sudo cat /etc/kubernetes/admin.conf | sed -e 's/192.168.5.15/127.0.0.1/' >$KUBECONFIG
8+
# $ kubectl get no
9+
# NAME STATUS ROLES AGE VERSION
10+
# lima-k8s Ready control-plane,master 44s v1.22.3
411

512
# This example requires Lima v0.7.0 or later.
613
images:
@@ -62,7 +69,7 @@ provision:
6269
test -e /etc/kubernetes/admin.conf && exit 0
6370
export KUBECONFIG=/etc/kubernetes/admin.conf
6471
# Initializing your control-plane node
65-
kubeadm init --cri-socket=/run/containerd/containerd.sock --pod-network-cidr=10.244.0.0/16
72+
kubeadm init --cri-socket=/run/containerd/containerd.sock --pod-network-cidr=10.244.0.0/16 --apiserver-cert-extra-sans 127.0.0.1
6673
# Installing a Pod network add-on
6774
kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/v0.14.0/Documentation/kube-flannel.yml
6875
# Control plane node isolation
@@ -72,7 +79,7 @@ provision:
7279
#!/bin/bash
7380
set -eux -o pipefail
7481
mkdir -p $HOME/.kube
75-
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
82+
sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
7683
sudo chown $(id -u):$(id -g) $HOME/.kube/config
7784
probes:
7885
- script: |
@@ -82,14 +89,17 @@ probes:
8289
echo >&2 "kubectl is not installed yet"
8390
exit 1
8491
fi
85-
hint: See "/var/log/cloud-init-output.log". in the guest
92+
hint: |
93+
See "/var/log/cloud-init-output.log". in the guest
8694
- script: |
8795
#!/bin/bash
8896
set -eux -o pipefail
89-
if ! timeout 300s bash -c "until test -e /etc/kubernetes/admin.conf >/dev/null 2>&1; do sleep 3; done"; then
90-
echo >&2 "/etc/kubernetes/admin.conf is not there yet"
97+
if ! timeout 300s bash -c "until test -f /etc/kubernetes/admin.conf; do sleep 3; done"; then
98+
echo >&2 "k8s is not running yet"
9199
exit 1
92100
fi
101+
hint: |
102+
The k8s kubeconfig file has not yet been created.
93103
- script: |
94104
#!/bin/bash
95105
set -eux -o pipefail

0 commit comments

Comments
 (0)