Home > database >  kubectl short alias for deployment
kubectl short alias for deployment

Time:08-15

Is there any shorter alias on the kubectl/oc for deployments? In OpenShift you have deployment configurations and you can access them using their alias dc.

Writing deployment all the time takes too much time. Any idea how to shorten that without setting a local alias on each machine?

Reality:

kubectl get deployment/xyz

Dream:

kubectl get d/xyz

CodePudding user response:

Add bash aliases to different K8s commands in your .bashrc or .zshrc file:

export alias k=kubectl
export alias kgd="k get deploy" # deploy is the short name of deployment 

Some other helpful aliases:

alias k="kubectl"
alias kgp="k get po"
alias kgs="k get svc"
alias kg="k get"
alias kc="k create"
alias kr="k run"
alias ka="k apply -f "
alias kpf="k port-forward"
alias kds="k describe"
alias kd="k delete"

CodePudding user response:

you can create an alias or you can can add plugin in the ~/.zshrc

vi ~/.zshrc

and add

plugins=(
  kubectl
)

then you can use the common alias given below or kgd

or you can try

# Deployment management.
alias kgd='kubectl get deployment'

and then

kgd

There are a couple of aliases that you can use regarding deployment.

|         |                                     | **Deployment management**                                                                        |
| kgd     | `kubectl get deployment`            | Get the deployment                                                                               |
| kgdw    | `kgd --watch`                       | After getting the deployment, watch for changes                                                  |
| kgdwide | `kgd -o wide`                       | After getting the deployment, output in plain-text format with any additional information        |
| ked     | `kubectl edit deployment`           | Edit deployment resource from the default editor                                                 |
| kdd     | `kubectl describe deployment`       | Describe deployment resource in detail                                                           |
| kdeld   | `kubectl delete deployment`         | Delete the deployment                                                                            |
| ksd     | `kubectl scale deployment`          | Scale a deployment                                                                               |
| krsd    | `kubectl rollout status deployment` | Check the rollout status of a deployment                                                         |
| kres    | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime 

you can find more common list here

  • Related