If you frequently work with the Docker/Kubernetes (or OpenShift) stack, you may find the following shortcut commands handy:
# aliases for kubectl commands # for operations on kube-system namespace, e.g. kubesys get pods == kubectl get pods --namespace=kube-system alias kubesys='kubectl --namespace=kube-system' # resource getters alias pods='kubectl get pods' alias logs='kubectl logs' alias get='kubectl get' alias desc='kubectl describe' alias svc='kubectl get svc' alias rc='kubectl get rc' alias rs='kubectl get rs' alias dep='kubectl get deployment' alias nodes='kubectl get nodes' # edit/delete ops alias del='kubectl delete' alias deldep='kubectl delete deployment' alias editdep='kubectl edit deployment' alias edit='kubectl edit' # open a shell to a running pod alias kssh='kubectl exec -it' # aliases for Docker control/management commands # list Docker images alias dimg='docker images' # clean dangling images (https://github.com/docker/docker/issues/8926) alias dclean='docker rmi -f `docker images -f "dangling=true" -q`' # start a new container with a shell, and discard it after exit from the shell alias drun='docker run --rm -it --entrypoint=sh' # service control for an all-in-one K8s node (master + minion on same machine) # starting the full stack alias kreboot='for i in etcd flanneld docker kube-apiserver kube-controller-manager kube-scheduler kube-proxy kubelet; do sudo service $i restart; service $i status; done' # stopping the full stack alias kdown='for i in etcd flanneld docker kube-apiserver kube-controller-manager kube-scheduler kube-proxy kubelet; do sudo service $i stop; done' # checking status of all required services (any unavailability will be displayed in red) alias kstat='for i in etcd flanneld docker kube-apiserver kube-controller-manager kube-scheduler kube-proxy kubelet; do service $i status | grep -B2 "Active:" | grep -v "Loaded:" | grep -E "inactive|exited|$"; done'
No comments:
Post a Comment
Thanks for commenting! But if you sound spammy, I will hunt you down, kill you, and dance on your grave!