Aliases and helpers to make the work in kubernetes environment easier.
| Name | Description |
|---|---|
| kubectl | The Kubernetes command-line tool that allows you to run commands against Kubernetes clusters. |
| kubectx | Tool to switch between contexts (clusters) on kubectl faster |
| kubens | Tool to switch between Kubernetes namespaces (and configure them for kubectl) easily |
To use my kubernetes commands aliases in your daily work with kubernetes, you have to copy the content of file k8s-commands-aliases-bash|k8s-commands-aliases-zsh into your terminal configuration file.
git clone https://github.com/josericardomcastro/k8s-aliases
cat k8s-aliases/k8s-commands-aliases-bash >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/josericardomcastro/k8s-aliases
cat k8s-aliases/k8s-commands-aliases-zsh >> ~/.zshrc
source ~/.zshrc
Tools:
k- kubectlkx- kubectxkns- kubens
Commands verbs:
g- gete- editd- deletedesc- describe
Resources:
n- nodesns- namespacesp- podsdp- deploymentsds- daemonsetsrs- replicasetsss- statefulsetss- servicesi- ingressr- routessc- secretscm- configmapspvc- persistentvolumeclaimspv- persistentvolumeep- endpointse- eventsrq- resourcequotaslr- limitranges
Output
w- widey- yaml
| Alias | Command description |
|---|---|
| kx minikube | Switch to the minikube cluster |
| kns app-prod | Switch to app-prod namespace |
| kgp | kubectl get pods |
| kgpw | kubectl get pods -o wide |
| kgpy my-pod | kubectl get pods my-pod -o yaml |
| kgs | kubectl get services |
| kgsy my-service | kubectl get services my-service -o yaml |
| kedp app-frontend | kubectl edit deployments app-frontend |
| kdns ns-test | kubectl delete namespaces ns-test |
See the k8s-commands-aliases-bash or k8s-commands-aliases-zsh file for the full list of aliases.
Custom $PS1 (Prompt Statement One) with information about kubernetes and git.
Download the k8s-git-ps1 file
curl -LO https://raw.githubusercontent.com/josericardomcastro/k8s-aliases/main/k8s-git-ps1
Add the following command to your .bashrc file:
[ -f <path-to-file>/k8s-git-ps1 ] && source <path-to-file>/k8s-git-ps1
You will see a prompt like this:
Format: [current time] [k8s context/cluster : k8s namespace] ~current location (git branch name)
