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
4
11
5
12
# This example requires Lima v0.7.0 or later.
6
13
images :
@@ -62,7 +69,7 @@ provision:
62
69
test -e /etc/kubernetes/admin.conf && exit 0
63
70
export KUBECONFIG=/etc/kubernetes/admin.conf
64
71
# 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
66
73
# Installing a Pod network add-on
67
74
kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/v0.14.0/Documentation/kube-flannel.yml
68
75
# Control plane node isolation
@@ -72,7 +79,7 @@ provision:
72
79
#!/bin/bash
73
80
set -eux -o pipefail
74
81
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
76
83
sudo chown $(id -u):$(id -g) $HOME/.kube/config
77
84
probes :
78
85
- script : |
@@ -82,14 +89,17 @@ probes:
82
89
echo >&2 "kubectl is not installed yet"
83
90
exit 1
84
91
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
86
94
- script : |
87
95
#!/bin/bash
88
96
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"
91
99
exit 1
92
100
fi
101
+ hint: |
102
+ The k8s kubeconfig file has not yet been created.
93
103
- script : |
94
104
#!/bin/bash
95
105
set -eux -o pipefail
0 commit comments