File tree Expand file tree Collapse file tree 5 files changed +66
-13
lines changed Expand file tree Collapse file tree 5 files changed +66
-13
lines changed Original file line number Diff line number Diff line change @@ -44,9 +44,9 @@ Context number to switch:
44
44
45
45
Force delete all pods in a namespace.
46
46
47
- #### kexecroot
47
+ #### kexec
48
48
49
- Force connect to a pod with root user.
49
+ Force connect to a pod with root user or connect to node pool with option ` --ssh ` .
50
50
51
51
#### kndefault
52
52
@@ -69,6 +69,18 @@ Show the contents of secrets with base64 decode.
69
69
70
70
## Utilities
71
71
72
+ #### killgrep
73
+
74
+ Kill with name not PID.
75
+
76
+ ```
77
+ $ ps -aux | grep terminator
78
+ ubuntu 8443 0.0 0.4 434654 238349 ? Sl 01:30 0:04 /usr/bin/python3 /usr/bin/terminator
79
+ ubuntu 34555 0.0 0.0 0349 993944 pts/1 S+ 11:33 0:00 grep --color=auto terminator
80
+
81
+ $ killgrep terminator
82
+ ```
83
+
72
84
#### outputlog
73
85
74
86
Easy format for log in your scripts.
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ killgrep
22
22
kall
23
23
kcontext
24
24
kdelforce
25
- kexecroot
25
+ kexec
26
26
kndefault
27
27
kscale
28
28
ksecret
@@ -33,18 +33,30 @@ trycommand
33
33
"
34
34
35
35
if [ " $OPTION " == " --install" ]; then
36
+
37
+ echo " [INFO] Dependency installation"
38
+ # Kubernetes
39
+ sudo apt-get install jq kubectl
40
+ # Pomodoro
41
+ sudo apt-get install pulseaudio-utils soxt
42
+
36
43
echo " [INFO] Copy to /usr/bin/"
37
44
sudo cp * /* /usr/bin/
45
+
38
46
elif [ " $OPTION " == " --uninstall" ]; then
47
+
39
48
for script in $list_scripts ;
40
49
do
41
50
if [ -f " /usr/bin/$script " ]; then
42
51
echo " [INFO] Remove /usr/bin/$script "
43
52
sudo rm -f /usr/bin/$script
44
53
fi
45
54
done
55
+
46
56
else
57
+
47
58
echo " [ERROR] invalid input"
59
+
48
60
fi
49
61
50
62
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # kexec
3
+ # By Tedezed
4
+
5
+ NAME_POD=$1
6
+ NAMESPACE=$2
7
+ OPTION=$3
8
+
9
+ set -e
10
+
11
+ if [ -z " $NAME_POD " ] || [ -z " $NAMESPACE " ] ; then
12
+ echo " [ERROR] invalid input: kexec POD_NAME NAMESPACE [OPTION]"
13
+ exit 1
14
+ fi
15
+
16
+ NODE_POD=$( kubectl get pod $NAME_POD -n $NAMESPACE -o json | jq ' .spec.nodeName' | tr -d ' "' )
17
+ NODE_ZONE=$( kubectl get node $NODE_POD -o json | jq ' .metadata.labels."topology.kubernetes.io/zone"' | tr -d ' "' )
18
+ ID_POD_DOCKER=$( gcloud compute ssh $USER @$NODE_POD --zone=$NODE_ZONE -- docker ps | grep " $NAME_POD " | grep " $NAMESPACE " | grep -v " POD" | awk ' {print $1}' )
19
+
20
+ if [ " $OPTION " == " --ssh" ]; then
21
+ gcloud compute ssh $USER @$NODE_POD --zone=$NODE_ZONE
22
+ else
23
+ gcloud compute ssh $USER @$NODE_POD --zone=$NODE_ZONE -- docker exec -it -u 0 $ID_POD_DOCKER /bin/sh
24
+ fi
25
+
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # kexecronjob
3
+ # By Tedezed
4
+
5
+ CRONJOB_NAME=$1
6
+ CRONJOB_NAMESPACE=$2
7
+
8
+ if [ -z " $CRONJOB_NAME " ] || [ -z " $CRONJOB_NAMESPACE " ]; then
9
+ echo " [ERROR] invalid input, example:"
10
+ echo " kexecronjob [CRONJOB] [NAMESPACE]"
11
+ exit 1
12
+ fi
13
+
14
+ kubectl create job --from=cronjob/${CRONJOB_NAME} ${CRONJOB_NAME} -$RANDOM -n ${CRONJOB_NAMESPACE}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments