Cyberithub

Krew - Plugin Manager for Kubectl Command Line Tool

Advertisements

Krew is a kubectl plugin manager for installing and managing plugins in the local system. It is widely known for enhancing the kubernetes experience. You can't just install available kubectl plugins but you can also package and distribute plugins on multiple platforms quite easily and can make those discoverable through a central plugin repository so that others can easily find and use your plugins. Krew works on all the major platforms such as Windows, Linux and MacOS. Check the steps on How to Install Krew Plugin Manager for kubectl CLI on Linux to install it on a linux distribution.

 

Krew - Plugin Manager for Kubectl Command Line Tool

Krew - Plugin Manager for Kubectl Command Line Tool

Also Read: Solved: Multi-Attach error for Volume "pvc-xx" Volume is already Used

Example 1: How to download all the Plugins list

To download the latest available plugins in your local system, you need to use kubectl krew update command as shown below.

cyberithub@ubuntu:~$ kubectl krew update
Updated the local copy of plugin index.

 

Example 2: How to search all the available Plugins

To search all the currently available plugins, you need to use kubectl krew search command as shown below.

cyberithub@ubuntu:~$ kubectl krew search
NAME                     DESCRIPTION                                           INSTALLED
access-matrix            Show an RBAC access matrix for server resources       no
accurate                 Manage Accurate, a multi-tenancy controller           no
advise-policy            Suggests PodSecurityPolicies and OPA Policies f...    no
advise-psp               Suggests PodSecurityPolicies for cluster.             no
allctx                   Run commands on contexts in your kubeconfig           no
apparmor-manager         Manage AppArmor profiles for cluster.                 no
applier                  Apply 'go text/template' files on k8s.                no
assert                   Assert Kubernetes resources                           no
auth-proxy               Authentication proxy to a pod or service              no
aws-auth                 Manage aws-auth ConfigMap                             no
...........................................

If you are searching for some specific plugin then you can simply grep it by using kubectl krew search | grep -i nsenter command as shown below.

cyberithub@ubuntu:~$ kubectl krew search | grep -i nsenter
nsenter Run shell command in Pod's namespace on the nod... no

 

Example 3: How to Install a Plugin

If you are looking to install a plugin, then you need to use kubectl krew install <plugin_name> syntax. In below example, we are installing a plugin called nsenter using kubectl krew install nsenter command as shown below.

cyberithub@ubuntu:~$ kubectl krew install nsenter
Updated the local copy of plugin index.
Installing plugin: nsenter
Installed plugin: nsenter
\
| Use this plugin:
| kubectl nsenter
| Documentation:
| https://github.com/pabateman/kubectl-nsenter
| Caveats:
| \
| | * This plugin needs SSH access to nodes
| | * Remote user must have root access
| | * Nodes need to have 'nsenter'
| /
/
WARNING: You installed plugin "nsenter" from the krew-index plugin repository.
These plugins are not audited for security by the Krew maintainers.
Run them at your own risk.

 

Example 4: How to Use a Installed Plugin

If you are looking to use an installed plugin then you need to use it like below. Here we have a plugin called nsenter installed in our local system. We are using it to get the hostname of pod my-nginx-66b6c48dd5 using kubectl nsenter -u vagrant my-nginx-66b6c48dd5-m4w8b hostname command as shown below.

cyberithub@ubuntu:~$ kubectl nsenter -u vagrant my-nginx-66b6c48dd5-m4w8b hostname

 

Example 5: How to Upgrade Plugins

If you are looking to upgrade your installed plugins to the latest version then you need to use kubectl krew upgrade command as shown below.

cyberithub@ubuntu:~$ kubectl krew upgrade
Updated the local copy of plugin index.
Upgrading plugin: krew
Skipping plugin krew, it is already on the newest version

 

Example 6: How to Check Information about an available Plugin

If you want to know about an available plugin then you need to use kubectl krew info <plugin_name> syntax. Here we are checking complete information about nsenter plugin using kubectl krew info nsenter command as shown below.

cyberithub@ubuntu:~$ kubectl krew info nsenter
NAME: nsenter
INDEX: default
URI: https://github.com/pabateman/kubectl-nsenter/releases/download/v0.2.3/kubectl-nsenter-linux-amd64.tar.gz
SHA256: 356d5c7974a870bf692bbfb065fcc27220b48df371712574aff5fe175b84e9a0
VERSION: v0.2.3
HOMEPAGE: https://github.com/pabateman/kubectl-nsenter
DESCRIPTION:
This plugin establishes a connection to node that's running the Pod over SSH and uses
nsenter to run commands in the container's namespace. You would need something
like this to run programs that are missing in the container image but presents on node.

CAVEATS:
\
| * This plugin needs SSH access to nodes
| * Remote user must have root access
| * Nodes need to have 'nsenter'
/

 

Example 7: How to List all installed Plugins

To check all the installed plugins, you need to use kubectl krew list command as shown below. This will show the plugins with its installed version.

cyberithub@ubuntu:~$ kubectl krew list
PLUGIN   VERSION
krew     v0.4.3
nsenter  v0.2.3

 

Example 8: How to Check the Version and Diagnostics

To check krew install path and other related information, you can run kubectl krew version command as shown below. This will show some of the important information such as Git Tag version, Git Commit value, Index URI, Base Path, Index Path, Binary Path and Detected Platform.

cyberithub@ubuntu:~$ kubectl krew version
OPTION            VALUE
GitTag            v0.4.3
GitCommit         dbfefa5
IndexURI          https://github.com/kubernetes-sigs/krew-index.git
BasePath          /home/cyberithub/.krew
IndexPath         /home/cyberithub/.krew/index/default
InstallPath       /home/cyberithub/.krew/store
BinPath           /home/cyberithub/.krew/bin
DetectedPlatform  linux/amd64

 

Example 9: How to List Configured Indexes

If you are looking to list our the configured indexes then you need to run kubectl krew index list command as shown below.

cyberithub@ubuntu:~$ kubectl krew index list
INDEX    URL
default  https://github.com/kubernetes-sigs/krew-index.git

 

Example 10: How to Uninstall a Plugin

Once you are done using a plugin, you can simply uninstall it from your system by using kubectl krew uninstall <plugin_name> syntax. In below example, we are uninstalling nsenter plugin by using kubectl krew uninstall nsenter command as shown below.

cyberithub@ubuntu:~$ kubectl krew uninstall nsenter
Uninstalled plugin: nsenter

Leave a Comment