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