3 This plugin adds completion for the [Kubernetes cluster manager](https://kubernetes.io/docs/reference/kubectl/kubectl/),
4 as well as some aliases for common kubectl commands.
6 To use it, add `kubectl` to the plugins array in your zshrc file:
14 | Alias | Command | Description |
15 |:--------|:------------------------------------|:-------------------------------------------------------------------------------------------------|
16 | k | `kubectl` | The kubectl command |
17 | kca | `kubectl --all-namespaces` | The kubectl command targeting all namespaces |
18 | kaf | `kubectl apply -f` | Apply a YML file |
19 | keti | `kubectl exec -ti` | Drop into an interactive terminal on a container |
20 | | | **Manage configuration quickly to switch contexts between local, dev and staging** |
21 | kcuc | `kubectl config use-context` | Set the current-context in a kubeconfig file |
22 | kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
23 | kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
24 | kccc | `kubectl config current-context` | Display the current-context |
25 | kcgc | `kubectl config get-contexts` | List of contexts available |
26 | | | **General aliases** |
27 | kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
28 | kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument |
29 | | | **Pod management** |
30 | kgp | `kubectl get pods` | List all pods in ps output format |
31 | kgpw | `kgp --watch` | After listing/getting the requested object, watch for changes |
32 | kgpwide | `kgp -o wide` | Output in plain-text format with any additional information. For pods, the node name is included |
33 | kep | `kubectl edit pods` | Edit pods from the default editor |
34 | kdp | `kubectl describe pods` | Describe all pods |
35 | kdelp | `kubectl delete pods` | Delete all pods matching passed arguments |
36 | kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` |
37 | kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` |
38 | | | **Service management** |
39 | kgs | `kubectl get svc` | List all services in ps output format |
40 | kgsw | `kgs --watch` | After listing all services, watch for changes |
41 | kgswide | `kgs -o wide` | After listing all services, output in plain-text format with any additional information |
42 | kes | `kubectl edit svc` | Edit services(svc) from the default editor |
43 | kds | `kubectl describe svc` | Describe all services in detail |
44 | kdels | `kubectl delete svc` | Delete all services matching passed argument |
45 | | | **Ingress management** |
46 | kgi | `kubectl get ingress` | List ingress resources in ps output format |
47 | kei | `kubectl edit ingress` | Edit ingress resource from the default editor |
48 | kdi | `kubectl describe ingress` | Describe ingress resource in detail |
49 | kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument |
50 | | | **Namespace management** |
51 | kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
52 | kcn | `kubectl config set-context --current --namespace` | Change current namespace |
53 | kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
54 | kdns | `kubectl describe namespace` | Describe namespace resource in detail |
55 | kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
56 | | | **ConfigMap management** |
57 | kgcm | `kubectl get configmaps` | List the configmaps in ps output format |
58 | kecm | `kubectl edit configmap` | Edit configmap resource from the default editor |
59 | kdcm | `kubectl describe configmap` | Describe configmap resource in detail |
60 | kdelcm | `kubectl delete configmap` | Delete the configmap |
61 | | | **Secret management** |
62 | kgsec | `kubectl get secret` | Get secret for decoding |
63 | kdsec | `kubectl describe secret` | Describe secret resource in detail |
64 | kdelsec | `kubectl delete secret` | Delete the secret |
65 | | | **Deployment management** |
66 | kgd | `kubectl get deployment` | Get the deployment |
67 | kgdw | `kgd --watch` | After getting the deployment, watch for changes |
68 | kgdwide | `kgd -o wide` | After getting the deployment, output in plain-text format with any additional information |
69 | ked | `kubectl edit deployment` | Edit deployment resource from the default editor |
70 | kdd | `kubectl describe deployment` | Describe deployment resource in detail |
71 | kdeld | `kubectl delete deployment` | Delete the deployment |
72 | ksd | `kubectl scale deployment` | Scale a deployment |
73 | krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment |
74 | kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime |
75 | | | **Rollout management** |
76 | kgrs | `kubectl get replicaset` | List all ReplicaSets `rs` created by the deployment |
77 | kdrs | `kubectl describe replicaset` | Describe ReplicaSet in detail |
78 | kers | `kubectl edit replicaset` | Edit ReplicaSet from the default editor |
79 | krh | `kubectl rollout history` | Check the revisions of this deployment |
80 | kru | `kubectl rollout undo` | Rollback to the previous revision |
81 | | | **Port forwarding** |
82 | kpf | `kubectl port-forward` | Forward one or more local ports to a pod |
83 | | | **Tools for accessing all information** |
84 | kga | `kubectl get all` | List all resources in ps format |
85 | kgaa | `kubectl get all --all-namespaces` | List the requested object(s) across all namespaces |
87 | kl | `kubectl logs` | Print the logs for a container or resource |
88 | klf | `kubectl logs -f` | Stream the logs for a container or resource (follow) |
90 | kcp | `kubectl cp` | Copy files and directories to and from containers |
91 | | | **Node management** |
92 | kgno | `kubectl get nodes` | List the nodes in ps output format |
93 | keno | `kubectl edit node` | Edit nodes resource from the default editor |
94 | kdno | `kubectl describe node` | Describe node resource in detail |
95 | kdelno | `kubectl delete node` | Delete the node |
96 | | | **Persistent Volume Claim management** |
97 | kgpvc | `kubectl get pvc` | List all PVCs |
98 | kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
99 | kepvc | `kubectl edit pvc` | Edit pvcs from the default editor |
100 | kdpvc | `kubectl describe pvc` | Describe all pvcs |
101 | kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments |
102 | | | **StatefulSets management** |
103 | kgss | `kubectl get statefulset` | List the statefulsets in ps format |
104 | kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes |
105 | kgsswide| `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information |
106 | kess | `kubectl edit statefulset` | Edit statefulset resource from the default editor |
107 | kdss | `kubectl describe statefulset` | Describe statefulset resource in detail |
108 | kdelss | `kubectl delete statefulset` | Delete the statefulset |
109 | ksss | `kubectl scale statefulset` | Scale a statefulset |
110 | krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment |
111 | | | **Service Accounts management** |
112 | kdsa | `kubectl describe sa` | Describe a service account in details |
113 | kdelsa | `kubectl delete sa` | Delete the service account |
114 | | | **DaemonSet management** |
115 | kgds | `kubectl get daemonset` | List all DaemonSets in ps output format |
116 | kgdsw | `kgds --watch` | After listing all DaemonSets, watch for changes |
117 | keds | `kubectl edit daemonset` | Edit DaemonSets from the default editor |
118 | kdds | `kubectl describe daemonset` | Describe all DaemonSets in detail |
119 | kdelds | `kubectl delete daemonset` | Delete all DaemonSets matching passed argument |
120 | | | **CronJob management** |
121 | kgcj | `kubectl get cronjob` | List all CronJobs in ps output format |
122 | kecj | `kubectl edit cronjob` | Edit CronJob from the default editor |
123 | kdcj | `kubectl describe cronjob` | Describe a CronJob in details |
124 | kdelcj | `kubectl delete cronjob` | Delete the CronJob |
125 | | | **Job management** |
126 | kgj | `kubectl get job` | List all Job in ps output format |
127 | kej | `kubectl edit job` | Edit a Job in details |
128 | kdj | `kubectl describe job` | Describe the Job |
129 | kdelj | `kubectl delete job` | Delete the Job |
133 This plugin provides 3 wrappers to colorize kubectl output in JSON and YAML using various tools (which must be installed):
135 - `kj`: JSON, colorized with [`jq`](https://stedolan.github.io/jq/).
136 - `kjx`: JSON, colorized with [`fx`](https://github.com/antonmedv/fx).
137 - `ky`: YAML, colorized with [`yh`](https://github.com/andreazorzetto/yh).