Gangmax Blog

Alias for Kubernetes Commands

Recently I use the “kubectl” command a lot. To save some time, I use alias commands like below in my “~/.zshrc” file.

1
2
3
4
5
6
7
# 1. Add alias for the specific name space.
alias kc='kubectl -n namespace1'
# 2. List pods for the specific name space.
alias cl='kubectl -n namespace1 get pods'
# 3. Get into the target pod bash shell.
# From: https://stackoverflow.com/a/35542534/3115617
alias ce='_ce() { kubectl -n namespace1 exec -it "$1" bash; }; _ce'

Comments