How would someone use kubectl
to retrieve information about installed packages in a container image? For example, how would you find the version of an installed package? Or list all of the packages installed on the system?
I'm searching for a similar command to docker inspect.
This is possible by using kubectl exec. For example, here I am retrieving the version of dnf
running in my example CentOS 7 container.
gt; kubectl exec example-67575f5dfb-xw2qz -- dnf --version
4.2.7
Installed: dnf-0:4.2.7-7.el8_1.noarch at Mon Jan 13 21:49:19 2020
Built : CentOS Buildsys <bugs@centos.org> at Thu Dec 19 15:44:23 2019
Installed: rpm-0:4.14.2-25.el8.x86_64 at Mon Jan 13 21:49:16 2020
Built : CentOS Buildsys <bugs@centos.org> at Fri Nov 8 22:56:14 2019
Here's another example showing how to grab all of the installed packages on the image:
gt; kubectl exec example-67575f5dfb-xw2qz -- dnf list all
Last metadata expiration check: 0:10:30 ago on Mon Mar 30 03:13:10 2020.
Installed Packages
acl.x86_64 2.2.53-1.el8 @System
audit-libs.x86_64 3.0-0.10.20180831git0047a6c.el8 @System
basesystem.noarch 11-5.el8 @System
>SNIP<
Please go through the kubectl docs. you should be able to interact with the cluster and able to collect required information.
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands
There is no equivalent to that. Kubernetes has a somewhat arms length relationship to containers. Most of the complex bits are delegates to the CRI plugin so K8s itself doesn’t know anything about images at all.