bf5574fc93166d7c1915b9f3ae78aba1959a8403

Author
Wenli Wan <swwl1992@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

kubectl: add aliases for serviceaccount, daemonsets and cronjob (#9344)

Diff

 1diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md
 2index 84f5f8d897aa6672914398059c99c25483c4ee16..7a6cdaa5995c4d3e43809b6bd28b8981c0b23bc0 100644
 3--- a/plugins/kubectl/README.md
 4+++ b/plugins/kubectl/README.md
 5@@ -22,7 +22,7 @@ plugins=(... kubectl)
 6 | kcsc    | `kubectl config set-context`        | Set a context entry in kubeconfig                                                                |
 7 | kcdc    | `kubectl config delete-context`     | Delete the specified context from the kubeconfig                                                 |
 8 | kccc    | `kubectl config current-context`    | Display the current-context                                                                      |
 9-| kcgc    | `kubectl config get-contexts` | List of contexts available
10+| kcgc    | `kubectl config get-contexts`       | List of contexts available
11 |         |                                     | **General aliases**                                                                              |
12 | kdel    | `kubectl delete`                    | Delete resources by filenames, stdin, resources and names, or by resources and label selector    |
13 | kdelf   | `kubectl delete -f`                 | Delete a pod using the type and name specified in -f argument                                    |
14@@ -91,13 +91,13 @@ plugins=(... kubectl)
15 | keno    | `kubectl edit node`                 | Edit nodes resource from the default editor                                                      |
16 | kdno    | `kubectl describe node`             | Describe node resource in detail                                                                 |
17 | kdelno  | `kubectl delete node`               | Delete the node                                                                                  |
18-|         |                                   | **Persistent Volume Claim management**                                                           |
19+|         |                                     | **Persistent Volume Claim management**                                                           |
20 | kgpvc   | `kubectl get pvc`                   | List all PVCs                                                                                    |
21 | kgpvcw  | `kgpvc --watch`                     | After listing/getting the requested object, watch for changes                                    |
22 | kepvc   | `kubectl edit pvc`                  | Edit pvcs from the default editor                                                                |
23-| kdpvc   | `kubectl describe pvc`              | Descirbe all pvcs                                                                                |
24+| kdpvc   | `kubectl describe pvc`              | Describe all pvcs                                                                                |
25 | kdelpvc | `kubectl delete pvc`                | Delete all pvcs matching passed arguments                                                        |
26-|         |                                     |                                                                                                  |
27+|         |                                     | **StatefulSets management**                                                                      |
28 | kgss    | `kubectl get statefulset`           | List the statefulsets in ps format                                                               |
29 | kgssw   | `kgss --watch`                      | After getting the list of statefulsets, watch for changes                                        |
30 | kgsswide| `kgss -o wide`                      | After getting the statefulsets, output in plain-text format with any additional information      |
31@@ -106,6 +106,21 @@ plugins=(... kubectl)
32 | kdelss  | `kubectl delete statefulset`        | Delete the statefulset                                                                           |
33 | ksss    | `kubectl scale statefulset`         | Scale a statefulset                                                                              |
34 | krsss   | `kubectl rollout status statefulset`| Check the rollout status of a deployment                                                         |
35+|         |                                     | **Service Accounts management**                                                                  |
36+| kgsa    | `kubectl get sa`                    | List all service accounts                                                                        |
37+| kdsa    | `kubectl describe sa`               | Describe a service account in details                                                            |
38+| kdelsa  | `kubectl delete sa`                 | Delete the service account                                                                       |
39+|         |                                     | **DaemonSet management**                                                                         |
40+| kgds    | `kubectl get daemonset`             | List all DaemonSets in ps output format                                                          |
41+| kgdsw   | `kgds --watch`                      | After listing all DaemonSets, watch for changes                                                  |
42+| keds    | `kubectl edit daemonset`            | Edit DaemonSets from the default editor                                                          |
43+| kdds    | `kubectl describe daemonset`        | Describe all DaemonSets in detail                                                                |
44+| kdelds  | `kubectl delete daemonset`          | Delete all DaemonSets matching passed argument                                                   |
45+|         |                                     | **CronJob management**                                                                           |
46+| kgcj    | `kubectl get cronjob`               | List all CronJobs in ps output format                                                            |
47+| kecj    | `kubectl edit cronjob`              | Edit CronJob from the default editor                                                             |
48+| kdcj    | `kubectl describe cronjob`          | Describe a CronJob in details                                                                    |
49+| kdelcj  | `kubectl delete cronjob`            | Delete the CronJob                                                                               |
50 
51 ## Wrappers
52 
53diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh
54index 0b1edb4501ec2e2a86cbb83b5fd063f16ae03b0b..d509d8795f0618a6eb3e41503917e3d47c68d42a 100644
55--- a/plugins/kubectl/kubectl.plugin.zsh
56+++ b/plugins/kubectl/kubectl.plugin.zsh
57@@ -150,6 +150,24 @@ alias kepvc='kubectl edit pvc'
58 alias kdpvc='kubectl describe pvc'
59 alias kdelpvc='kubectl delete pvc'
60 
61+# Service account management.
62+alias kgsa="kubectl get sa"
63+alias kdsa="kubectl describe sa"
64+alias kdelsa="kubectl delete sa"
65+
66+# DaemonSet management.
67+alias kgds='kubectl get daemonset'
68+alias kgdsw='kgds --watch'
69+alias keds='kubectl edit daemonset'
70+alias kdds='kubectl describe daemonset'
71+alias kdelds='kubectl delete daemonset'
72+
73+# CronJob management.
74+alias kgcj='kubectl get cronjob'
75+alias kecj='kubectl edit cronjob'
76+alias kdcj='kubectl describe cronjob'
77+alias kdelcj='kubectl delete cronjob'
78+
79 # Only run if the user actually has kubectl installed
80 if (( ${+_comps[kubectl]} )); then
81   kj() { kubectl "$@" -o json | jq; }