File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ binaries: clean \
46
46
_output/bin/apptainer.lima \
47
47
_output/bin/docker.lima \
48
48
_output/bin/podman.lima \
49
+ _output/bin/kubectl.lima \
49
50
_output/share/lima/lima-guestagent.Linux-x86_64 \
50
51
_output/share/lima/lima-guestagent.Linux-aarch64 \
51
52
_output/share/lima/lima-guestagent.Linux-riscv64
@@ -87,6 +88,10 @@ _output/bin/podman.lima: ./cmd/podman.lima
87
88
@mkdir -p _output/bin
88
89
cp -a $^ $@
89
90
91
+ _output/bin/kubectl.lima : ./cmd/kubectl.lima
92
+ @mkdir -p _output/bin
93
+ cp -a $^ $@
94
+
90
95
.PHONY : _output/bin/limactl$(exe )
91
96
_output/bin/limactl$(exe ) :
92
97
# The hostagent must be compiled with CGO_ENABLED=1 so that net.LookupIP() in the DNS server
@@ -132,6 +137,7 @@ uninstall:
132
137
" $( DEST) /bin/apptainer.lima" \
133
138
" $( DEST) /bin/docker.lima" \
134
139
" $( DEST) /bin/podman.lima" \
140
+ " $( DEST) /bin/kubectl.lima" \
135
141
" $( DEST) /share/lima" " $( DEST) /share/doc/lima"
136
142
if [ " $$ (readlink " $( DEST) /bin/nerdctl" )" = " nerdctl.lima" ]; then rm " $( DEST) /bin/nerdctl" ; fi
137
143
if [ " $$ (readlink " $( DEST) /bin/apptainer" )" = " apptainer.lima" ]; then rm " $( DEST) /bin/apptainer" ; fi
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ set -eu
3
+ : " ${LIMA_INSTANCE:= } "
4
+ : " ${KUBECTL:= kubectl} "
5
+
6
+ if [ -z " $LIMA_INSTANCE " ]; then
7
+ if [ " $( limactl ls -f ' {{.Status}}' k3s 2> /dev/null) " = " Running" ]; then
8
+ LIMA_INSTANCE=k3s
9
+ elif [ " $( limactl ls -f ' {{.Status}}' k8s 2> /dev/null) " = " Running" ]; then
10
+ LIMA_INSTANCE=k8s
11
+ else
12
+ echo " No k3s or k8s running instances found. Either start one with" >&2
13
+ echo " limactl start --name=k3s template://k3s" >&2
14
+ echo " limactl start --name=k8s template://k8s" >&2
15
+ echo " or set LIMA_INSTANCE to the name of your Kubernetes instance" >&2
16
+ exit 1
17
+ fi
18
+ elif [ " $( limactl ls -q " $LIMA_INSTANCE " 2> /dev/null) " != " $LIMA_INSTANCE " ]; then
19
+ echo " instance \" $LIMA_INSTANCE \" does not exist, run \` limactl start --name=$LIMA_INSTANCE \` to create a new instance" >&2
20
+ exit 1
21
+ fi
22
+ KUBECTL=$( command -v " $KUBECTL " || true)
23
+ if [ -n " $KUBECTL " ]; then
24
+ KUBECONFIG=$( limactl list " $LIMA_INSTANCE " --format ' {{.Dir}}/copied-from-guest/kubeconfig.yaml' )
25
+ export KUBECONFIG
26
+ exec " $KUBECTL " " $@ "
27
+ else
28
+ export LIMA_INSTANCE
29
+ exec lima sudo kubectl " $@ "
30
+ fi
You can’t perform that action at this time.
0 commit comments