All Projects → ahmetb → Kubectl Aliases

ahmetb / Kubectl Aliases

Licence: other
Programmatically generated handy kubectl aliases.

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Kubectl Aliases

Kuberos
An OIDC authentication helper for Kubernetes' kubectl
Stars: ✭ 109 (-94.93%)
Mutual labels:  kubectl
Laravel Docker K8s
Running Laravel project using Docker and Deploying using Kubernetes
Stars: ✭ 127 (-94.1%)
Mutual labels:  kubectl
Devtron
Software Delivery Workflow For Kubernetes
Stars: ✭ 130 (-93.96%)
Mutual labels:  kubectl
Kubectl Sheetcheat
The Definitive Kubectl Sheetcheat. ⭐ Give it a star if you like it. Work (always) in progress !
Stars: ✭ 119 (-94.47%)
Mutual labels:  kubectl
Kk
A kubernetes/kubectl terminal client
Stars: ✭ 124 (-94.24%)
Mutual labels:  kubectl
Kubectl
A Github action for kubectl, the Kubernetes CLI
Stars: ✭ 128 (-94.05%)
Mutual labels:  kubectl
Libvirt K8s Provisioner
Automate your k8s installation
Stars: ✭ 106 (-95.07%)
Mutual labels:  kubectl
Kubectl Tree
kubectl plugin to browse Kubernetes object hierarchies as a tree 🎄 (star the repo if you are using)
Stars: ✭ 1,962 (-8.83%)
Mutual labels:  kubectl
Littletools
A set of short commands used to make the input of some commands simple.
Stars: ✭ 126 (-94.14%)
Mutual labels:  kubectl
Kui
A hybrid command-line/UI development experience for cloud-native development
Stars: ✭ 2,052 (-4.65%)
Mutual labels:  kubectl
Kube Prompt
An interactive kubernetes client featuring auto-complete.
Stars: ✭ 1,614 (-25%)
Mutual labels:  kubectl
Kubectl Reap
kubectl plugin that deletes unused Kubernetes resources
Stars: ✭ 123 (-94.28%)
Mutual labels:  kubectl
Kubernetes Reflector
Custom Kubernetes controller that can be used to replicate secrets, configmaps and certificates.
Stars: ✭ 129 (-94.01%)
Mutual labels:  kubectl
Vim Kubernetes
vim-kubernetes
Stars: ✭ 112 (-94.8%)
Mutual labels:  kubectl
K8sh
A simple, easily extensible shell for navigating your kubernetes clusters
Stars: ✭ 136 (-93.68%)
Mutual labels:  kubectl
Kubectx
Faster way to switch between clusters and namespaces in kubectl
Stars: ✭ 11,922 (+454%)
Mutual labels:  kubectl
Ckube
A cli to simplify working with kubectl for some common workflows
Stars: ✭ 127 (-94.1%)
Mutual labels:  kubectl
Binenv
One binary to rule them all. Manage all those pesky binaries (kubectl, helm, terraform, ...) easily.
Stars: ✭ 148 (-93.12%)
Mutual labels:  kubectl
Kubexp
Stars: ✭ 138 (-93.59%)
Mutual labels:  kubectl
Kubectl View Utilization
kubectl plugin to show cluster CPU and Memory requests utilization
Stars: ✭ 128 (-94.05%)
Mutual labels:  kubectl

kubectl-aliases

This repository contains a script to generate hundreds of convenient shell aliases for kubectl, so you no longer need to spell out every single command and --flag over and over again.

An example shell alias created from command/flags permutation looks like:

alias ksysgdepwslowidel='kubectl --namespace=kube-system get deployment --watch --show-labels -o=wide -l'

Confused? Read on.

Examples

Some of the 800 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='watch kubectl get service --namespace'
alias kgsvcslwn='watch kubectl get service --show-labels --namespace'

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

See the full list.

Installation

You can directly download the .kubectl_aliases file for bash/zsh or the .kubectl_aliases.fish file for fish and save it to your $HOME directory.

Bash/Zsh

Add the following to your .bashrc/.zshrc file:

[ -f ~/.kubectl_aliases ] && source ~/.kubectl_aliases

Recommendation: If you want to use GNU watch command instead of kubectl [...] --watch, run it like this:

[ -f ~/.kubectl_aliases ] && source \
   <(cat ~/.kubectl_aliases | sed -r 's/(kubectl.*) --watch/watch \1/g')

Print the full command before running it: Add this to your .bashrc or .zshrc file:

function kubectl() { echo "+ kubectl $@">&2; command kubectl $@; }

Fish

Add the following to your ~/.config/fish/config.fish file:

test -f ~/.kubectl_aliases.fish && source ~/.kubectl_aliases.fish

Recommendation: If you want to use GNU watch command instead of kubectl [...] --watch, run it like this:

test -f ~/.kubectl_aliases.fish && source \
     (cat ~/.kubectl_aliases.fish | sed -r 's/(kubectl.*) --watch/watch \1/g' | psub)

Syntax explanation

  • k=kubectl
    • sys=--namespace kube-system
  • commands:
    • g=get
    • d=describe
    • rm=delete
    • a:apply -f
    • ak:apply -k
    • k:kustomize
    • ex: exec -i -t
    • lo: logs -f
  • resources:
    • po=pod, dep=deployment, ing=ingress, svc=service, cm=configmap, sec=secret, ns=namespace, no=node ** ⚠️ Please do not suggest new resources here, instead fork the project.
  • flags:
    • output format: oyaml, ojson, owide
    • all: --all or --all-namespaces depending on the command
    • sl: --show-labels
    • w=-w/--watch
  • value flags (should be at the end):
    • n=-n/--namespace
    • f=-f/--filename
    • l=-l/--selector

Running the script

The script has only one optional argument, the shell to which the aliases will be generated. If not given, it assumes bash. Ex:

# Generate aliases for bash/zsh
python generate_aliases.py > .kubectl_aliases

# Generate abbr for fish
python generate_aliases.py fish > .kubectl_aliases.fish

FAQ

  • Doesn't this 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.

  • Can I add more Kubernetes resource types to this? Please consider forking this repo and adding the resource types you want. Not all resource types are used by everyone, and adding more resource types slows down shell initialization see above).

  • Where can I find PowerShell aliases for kubectl? There’s a fork of this here.

Authors


This is not an official Google project.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].