feat(kubectl): show labels in aliases kgpsl (get pod) and kgnosl (get node) (#12612)

Co-authored-by: Marc Cornellà <marc@mcornella.com>
This commit is contained in:
Jérémy 2024-09-05 19:57:11 +02:00 committed by GitHub
parent e6380085f3
commit bc42097900
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 122 additions and 122 deletions

View File

@ -11,122 +11,124 @@ plugins=(... kubectl)
## Aliases ## Aliases
| Alias | Command | Description | | Alias | Command | Description |
|:--------|:------------------------------------|:-------------------------------------------------------------------------------------------------| | :------- | :------------------------------------------------- | :----------------------------------------------------------------------------------------------- |
| k | `kubectl` | The kubectl command | | k | `kubectl` | The kubectl command |
| kca | `kubectl --all-namespaces` | The kubectl command targeting all namespaces | | kca | `kubectl --all-namespaces` | The kubectl command targeting all namespaces |
| kaf | `kubectl apply -f` | Apply a YML file | | kaf | `kubectl apply -f` | Apply a YML file |
| keti | `kubectl exec -ti` | Drop into an interactive terminal on a container | | keti | `kubectl exec -ti` | Drop into an interactive terminal on a container |
| | | **Manage configuration quickly to switch contexts between local, dev and staging** | | | | **Manage configuration quickly to switch contexts between local, dev and staging** |
| kcuc | `kubectl config use-context` | Set the current-context in a kubeconfig file | | kcuc | `kubectl config use-context` | Set the current-context in a kubeconfig file |
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig | | kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig | | kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
| kccc | `kubectl config current-context` | Display the current-context | | kccc | `kubectl config current-context` | Display the current-context |
| kcgc | `kubectl config get-contexts` | List of contexts available | | kcgc | `kubectl config get-contexts` | List of contexts available |
| | | **General aliases** | | | | **General aliases** |
| kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector | | kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
| kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument | | kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument |
| | | **Pod management** | | | | **Pod management** |
| kgp | `kubectl get pods` | List all pods in ps output format | | kgp | `kubectl get pods` | List all pods in ps output format |
| kgpw | `kgp --watch` | After listing/getting the requested object, watch for changes | | kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` |
| kgpwide | `kgp -o wide` | Output in plain-text format with any additional information. For pods, the node name is included | | kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` |
| kep | `kubectl edit pods` | Edit pods from the default editor | | kgpsl | `kubectl get pods --show-labels` | List all pods in ps output format with labels |
| kdp | `kubectl describe pods` | Describe all pods | | kgpw | `kgp --watch` | After listing/getting the requested object, watch for changes |
| kdelp | `kubectl delete pods` | Delete all pods matching passed arguments | | kgpwide | `kgp -o wide` | Output in plain-text format with any additional information. For pods, the node name is included |
| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` | | kep | `kubectl edit pods` | Edit pods from the default editor |
| kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` | | kdp | `kubectl describe pods` | Describe all pods |
| | | **Service management** | | kdelp | `kubectl delete pods` | Delete all pods matching passed arguments |
| kgs | `kubectl get svc` | List all services in ps output format | | | | **Service management** |
| kgsw | `kgs --watch` | After listing all services, watch for changes | | kgs | `kubectl get svc` | List all services in ps output format |
| kgswide | `kgs -o wide` | After listing all services, output in plain-text format with any additional information | | kgsw | `kgs --watch` | After listing all services, watch for changes |
| kes | `kubectl edit svc` | Edit services(svc) from the default editor | | kgswide | `kgs -o wide` | After listing all services, output in plain-text format with any additional information |
| kds | `kubectl describe svc` | Describe all services in detail | | kes | `kubectl edit svc` | Edit services(svc) from the default editor |
| kdels | `kubectl delete svc` | Delete all services matching passed argument | | kds | `kubectl describe svc` | Describe all services in detail |
| | | **Ingress management** | | kdels | `kubectl delete svc` | Delete all services matching passed argument |
| kgi | `kubectl get ingress` | List ingress resources in ps output format | | | | **Ingress management** |
| kei | `kubectl edit ingress` | Edit ingress resource from the default editor | | kgi | `kubectl get ingress` | List ingress resources in ps output format |
| kdi | `kubectl describe ingress` | Describe ingress resource in detail | | kei | `kubectl edit ingress` | Edit ingress resource from the default editor |
| kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument | | kdi | `kubectl describe ingress` | Describe ingress resource in detail |
| | | **Namespace management** | | kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument |
| kgns | `kubectl get namespaces` | List the current namespaces in a cluster | | | | **Namespace management** |
| kcn | `kubectl config set-context --current --namespace` | Change current namespace | | kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
| kens | `kubectl edit namespace` | Edit namespace resource from the default editor | | kcn | `kubectl config set-context --current --namespace` | Change current namespace |
| kdns | `kubectl describe namespace` | Describe namespace resource in detail | | kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
| kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace | | kdns | `kubectl describe namespace` | Describe namespace resource in detail |
| | | **ConfigMap management** | | kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
| kgcm | `kubectl get configmaps` | List the configmaps in ps output format | | | | **ConfigMap management** |
| kecm | `kubectl edit configmap` | Edit configmap resource from the default editor | | kgcm | `kubectl get configmaps` | List the configmaps in ps output format |
| kdcm | `kubectl describe configmap` | Describe configmap resource in detail | | kecm | `kubectl edit configmap` | Edit configmap resource from the default editor |
| kdelcm | `kubectl delete configmap` | Delete the configmap | | kdcm | `kubectl describe configmap` | Describe configmap resource in detail |
| | | **Secret management** | | kdelcm | `kubectl delete configmap` | Delete the configmap |
| kgsec | `kubectl get secret` | Get secret for decoding | | | | **Secret management** |
| kdsec | `kubectl describe secret` | Describe secret resource in detail | | kgsec | `kubectl get secret` | Get secret for decoding |
| kdelsec | `kubectl delete secret` | Delete the secret | | kdsec | `kubectl describe secret` | Describe secret resource in detail |
| | | **Deployment management** | | kdelsec | `kubectl delete secret` | Delete the secret |
| kgd | `kubectl get deployment` | Get the deployment | | | | **Deployment management** |
| kgdw | `kgd --watch` | After getting the deployment, watch for changes | | kgd | `kubectl get deployment` | Get the deployment |
| kgdwide | `kgd -o wide` | After getting the deployment, output in plain-text format with any additional information | | kgdw | `kgd --watch` | After getting the deployment, watch for changes |
| ked | `kubectl edit deployment` | Edit deployment resource from the default editor | | kgdwide | `kgd -o wide` | After getting the deployment, output in plain-text format with any additional information |
| kdd | `kubectl describe deployment` | Describe deployment resource in detail | | ked | `kubectl edit deployment` | Edit deployment resource from the default editor |
| kdeld | `kubectl delete deployment` | Delete the deployment | | kdd | `kubectl describe deployment` | Describe deployment resource in detail |
| ksd | `kubectl scale deployment` | Scale a deployment | | kdeld | `kubectl delete deployment` | Delete the deployment |
| krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment | | ksd | `kubectl scale deployment` | Scale a deployment |
| kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime | | krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment |
| | | **Rollout management** | | kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime |
| kgrs | `kubectl get replicaset` | List all ReplicaSets `rs` created by the deployment | | | | **Rollout management** |
| kdrs | `kubectl describe replicaset` | Describe ReplicaSet in detail | | kgrs | `kubectl get replicaset` | List all ReplicaSets `rs` created by the deployment |
| kers | `kubectl edit replicaset` | Edit ReplicaSet from the default editor | | kdrs | `kubectl describe replicaset` | Describe ReplicaSet in detail |
| krh | `kubectl rollout history` | Check the revisions of this deployment | | kers | `kubectl edit replicaset` | Edit ReplicaSet from the default editor |
| kru | `kubectl rollout undo` | Rollback to the previous revision | | krh | `kubectl rollout history` | Check the revisions of this deployment |
| | | **Port forwarding** | | kru | `kubectl rollout undo` | Rollback to the previous revision |
| kpf | `kubectl port-forward` | Forward one or more local ports to a pod | | | | **Port forwarding** |
| | | **Tools for accessing all information** | | kpf | `kubectl port-forward` | Forward one or more local ports to a pod |
| kga | `kubectl get all` | List all resources in ps format | | | | **Tools for accessing all information** |
| kgaa | `kubectl get all --all-namespaces` | List the requested object(s) across all namespaces | | kga | `kubectl get all` | List all resources in ps format |
| | | **Logs** | | kgaa | `kubectl get all --all-namespaces` | List the requested object(s) across all namespaces |
| kl | `kubectl logs` | Print the logs for a container or resource | | | | **Logs** |
| klf | `kubectl logs -f` | Stream the logs for a container or resource (follow) | | kl | `kubectl logs` | Print the logs for a container or resource |
| | | **File copy** | | klf | `kubectl logs -f` | Stream the logs for a container or resource (follow) |
| kcp | `kubectl cp` | Copy files and directories to and from containers | | | | **File copy** |
| | | **Node management** | | kcp | `kubectl cp` | Copy files and directories to and from containers |
| kgno | `kubectl get nodes` | List the nodes in ps output format | | | | **Node management** |
| keno | `kubectl edit node` | Edit nodes resource from the default editor | | kgno | `kubectl get nodes` | List the nodes in ps output format |
| kdno | `kubectl describe node` | Describe node resource in detail | | kgnosl | `kubectl get nodes --show-labels` | List the nodes in ps output format with labels |
| kdelno | `kubectl delete node` | Delete the node | | keno | `kubectl edit node` | Edit nodes resource from the default editor |
| | | **Persistent Volume Claim management** | | kdno | `kubectl describe node` | Describe node resource in detail |
| kgpvc | `kubectl get pvc` | List all PVCs | | kdelno | `kubectl delete node` | Delete the node |
| kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes | | | | **Persistent Volume Claim management** |
| kepvc | `kubectl edit pvc` | Edit pvcs from the default editor | | kgpvc | `kubectl get pvc` | List all PVCs |
| kdpvc | `kubectl describe pvc` | Describe all pvcs | | kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
| kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments | | kepvc | `kubectl edit pvc` | Edit pvcs from the default editor |
| | | **StatefulSets management** | | kdpvc | `kubectl describe pvc` | Describe all pvcs |
| kgss | `kubectl get statefulset` | List the statefulsets in ps format | | kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments |
| kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes | | | | **StatefulSets management** |
| kgsswide| `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information | | kgss | `kubectl get statefulset` | List the statefulsets in ps format |
| kess | `kubectl edit statefulset` | Edit statefulset resource from the default editor | | kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes |
| kdss | `kubectl describe statefulset` | Describe statefulset resource in detail | | kgsswide | `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information |
| kdelss | `kubectl delete statefulset` | Delete the statefulset | | kess | `kubectl edit statefulset` | Edit statefulset resource from the default editor |
| ksss | `kubectl scale statefulset` | Scale a statefulset | | kdss | `kubectl describe statefulset` | Describe statefulset resource in detail |
| krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment | | kdelss | `kubectl delete statefulset` | Delete the statefulset |
| | | **Service Accounts management** | | ksss | `kubectl scale statefulset` | Scale a statefulset |
| kdsa | `kubectl describe sa` | Describe a service account in details | | krsss | `kubectl rollout status statefulset` | Check the rollout status of a deployment |
| kdelsa | `kubectl delete sa` | Delete the service account | | | | **Service Accounts management** |
| | | **DaemonSet management** | | kdsa | `kubectl describe sa` | Describe a service account in details |
| kgds | `kubectl get daemonset` | List all DaemonSets in ps output format | | kdelsa | `kubectl delete sa` | Delete the service account |
| kgdsw | `kgds --watch` | After listing all DaemonSets, watch for changes | | | | **DaemonSet management** |
| keds | `kubectl edit daemonset` | Edit DaemonSets from the default editor | | kgds | `kubectl get daemonset` | List all DaemonSets in ps output format |
| kdds | `kubectl describe daemonset` | Describe all DaemonSets in detail | | kgdsw | `kgds --watch` | After listing all DaemonSets, watch for changes |
| kdelds | `kubectl delete daemonset` | Delete all DaemonSets matching passed argument | | keds | `kubectl edit daemonset` | Edit DaemonSets from the default editor |
| | | **CronJob management** | | kdds | `kubectl describe daemonset` | Describe all DaemonSets in detail |
| kgcj | `kubectl get cronjob` | List all CronJobs in ps output format | | kdelds | `kubectl delete daemonset` | Delete all DaemonSets matching passed argument |
| kecj | `kubectl edit cronjob` | Edit CronJob from the default editor | | | | **CronJob management** |
| kdcj | `kubectl describe cronjob` | Describe a CronJob in details | | kgcj | `kubectl get cronjob` | List all CronJobs in ps output format |
| kdelcj | `kubectl delete cronjob` | Delete the CronJob | | kecj | `kubectl edit cronjob` | Edit CronJob from the default editor |
| | | **Job management** | | kdcj | `kubectl describe cronjob` | Describe a CronJob in details |
| kgj | `kubectl get job` | List all Job in ps output format | | kdelcj | `kubectl delete cronjob` | Delete the CronJob |
| kej | `kubectl edit job` | Edit a Job in details | | | | **Job management** |
| kdj | `kubectl describe job` | Describe the Job | | kgj | `kubectl get job` | List all Job in ps output format |
| kdelj | `kubectl delete job` | Delete the Job | | kej | `kubectl edit job` | Edit a Job in details |
| kdj | `kubectl describe job` | Describe the Job |
| kdelj | `kubectl delete job` | Delete the Job |
## Wrappers ## Wrappers

View File

@ -39,6 +39,9 @@ alias kdelf='kubectl delete -f'
# Pod management. # Pod management.
alias kgp='kubectl get pods' alias kgp='kubectl get pods'
alias kgpl='kgp -l'
alias kgpn='kgp -n'
alias kgpsl='kubectl get pods --show-labels'
alias kgpa='kubectl get pods --all-namespaces' alias kgpa='kubectl get pods --all-namespaces'
alias kgpw='kgp --watch' alias kgpw='kgp --watch'
alias kgpwide='kgp -o wide' alias kgpwide='kgp -o wide'
@ -47,12 +50,6 @@ alias kdp='kubectl describe pods'
alias kdelp='kubectl delete pods' alias kdelp='kubectl delete pods'
alias kgpall='kubectl get pods --all-namespaces -o wide' alias kgpall='kubectl get pods --all-namespaces -o wide'
# get pod by label: kgpl "app=myapp" -n myns
alias kgpl='kgp -l'
# get pod by namespace: kgpn kube-system"
alias kgpn='kgp -n'
# Service management. # Service management.
alias kgs='kubectl get svc' alias kgs='kubectl get svc'
alias kgsa='kubectl get svc --all-namespaces' alias kgsa='kubectl get svc --all-namespaces'
@ -144,6 +141,7 @@ alias kcp='kubectl cp'
# Node Management # Node Management
alias kgno='kubectl get nodes' alias kgno='kubectl get nodes'
alias kgnosl='kubectl get nodes --show-labels'
alias keno='kubectl edit node' alias keno='kubectl edit node'
alias kdno='kubectl describe node' alias kdno='kubectl describe node'
alias kdelno='kubectl delete node' alias kdelno='kubectl delete node'