-
Notifications
You must be signed in to change notification settings - Fork 0
/
containerSSH.sh
40 lines (40 loc) · 1.19 KB
/
containerSSH.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function sshc() {
PS3="Select a namespace: "
select ns in $(kubectl get namespace | grep -v NAME | awk '{print $1}')
do
echo "Selected: $ns"
echo "================================================================"
PS3="Select a pod: "
select pod in $(kubectl get pods -n $ns| grep -v NAME | awk '{print $1}')
do
echo "Selected: $pod"
echo "================================================================"
PS3="Select container: "
select c in $(kubectl get pods $pod -n $ns -o jsonpath='{.spec.containers[*].name}')
do
echo "Selected: $c"
echo "================================================================"
PS3="Select one of the option: "
select op in tail-logs shell attach
do
case $op in
tail-logs )
kubectl logs $pod $c -n $ns --follow
;;
attach )
kubectl attach -it -n $ns $pod -c $c
;;
shell )
kubectl exec -it -n $ns $pod -c $c -- sh -c "(bash || ash || sh)"
;;
esac
break
done
break
done
break
done
break
done
return $?
}