Skip to content

Commit 351c4ae

Browse files
authored
Merge pull request #513 from afbjorklund/sudo-kubectl
Running kubectl requires using sudo kubectl
2 parents 1f11800 + a5427dd commit 351c4ae

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

examples/k3s.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Deploy kubernetes via k3s (which installs a bundled containerd).
2+
# $ limactl start ./k3s.yaml
3+
# $ limactl shell k3s sudo kubectl
24
#
35
# It can be accessed from the host by exporting the kubeconfig file;
46
# the ports are already forwarded automatically by lima:

examples/k8s.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Deploy kubernetes via kubeadm.
2+
# $ limactl start ./k8s.yaml
3+
# $ limactl shell k8s sudo kubectl
24

35
# It can be accessed from the host by exporting the kubeconfig file;
46
# the ports are already forwarded automatically by lima:
57
#
68
# $ 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
9+
# $ limactl shell k8s sudo cat /etc/kubernetes/admin.conf >$KUBECONFIG
810
# $ kubectl get no
911
# NAME STATUS ROLES AGE VERSION
1012
# lima-k8s Ready control-plane,master 44s v1.22.3
@@ -73,13 +75,8 @@ provision:
7375
kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/v0.14.0/Documentation/kube-flannel.yml
7476
# Control plane node isolation
7577
kubectl taint nodes --all node-role.kubernetes.io/master-
76-
- mode: user
77-
script: |
78-
#!/bin/bash
79-
set -eux -o pipefail
80-
mkdir -p $HOME/.kube
81-
sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
82-
sudo chown $(id -u):$(id -g) $HOME/.kube/config
78+
sed -e "s/${LIMA_CIDATA_SLIRP_IP_ADDRESS:-192.168.5.15}/127.0.0.1/" -i $KUBECONFIG
79+
mkdir -p ${HOME:-/root}/.kube && cp -f $KUBECONFIG ${HOME:-/root}/.kube/config
8380
probes:
8481
- script: |
8582
#!/bin/bash

0 commit comments

Comments
 (0)