Extend kubectl with a Custom Image-Inspection Plugin
Scenario
The platform team operates several clusters and wants a fast way to audit
which container images are running and how much node storage they occupy.
A script that functions as a kubectl plugin has been written and
downloaded to this node. Your job is to install it correctly so that
kubectl images works from any directory.
The script has already been downloaded to /home/laborant/image.sh — you
don't need to fetch it yourself.
Task
- Install
/home/laborant/image.shas akubectlplugin so that the commandkubectl imagesworks from any directory.
Hint 1 — How kubectl Plugin Discovery Works
kubectl finds plugins by scanning every directory listed in $PATH for
executables whose names start with kubectl-. The part after the hyphen
becomes the subcommand name.
For example, a file named kubectl-images anywhere in your PATH and
marked executable turns kubectl images into a valid command.
Common install targets that are already in PATH:
/usr/local/bin//usr/bin/
Note that /usr/local/bin is owned by root, so you'll need sudo to
copy a file into it.
Documentation
Hint 2 — Install the Plugin
You need to copy the script to a directory in PATH under the correct
plugin name, then ensure it is executable:
sudo cp /home/laborant/image.sh /usr/local/bin/kubectl-______
sudo chmod +x /usr/local/bin/kubectl-______
Fill in the blank with the plugin name that makes kubectl images work.
Verify with kubectl images --help before moving on.
Hint 3 — Confirm It Actually Works
--help only proves that kubectl found the plugin — it doesn't prove
the plugin works against the cluster. Try the real report:
kubectl images -A --no-interactive
If you see an error about jq not being found, that's a missing
dependency on the machine, not a mistake in how you installed the
plugin — the plugin itself only needs to be copied and made executable.