Skip to content

Commit 0117427

Browse files
committed
Fix install
1 parent e079a30 commit 0117427

File tree

5 files changed

+66
-13
lines changed

5 files changed

+66
-13
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ Context number to switch:
4444

4545
Force delete all pods in a namespace.
4646

47-
#### kexecroot
47+
#### kexec
4848

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`.
5050

5151
#### kndefault
5252

@@ -69,6 +69,18 @@ Show the contents of secrets with base64 decode.
6969

7070
## Utilities
7171

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+
7284
#### outputlog
7385

7486
Easy format for log in your scripts.

devops_command.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ killgrep
2222
kall
2323
kcontext
2424
kdelforce
25-
kexecroot
25+
kexec
2626
kndefault
2727
kscale
2828
ksecret
@@ -33,18 +33,30 @@ trycommand
3333
"
3434

3535
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+
3643
echo "[INFO] Copy to /usr/bin/"
3744
sudo cp */* /usr/bin/
45+
3846
elif [ "$OPTION" == "--uninstall" ]; then
47+
3948
for script in $list_scripts;
4049
do
4150
if [ -f "/usr/bin/$script" ]; then
4251
echo "[INFO] Remove /usr/bin/$script"
4352
sudo rm -f /usr/bin/$script
4453
fi
4554
done
55+
4656
else
57+
4758
echo "[ERROR] invalid input"
59+
4860
fi
4961

5062

kubernetes/kexec

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+

kubernetes/kexecronjob

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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}

kubernetes/kexecroot

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)