-
Notifications
You must be signed in to change notification settings - Fork 0
/
kube
executable file
·50 lines (39 loc) · 869 Bytes
/
kube
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
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
CLUSTERS=
SELECTED_CLUSTER=
SELECTED_ENV=
SELECTED_POD=
select_cluster() {
CLUSTERS="Acceptation\nProduction"
SELECTED_CLUSTER=$(echo $CLUSTERS | fzf)
case $SELECTED_CLUSTER in
"Acceptation")
aws eks update-kubeconfig --name oaky-staging-2
;;
"Production")
aws eks --region eu-central-1 update-kubeconfig --name oaky-prod
;;
*)
exit 0
esac
}
select_env() {
if [ $SELECTED_CLUSTER = "Acceptation" ]; then
SELECTED_ENV=$(echo "accp-1\naccp-2\naccp-3\naccp-4\naccp-5" | fzf)
else
SELECTED_ENV="oaky-prod"
fi
if [ -z "$SELECTED_ENV" ]; then
exit 0
fi
}
select_pod() {
SELECTED_POD=$(kubectl get po -n $SELECTED_ENV --no-headers -o custom-columns=":metadata.name" | fzf)
if [ -z "$SELECTED_POD" ]; then
exit 0
fi
kubectl exec -it $SELECTED_POD -n $SELECTED_ENV -- /bin/sh
}
select_cluster
select_env
select_pod