Skip to content

Instantly share code, notes, and snippets.

@barthy1
Created February 19, 2018 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barthy1/3b24604e56a0e919a3f2a42caa470706 to your computer and use it in GitHub Desktop.
Save barthy1/3b24604e56a0e919a3f2a42caa470706 to your computer and use it in GitHub Desktop.
#!/bin/bash
execc()
{
kubectl exec --namespace=$1 $2 -i -t -- bash -il
}
desc()
{
kubectl describe po --namespace=$1 $2
}
logs()
{
kubectl logs --namespace=$1 $2
}
all()
{
kubectl get pods --all-namespaces
}
alls()
{
kubectl get svc --all-namespaces
}
del()
{
kubectl delete pod --namespace=$1 $2
}
command=$1
source=$2
set -- $(kubectl get pods --all-namespaces | grep $2 | head -1|awk '{print $1,$2}')
if [ "$command" == "logs" ]; then
logs $1 $2
fi
if [ "$command" == "exec" ]; then
execc $1 $2
fi
if [ "$command" == "desc" ]; then
desc $1 $2
fi
if [ "$command" == "all" ]; then
all
fi
if [ "$command" == "alls" ]; then
alls
fi
if [ "$command" == "del" ]; then
del $1 $2
fi
if [ "$command" == "delall" ]; then
kubectl delete pod -n $1 $(kubectl get pods --all-namespaces | grep $source | awk '{print $2}' ORS=' ')
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment