658240f49816bd6ae1e693a383e26b703ef2d0fb

Author
mm503 <182180598+mm503@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(kubectl): add aliases for `get events` (#13147)

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md
  2index 28a502d111cf376b1b5b4dab0fc0602dcbd7922f..6f347a8ee940656e790d7fdc0193453e8200d6c6 100644
  3--- a/plugins/kubectl/README.md
  4+++ b/plugins/kubectl/README.md
  5@@ -11,124 +11,126 @@ plugins=(... kubectl)
  6 
  7 ## Aliases
  8 
  9-| Alias    | Command                                            | Description                                                                                      |
 10-| :------- | :------------------------------------------------- | :----------------------------------------------------------------------------------------------- |
 11-| k        | `kubectl`                                          | The kubectl command                                                                              |
 12-| kca      | `kubectl --all-namespaces`                         | The kubectl command targeting all namespaces                                                     |
 13-| kaf      | `kubectl apply -f`                                 | Apply a YML file                                                                                 |
 14-| keti     | `kubectl exec -ti`                                 | Drop into an interactive terminal on a container                                                 |
 15-|          |                                                    | **Manage configuration quickly to switch contexts between local, dev and staging**               |
 16-| kcuc     | `kubectl config use-context`                       | Set the current-context in a kubeconfig file                                                     |
 17-| kcsc     | `kubectl config set-context`                       | Set a context entry in kubeconfig                                                                |
 18-| kcdc     | `kubectl config delete-context`                    | Delete the specified context from the kubeconfig                                                 |
 19-| kccc     | `kubectl config current-context`                   | Display the current-context                                                                      |
 20-| kcgc     | `kubectl config get-contexts`                      | List of contexts available                                                                       |
 21-|          |                                                    | **General aliases**                                                                              |
 22-| kdel     | `kubectl delete`                                   | Delete resources by filenames, stdin, resources and names, or by resources and label selector    |
 23-| kdelf    | `kubectl delete -f`                                | Delete a pod using the type and name specified in -f argument                                    |
 24-|          |                                                    | **Pod management**                                                                               |
 25-| kgp      | `kubectl get pods`                                 | List all pods in ps output format                                                                |
 26-| kgpl     | `kgp -l`                                           | Get pods by label. Example: `kgpl "app=myapp" -n myns`                                           |
 27-| kgpn     | `kgp -n`                                           | Get pods by namespace. Example: `kgpn kube-system`                                               |
 28-| kgpsl    | `kubectl get pods --show-labels`                   | List all pods in ps output format with labels                                                    |
 29-| kgpw     | `kgp --watch`                                      | After listing/getting the requested object, watch for changes                                    |
 30-| kgpwide  | `kgp -o wide`                                      | Output in plain-text format with any additional information. For pods, the node name is included |
 31-| kep      | `kubectl edit pods`                                | Edit pods from the default editor                                                                |
 32-| kdp      | `kubectl describe pods`                            | Describe all pods                                                                                |
 33-| kdelp    | `kubectl delete pods`                              | Delete all pods matching passed arguments                                                        |
 34-|          |                                                    | **Service management**                                                                           |
 35-| kgs      | `kubectl get svc`                                  | List all services in ps output format                                                            |
 36-| kgsw     | `kgs --watch`                                      | After listing all services, watch for changes                                                    |
 37-| kgswide  | `kgs -o wide`                                      | After listing all services, output in plain-text format with any additional information          |
 38-| kes      | `kubectl edit svc`                                 | Edit services(svc) from the default editor                                                       |
 39-| kds      | `kubectl describe svc`                             | Describe all services in detail                                                                  |
 40-| kdels    | `kubectl delete svc`                               | Delete all services matching passed argument                                                     |
 41-|          |                                                    | **Ingress management**                                                                           |
 42-| kgi      | `kubectl get ingress`                              | List ingress resources in ps output format                                                       |
 43-| kei      | `kubectl edit ingress`                             | Edit ingress resource from the default editor                                                    |
 44-| kdi      | `kubectl describe ingress`                         | Describe ingress resource in detail                                                              |
 45-| kdeli    | `kubectl delete ingress`                           | Delete ingress resources matching passed argument                                                |
 46-|          |                                                    | **Namespace management**                                                                         |
 47-| kgns     | `kubectl get namespaces`                           | List the current namespaces in a cluster                                                         |
 48-| kcn      | `kubectl config set-context --current --namespace` | Change current namespace                                                                         |
 49-| kens     | `kubectl edit namespace`                           | Edit namespace resource from the default editor                                                  |
 50-| kdns     | `kubectl describe namespace`                       | Describe namespace resource in detail                                                            |
 51-| kdelns   | `kubectl delete namespace`                         | Delete the namespace. WARNING! This deletes everything in the namespace                          |
 52-|          |                                                    | **ConfigMap management**                                                                         |
 53-| kgcm     | `kubectl get configmaps`                           | List the configmaps in ps output format                                                          |
 54-| kecm     | `kubectl edit configmap`                           | Edit configmap resource from the default editor                                                  |
 55-| kdcm     | `kubectl describe configmap`                       | Describe configmap resource in detail                                                            |
 56-| kdelcm   | `kubectl delete configmap`                         | Delete the configmap                                                                             |
 57-|          |                                                    | **Secret management**                                                                            |
 58-| kgsec    | `kubectl get secret`                               | Get secret for decoding                                                                          |
 59-| kdsec    | `kubectl describe secret`                          | Describe secret resource in detail                                                               |
 60-| kdelsec  | `kubectl delete secret`                            | Delete the secret                                                                                |
 61-|          |                                                    | **Deployment management**                                                                        |
 62-| kgd      | `kubectl get deployment`                           | Get the deployment                                                                               |
 63-| kgdw     | `kgd --watch`                                      | After getting the deployment, watch for changes                                                  |
 64-| kgdwide  | `kgd -o wide`                                      | After getting the deployment, output in plain-text format with any additional information        |
 65-| ked      | `kubectl edit deployment`                          | Edit deployment resource from the default editor                                                 |
 66-| kdd      | `kubectl describe deployment`                      | Describe deployment resource in detail                                                           |
 67-| kdeld    | `kubectl delete deployment`                        | Delete the deployment                                                                            |
 68-| ksd      | `kubectl scale deployment`                         | Scale a deployment                                                                               |
 69-| krsd     | `kubectl rollout status deployment`                | Check the rollout status of a deployment                                                         |
 70-| kres     | `kubectl set env $@ REFRESHED_AT=...`              | Recreate all pods in deployment with zero-downtime                                               |
 71-|          |                                                    | **Rollout management**                                                                           |
 72-| kgrs     | `kubectl get replicaset`                           | List all ReplicaSets `rs` created by the deployment                                              |
 73-| kdrs     | `kubectl describe replicaset`                      | Describe ReplicaSet in detail                                                                    |
 74-| kers     | `kubectl edit replicaset`                          | Edit ReplicaSet from the default editor                                                          |
 75-| krh      | `kubectl rollout history`                          | Check the revisions of this deployment                                                           |
 76-| kru      | `kubectl rollout undo`                             | Rollback to the previous revision                                                                |
 77-|          |                                                    | **Port forwarding**                                                                              |
 78-| kpf      | `kubectl port-forward`                             | Forward one or more local ports to a pod                                                         |
 79-|          |                                                    | **Tools for accessing all information**                                                          |
 80-| kga      | `kubectl get all`                                  | List all resources in ps format                                                                  |
 81-| kgaa     | `kubectl get all --all-namespaces`                 | List the requested object(s) across all namespaces                                               |
 82-|          |                                                    | **Logs**                                                                                         |
 83-| kl       | `kubectl logs`                                     | Print the logs for a container or resource                                                       |
 84-| klf      | `kubectl logs -f`                                  | Stream the logs for a container or resource (follow)                                             |
 85-|          |                                                    | **File copy**                                                                                    |
 86-| kcp      | `kubectl cp`                                       | Copy files and directories to and from containers                                                |
 87-|          |                                                    | **Node management**                                                                              |
 88-| kgno     | `kubectl get nodes`                                | List the nodes in ps output format                                                               |
 89-| kgnosl   | `kubectl get nodes --show-labels`                  | List the nodes in ps output format with labels                                                   |
 90-| keno     | `kubectl edit node`                                | Edit nodes resource from the default editor                                                      |
 91-| kdno     | `kubectl describe node`                            | Describe node resource in detail                                                                 |
 92-| kdelno   | `kubectl delete node`                              | Delete the node                                                                                  |
 93-|          |                                                    | **Persistent Volume Claim management**                                                           |
 94-| kgpvc    | `kubectl get pvc`                                  | List all PVCs                                                                                    |
 95-| kgpvcw   | `kgpvc --watch`                                    | After listing/getting the requested object, watch for changes                                    |
 96-| kepvc    | `kubectl edit pvc`                                 | Edit pvcs from the default editor                                                                |
 97-| kdpvc    | `kubectl describe pvc`                             | Describe all pvcs                                                                                |
 98-| kdelpvc  | `kubectl delete pvc`                               | Delete all pvcs matching passed arguments                                                        |
 99-|          |                                                    | **StatefulSets management**                                                                      |
100-| kgss     | `kubectl get statefulset`                          | List the statefulsets in ps format                                                               |
101-| kgssw    | `kgss --watch`                                     | After getting the list of statefulsets, watch for changes                                        |
102-| kgsswide | `kgss -o wide`                                     | After getting the statefulsets, output in plain-text format with any additional information      |
103-| kess     | `kubectl edit statefulset`                         | Edit statefulset resource from the default editor                                                |
104-| kdss     | `kubectl describe statefulset`                     | Describe statefulset resource in detail                                                          |
105diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh
106index 33699bdf9db6a6bbd45cd012648cc7ad94b25227..4a72c02af98822055640ea05012147d948258936 100644
107--- a/plugins/kubectl/kubectl.plugin.zsh
108+++ b/plugins/kubectl/kubectl.plugin.zsh
109@@ -36,6 +36,8 @@ alias kcgc='kubectl config get-contexts'
110 # General aliases
111 alias kdel='kubectl delete'
112 alias kdelf='kubectl delete -f'
113+alias kge='kubectl get events --sort-by=".lastTimestamp"'
114+alias kgew='kubectl get events --sort-by=".lastTimestamp" --watch'
115 
116 # Pod management.
117 alias kgp='kubectl get pods'