Below kubectl shortcut will same some time in typing.
alias a='alias'
alias k='kubectl '
alias ka='kubectl apply -f '
alias kg='kubectl get '
alias kgn='kubectl get nodes'
alias kgnw='kubectl get nodes -o wide'
alias kgnl='kubectl get nodes --show-labels'
alias kgp='kubectl get pods'
alias kgs='kubectl get svc'
alias kgd='kubectl get deployments'
alias kcf='kubectl create -f '
alias kd='kubectl delete '
alias kdf='kubectl delete -f '
alias kaf='kubectl apply -f '
alias kgpa='kubectl get pods --all-namespaces'
Then you can use kgn
it will display node status.
# kgn
NAME STATUS ROLES AGE VERSION
k8sm-01 Ready master 2d v1.8.0
k8sn-01 Ready <none> 2d v1.8.0
k8sn-02 Ready <none> 2d v1.8.0
Login to tools pod Script
#!/bin/bash
set -xv
P="$1"
[ -z "$P" ] && P=$(kubectl get pods |grep net-tools |cut -f1 -d' ')
kubectl exec "$P" -it -- bash -il
Confgure System wide alias
#!/bin/bash
if [ ! -f /etc/profile.d/kubectl.sh ] ; then
{
curl -k https://raw.githubusercontent.com/ahmetb/kubectl-aliases/master/.kubectl_aliases
cat<<-EOF
alias a='alias'
alias k='kubectl '
alias ka='kubectl apply -f '
alias kg='kubectl get '
alias kgn='kubectl get nodes'
alias kgnw='kubectl get nodes -o wide'
alias kgnl='kubectl get nodes --show-labels'
alias kgp='kubectl get pods'
alias kgs='kubectl get svc'
alias kgd='kubectl get deployments'
alias kcf='kubectl create -f '
alias kd='kubectl delete '
alias kdf='kubectl delete -f '
alias kaf='kubectl apply -f '
EOF
} > /etc/profile.d/kubectl.sh
fi
cd /usr/local/bin
for i in kubectx kubens utils.bash
do
[ -f $i ] || ( curl -Ok https://raw.githubusercontent.com/ahmetb/kubectx/master/$i && chmod +x $i )
done