kubernetes dashboard shell
#!/bin/sh
PORT_PROG_KILL="kill $(lsof -i:8001 | grep kubectl | cut -c 9-16 | uniq);"
PRAM=$1
if [ "$PRAM" = "" ]; then
echo "パラメータが何も入力されませんでした。"
exit -1
elif [ "$PRAM" = "c" ]; then
CMD="kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.8.1/src/deploy/recommended/kubernetes-dashboard.yaml --record"
elif [ "$PRAM" = "d" ]; then
CMD="kubectl delete -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.8.1/src/deploy/recommended/kubernetes-dashboard.yaml; $PORT_PROG_KILL"
elif [ "$PRAM" = "a" ]; then
CMD="kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.8.1/src/deploy/recommended/kubernetes-dashboard.yaml"
elif [ "$PRAM" = "g" ]; then
CMD="kubectl get deployments,replicasets,pods,service --all-namespaces -o wide --selector=k8s-app=kubernetes-dashboard"
elif [ "$PRAM" = "h" ]; then
CMD="kubectl rollout history deployment kubernetes-dashboard"
elif [ "$PRAM" = "r" ]; then
CMD="kubectl rollout undo deployment kubernetes-dashboard"
elif [ "$PRAM" = "p" ]; then
CMD="$PORT_PROG_KILL kubectl proxy &"
elif [ "$PRAM" = "o" ]; then
CMD="open http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/"
else
echo "不正なパラメータ: $PRAM"
exit -1
fi
echo $CMD
eval $CMD
exit 0