File tree Expand file tree Collapse file tree 1 file changed +36
-6
lines changed Expand file tree Collapse file tree 1 file changed +36
-6
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
- if [ -z " $1 " ]; then
2
+
3
+ CONTEXT=" "
4
+ KUBECONFIG=" "
5
+ NODE=" "
6
+ NAMESPACE=" "
7
+ while [ $# -gt 0 ]; do
8
+ key=" $1 "
9
+
10
+ case $key in
11
+ --context)
12
+ CONTEXT=" --context $2 "
13
+ shift
14
+ shift
15
+ ;;
16
+ --kubeconfig)
17
+ KUBECONFIG=" --kubconfig $2 "
18
+ shift
19
+ shift
20
+ ;;
21
+ -n | --namespace)
22
+ NAMESPACE=" --namespace $2 "
23
+ shift
24
+ shift
25
+ ;;
26
+ * )
27
+ NODE=" $1 "
28
+ shift
29
+ ;;
30
+ esac
31
+ done
32
+
33
+ if [ -z " $NODE " ]; then
3
34
echo " Please specify node name"
4
35
exit 1
5
36
fi
6
37
7
- NODE=" $1 "
8
38
IMAGE=" docker.io/library/alpine"
9
39
POD=" nsenter-$( env LC_ALL=C tr -dc a-z0-9 < /dev/urandom | head -c 6) "
10
- NAMESPACE=" "
11
40
12
41
# Check the node
13
- kubectl get node " $NODE " > /dev/null || exit 1
42
+ kubectl get node " $NODE " $CONTEXT $KUBECONFIG > /dev/null || exit 1
14
43
15
- OVERRIDES=" $( cat << EOT
44
+ OVERRIDES=" $(
45
+ cat << EOT
16
46
{
17
47
"spec": {
18
48
"nodeName": "$NODE ",
36
66
) "
37
67
38
68
echo " spawning \" $POD \" on \" $NODE \" "
39
- kubectl run --namespace " $NAMESPACE " -- rm --image " $IMAGE " --overrides=" $OVERRIDES " --generator=run-pod/v1 -ti " $POD "
69
+ kubectl run --rm --image " $IMAGE " --overrides=" $OVERRIDES " --generator=run-pod/v1 -ti " $POD " $CONTEXT $KUBECONFIG $NAMESPACE
You can’t perform that action at this time.
0 commit comments