Skip to content
Snippets Groups Projects
Select Git revision
  • 3a02da76575c3cdc2169f5af6e87e73fec04b9e6
  • main default protected
2 results

kubectl-aliases

user avatar
cclauss authored
from __future__ import print_function for Python 3
* Also, define xrange() for Python 3 because it was removed in favor of range()
3a02da76
History

kubectl-aliases

This repository contains a script to generate hundreds of convenient kubectl aliases programmatically.

You can directly download the .kubectl_aliases file and save it in your $HOME directory, then edit your .bashrc/.zshrc file with:

source ~/.kubectl_aliases

Examples

Some of the 600 generated aliases are:

alias k='kubectl'
alias kg='kubectl get'
alias kgpo='kubectl get pod'

alias ksysgpo='kubectl --namespace=kube-system get pod'

alias krm='kubectl delete'
alias krmf='kubectl delete -f'
alias krming='kubectl delete ingress'
alias krmingl='kubectl delete ingress -l'
alias krmingall='kubectl delete ingress --all-namespaces'

alias kgsvcoyaml='kubectl get service -o=yaml'
alias kgsvcwn='kubectl get service --watch --namespace'

alias kgwf='kubectl get --watch -f'
...

See the full list.

Syntax explanation

  • k=kubectl
    • sys=--namespace kube-system
  • commands:
    • g=get
    • d=describe
    • rm=delete
    • a:apply -f
    • ex: exec -i -t
    • lo: logs -f
  • resources:
    • po=pod, dep=deployment, ing=ingress, svc=service, cm=configmap, sec=secret, ns=namespace, no=node
  • flags:
    • output format: oyaml, ojson, owide
    • all: --all or --all-namespaces depending on the command
    • w=-w/--watch
  • value flags (should be at the end):
    • f=-f/--filename
    • l=-l/--selector

FAQ

Does this not slow down my shell start up? Sourcing the file that contains ~500 aliases takes about 30-45 milliseconds in my shell (zsh). I don't think it's a big deal for me. Measure it with echo $(($(date +%s%N)/1000000)) command yourself in your .bashrc/.zshrc.

Authors


This is not an official Google project.

Stargazers over time

Stargazers over time