my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
16 KiB

3 years ago
  1. # Kubectl plugin
  2. This plugin adds completion for the [Kubernetes cluster manager](https://kubernetes.io/docs/reference/kubectl/kubectl/),
  3. as well as some aliases for common kubectl commands.
  4. To use it, add `kubectl` to the plugins array in your zshrc file:
  5. ```zsh
  6. plugins=(... kubectl)
  7. ```
  8. ## Aliases
  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. | kgpw | `kgp --watch` | After listing/getting the requested object, watch for changes |
  27. | kgpwide | `kgp -o wide` | Output in plain-text format with any additional information. For pods, the node name is included |
  28. | kep | `kubectl edit pods` | Edit pods from the default editor |
  29. | kdp | `kubectl describe pods` | Describe all pods |
  30. | kdelp | `kubectl delete pods` | Delete all pods matching passed arguments |
  31. | kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` |
  32. | kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` |
  33. | | | **Service management** |
  34. | kgs | `kubectl get svc` | List all services in ps output format |
  35. | kgsw | `kgs --watch` | After listing all services, watch for changes |
  36. | kgswide | `kgs -o wide` | After listing all services, output in plain-text format with any additional information |
  37. | kes | `kubectl edit svc` | Edit services(svc) from the default editor |
  38. | kds | `kubectl describe svc` | Describe all services in detail |
  39. | kdels | `kubectl delete svc` | Delete all services matching passed argument |
  40. | | | **Ingress management** |
  41. | kgi | `kubectl get ingress` | List ingress resources in ps output format |
  42. | kei | `kubectl edit ingress` | Edit ingress resource from the default editor |
  43. | kdi | `kubectl describe ingress` | Describe ingress resource in detail |
  44. | kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument |
  45. | | | **Namespace management** |
  46. | kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
  47. | kcn | `kubectl config set-context --current --namespace` | Change current namespace |
  48. | kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
  49. | kdns | `kubectl describe namespace` | Describe namespace resource in detail |
  50. | kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
  51. | | | **ConfigMap management** |
  52. | kgcm | `kubectl get configmaps` | List the configmaps in ps output format |
  53. | kecm | `kubectl edit configmap` | Edit configmap resource from the default editor |
  54. | kdcm | `kubectl describe configmap` | Describe configmap resource in detail |
  55. | kdelcm | `kubectl delete configmap` | Delete the configmap |
  56. | | | **Secret management** |
  57. | kgsec | `kubectl get secret` | Get secret for decoding |
  58. | kdsec | `kubectl describe secret` | Describe secret resource in detail |
  59. | kdelsec | `kubectl delete secret` | Delete the secret |
  60. | | | **Deployment management** |
  61. | kgd | `kubectl get deployment` | Get the deployment |
  62. | kgdw | `kgd --watch` | After getting the deployment, watch for changes |
  63. | kgdwide | `kgd -o wide` | After getting the deployment, output in plain-text format with any additional information |
  64. | ked | `kubectl edit deployment` | Edit deployment resource from the default editor |
  65. | kdd | `kubectl describe deployment` | Describe deployment resource in detail |
  66. | kdeld | `kubectl delete deployment` | Delete the deployment |
  67. | ksd | `kubectl scale deployment` | Scale a deployment |
  68. | krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment |
  69. | kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime |
  70. | | | **Rollout management** |
  71. | kgrs | `kubectl get rs` | To see the ReplicaSet `rs` created by the deployment |
  72. | krh | `kubectl rollout history` | Check the revisions of this deployment |
  73. | kru | `kubectl rollout undo` | Rollback to the previous revision |
  74. | | | **Port forwarding** |
  75. | kpf | `kubectl port-forward` | Forward one or more local ports to a pod |
  76. | | | **Tools for accessing all information** |
  77. | kga | `kubectl get all` | List all resources in ps format |
  78. | kgaa | `kubectl get all --all-namespaces` | List the requested object(s) across all namespaces |
  79. | | | **Logs** |
  80. | kl | `kubectl logs` | Print the logs for a container or resource |
  81. | klf | `kubectl logs -f` | Stream the logs for a container or resource (follow) |
  82. | | | **File copy** |
  83. | kcp | `kubectl cp` | Copy files and directories to and from containers |
  84. | | | **Node management** |
  85. | kgno | `kubectl get nodes` | List the nodes in ps output format |
  86. | keno | `kubectl edit node` | Edit nodes resource from the default editor |
  87. | kdno | `kubectl describe node` | Describe node resource in detail |
  88. | kdelno | `kubectl delete node` | Delete the node |
  89. | | | **Persistent Volume Claim management** |
  90. | kgpvc | `kubectl get pvc` | List all PVCs |
  91. | kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
  92. | kepvc | `kubectl edit pvc` | Edit pvcs from the default editor |
  93. | kdpvc | `kubectl describe pvc` | Describe all pvcs |
  94. | kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments |
  95. | | | **StatefulSets management** |
  96. | kgss | `kubectl get statefulset` | List the statefulsets in ps format |
  97. | kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes |
  98. | kgsswide| `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information |
  99. | kess | `kubectl edit statefulset` | Edit statefulset resource from the default editor |
  100. | kdss | `kubectl describe statefulset` | Describe statefulset resource in detail |
  101. | kdelss | `kubectl delete statefulset` | Delete the statefulset |
  102. | ksss | `kubectl scale statefulset` | Scale a statefulset |
  103. | krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment |
  104. | | | **Service Accounts management** |
  105. | kdsa | `kubectl describe sa` | Describe a service account in details |
  106. | kdelsa | `kubectl delete sa` | Delete the service account |
  107. | | | **DaemonSet management** |
  108. | kgds | `kubectl get daemonset` | List all DaemonSets in ps output format |
  109. | kgdsw | `kgds --watch` | After listing all DaemonSets, watch for changes |
  110. | keds | `kubectl edit daemonset` | Edit DaemonSets from the default editor |
  111. | kdds | `kubectl describe daemonset` | Describe all DaemonSets in detail |
  112. | kdelds | `kubectl delete daemonset` | Delete all DaemonSets matching passed argument |
  113. | | | **CronJob management** |
  114. | kgcj | `kubectl get cronjob` | List all CronJobs in ps output format |
  115. | kecj | `kubectl edit cronjob` | Edit CronJob from the default editor |
  116. | kdcj | `kubectl describe cronjob` | Describe a CronJob in details |
  117. | kdelcj | `kubectl delete cronjob` | Delete the CronJob |
  118. ## Wrappers
  119. This plugin provides 3 wrappers to colorize kubectl output in JSON and YAML using various tools (which must be installed):
  120. - `kj`: JSON, colorized with [`jq`](https://stedolan.github.io/jq/).
  121. - `kjx`: JSON, colorized with [`fx`](https://github.com/antonmedv/fx).
  122. - `ky`: YAML, colorized with [`yh`](https://github.com/andreazorzetto/yh).