-
Notifications
You must be signed in to change notification settings - Fork 0
/
kubectl.sh
59 lines (56 loc) · 1.85 KB
/
kubectl.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# This is this kubectl shortener
kubectlShort(){
#set -x
local_arg="$1"
[ -z "$local_arg" ] || shift
if [ "$local_arg" == "ans" ]; then
K_NAMESPACE_ARG="--all-namespaces"
local_arg="$1"
shift
fi
if [ -n "${K_NS:-}" ]; then
if [ "$K_NS" == "all" ]; then
K_NAMESPACE_ARG="--all-namespaces"
else
K_NAMESPACE_ARG="--namespace \"$K_NS\""
fi
fi
case "$local_arg" in
del) kubectl delete $K_NAMESPACE_ARG "$@";;
exp*) kubectl explain $K_NAMESPACE_ARG "$@";;
c|cr|cre*) kubectl create $K_NAMESPACE_ARG "$@";;
co|con|conf) kubectl config $K_NAMESPACE_ARG "$@";;
apiv|api-v*) kubectl api-versions $K_NAMESPACE_ARG "$@";;
apir|api-r*) kubectl api-resources $K_NAMESPACE_ARG "$@";;
a|ap*) kubectl apply $K_NAMESPACE_ARG "$@";;
r|ru) kubectl run $K_NAMESPACE_ARG "$@";;
s|se) kubectl set $K_NAMESPACE_ARG "$@";;
g|ge) kubectl get $K_NAMESPACE_ARG "$@";;
d|de|des|desc) kubectl describe $K_NAMESPACE_ARG "$@";;
e|ed|edi) kubectl edit $K_NAMESPACE_ARG "$@";;
l|lo|log) kubectl logs $K_NAMESPACE_ARG "$@";;
ex|exe) kubectl exec $K_NAMESPACE_ARG "$@";;
h|help) echo "the (k)ubectl function"
echo " k a(pply)"
echo " k c(reate)"
echo " k e(dit)"
echo " k g(get)"
echo " k d(escribe)"
echo " k s(et)"
echo " k del(ete)"
echo " k l(ogs)"
echo " k ex(ec)"
echo " k r(un)"
echo " k api-v(ersion)"
echo " k api-r(esources)"
echo " k co(nfig)"
;;
*) kubectl $K_NAMESPACE_ARG "$local_arg" "$@";;
esac
#set +x
}
set_kubeconfig_namespace(){
local_namespace="$1"
context=$(kubectl config current-context)
}
# MIT License Copyright (c) 2019 Matt Hoyle