Giter Club home page Giter Club logo

kube-aliases's Introduction

kube-aliases

This is an oh-my-zsh plugin (or source kube-aliases.plugin.zsh for bash) to make working with kubernetes easier. It provides a bunch of bash aliases and zsh functions. Docs can be found here, which clarifies all aliases.

Usage

There are a few main features of this plugin. First, there are lots of aliases to make working with Kubernetes easier. Second, there are bash functions to help with varies tasks such as switching contexts to use different clusters.

Aliases

To see a full list of aliases, use

khelp usage

In general and when it makes sense, aliases follow the following conventions.

k           # kubectl
kd<r>       # kubectl delete <resource>, e.g. kdp for kubectl delete pods
kds<r>      # kubectl describe <resource>, e.g. kdsp for kubectl describe pod
ke<r>       # kubectl edit <resource>, e.g. kep for kubectl edit pods
kg<r>       # kubectl get <resource>, e.g. kgp for kubectl get pods
kga<r>      # kubectl get --all-namespaces -o wide <resource>, e.g. kgap for kubectl --all-namespaces -o wide get pods
kl          # kubectl logs <podname>
klf         # kubectl logs -f <podname>: i.e. watch logs live

There is also some other useful commands such as the following:

kcon       # create configuration files
kdap       # delete all pods within a namespace
kdrain     # drain a node
kexec      # execute a command in a specified pod,
           # default drops user into a shell
kfind      # use a regular expression to find items across everything except
           # custom resources
kgpns      # Get just pod names in a namespace
kpfind     # Search through pods with regular expressions
krd        # restart a deployment
kstatus    # search across namespaces to find pods statuses

For a more detailed list of aliases, view the docs.

Not everything is currently implemented, but more and more is being added to the list. If something is missing that is desired, feel free to submit a pull request.

Installation

Oh-My-Zsh

git clone https://github.com/Dbz/kube-aliases.git ~/.oh-my-zsh/custom/plugins/kube-aliases
echo "plugins+=(kube-aliases)" >> ~/.zshrc

You can also manually place kube-aliases inside of plugins=(...)

If you have set the ZSH_CUSTOM environment variable in your zshrc, then you should modify the git clone directory to be $ZSH_CUSTOM/plugins/kube-aliases.

Antigen

Add antigen bundle dbz/kube-aliases to your antigen bundles in your .zshrc

Zgen

Add zgen load dbz/kube-aliases to your zgen plugins in your .zshrc

Zinit

Add zinit load Dbz/kube-aliases to your zinit plugins in your .zshrc

Bash

Source kube-aliases.plugin.zsh in your .bashrc.

Aliases for Kubernetes Extensions

kubectx

For easy context and namespace switching there is kubectx. kubectx allows users context switching, and the linked github comes with kubens which allows for simple namespace switching. You can use the following aliases:

alias kctx='kubectx'
alias kns='kubens'

Kubernetes Metrics Server

To get some metrics from nodes or pods, you can use Kubernetes Metrics Server. There are the aliases

alias kt='kubectl top'
alias ktn='kubectl top nodes'
alias ktp='kubectl top pods'

Trouble Shooting

Autocomplete

If there is problems with autocomplete, it may be that kubectl is not on the path when the plugin is loaded. To fix, load plugins after adding kubectl to path.

kube-aliases's People

Contributors

abheyogy avatar adiii717 avatar dbz avatar dragonwang-hub avatar eogpat avatar ericbn avatar frankcash avatar jasons42 avatar kon-angelo avatar patmessina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kube-aliases's Issues

[Issue] Duplicate use of alias

The alias kgs is mapped to both:
kubectl get secrets
kubectl get services

Since kubectl get services is the last alias mapped it wins out.
A new alias should be chosen for kubectl get secrets such as kgse

Add prefix and suffix commands

When generating aliases it would be nice to add a prefix and suffix commands so we can generate things like watch commands/

Suggested Changes

Want to propose some changes, and additions. I will be more than happy to make them myself. Particularly since I have a lot of this done already.

  • Change kc to k
  • Change kcl to k
  • Change n to ns to represent namespaces and use n for nodes
  • Large number of alias additions
  • Add Completion
  • Add help
  • Get all resources across namespaces
  • Find a resources based on name across all namespaces

Let me know what you want, if anything.

khelp res

khelp res is broken.

When it does work, it is just reading from a file and not pulling in resources. This needs to change.

This prevents kfind from working properly when there is new resource types.

Ill fix it.

Generate Aliases

Can now generate aliases. I did previously have stuff there. But I made it a little cleaner.

I would like to clean up what we have. Ill probably rewrite some of the helper functions and remove any that can be generated. Some stuff needs updating as well with Kubernetes being further along.

Create AUR package

I would find it convenient to be able to just install this package. Not sure if its particularly necessary.

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.