K8s command line tool kubectl is a necessary tool for people who play k8s. Kubectl plug-in mechanism declared stable in kubernetes 1.14 and entered Ga State. The plug-in mechanism of kubectl is to allow developers to issue customized kubectl subcommands in an independent binary form. Kubectl plug-in can be developed in any language. For example, it can be a script of Bash and python or a binary executable file developed and compiled in other languages. As long as the script or binary executable file is finally put into path with kubectl – prefix. Use kubectl plugin list to see which plug-ins are available in path
Krew is the manager of kubectl plug-ins. Using Krew, you can easily find, install and manage kubectl plug-ins. Krew itself exists as a kubectl plug-in. The installation documents on the official website are very clear and friendly. You can move: https://krew.sigs.k8s.io/docs/user-guide/setup/install/ 。 I installed it by downloading the file directly. Before installation, confirm that git has been installed on the target machine. Krew will use git when updating the local plug-in index.
View all plug-ins
Plug in installation
kubectl krew install xxxx
Common plug-ins
1. Ns plug-in
NS is a plug-in that can switch namespaces in the kubernetes cluster. Are you tired of adding – N & lt; every time you hit the kubectl command; namespaces> And don’t want to maintain a large number of context in config. Then the NS plug-in is to save you. It will modify the context in the current config to the current namespace when switching the namespace, so you don’t need to add the – n parameter.
Installation:
kubectl krew install ns
2. Images plug-in
The images plug-in allows you to view the image information used in the current namespace (or even the entire cluster) workload. Currently, several functions are supported as follows:
Lists the image information for all namespace workloads
The specified field displays the associated k8s information of the image
Specify a separate namespace to display the image
Installation: kubectl Krew install images
3. View secret plug-in
In most cases, the information in our secret will be stored after Base64 encoding in advance. When we need to read the content from secret, we are doing decode
kubectl get secret < secret> – o=jsonpath='{.data.password}’ |base64 -d
But our goal is to type fewer commands and never more than one letter. Then view secret can help us at this time.
Installation:
kubectl krew install view-secret
4. View allocations plug-in
If you want to quickly know the current resource distribution of your kubernetes cluster, the view allocations plug-in can certainly help. Currently, view allocations can display the current resource allocation status of the cluster according to the three dimensions of resource, node and pod. It is worth mentioning that if your kubernetes cluster has GPU nodes, you can also quickly check your GPU graphics card allocation status by using view allocations
Similar Posts:
- [Solved] K8s cannot delete the namespace. It is always in the terminating state.
- K8s version 1.20x nfs dynamic storage error: persistentvolume-controller waiting for a volume to be created, either by external provisioner “qgg-nfs-storage” or manually created by system administrator
- Sublime run code – open in browser shortcut key settings
- nfs load errorwrong fs type, bad option, bad superblock
- K8S Error: no metrics known for node [How to Solve]
- docker: Error response from daemon: Conflict. The container name “/xx” is already in use
- The newly deployed k8s cluster of the virtual machine reports an error when executing kubectl logs and exec
- Pom.xml error: org.codehaus.plexus.archiver.jar.Manifest.write(java.io.PrintWriter) solution
- Other Master Nodes Add to the Cluster After Reset Error: CONTEXT DEADLINE EXCEEDED
- [Solved] k8s-nfs pvc load error –nfs-client-provisioner