GithubHelp home page GithubHelp logo

ptzagk / kubectl-aliases Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ahmetb/kubectl-aliases

0.0 0.0 0.0 118 KB

Programmatically generated handy kubectl aliases.

Home Page: https://ahmet.im/blog/kubectl-aliases/

License: Apache License 2.0

Python 100.00%

kubectl-aliases's Introduction

kubectl-aliases

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

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

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

See the full list.

Installation

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

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

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

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

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
    • sl: --show-labels
    • 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.

kubectl-aliases's People

Contributors

ahmetb avatar freele avatar henricook avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.