Using kubectl, how might one retrieve a list of packages installed in a container image? Using kubectl, how might one retrieve a list of packages installed in a container image? kubernetes kubernetes

Using kubectl, how might one retrieve a list of packages installed in a container image?


This is possible by using kubectl exec. For example, here I am retrieving the version of dnf running in my example CentOS 7 container.

$> kubectl exec example-67575f5dfb-xw2qz -- dnf --version4.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:

$> kubectl exec example-67575f5dfb-xw2qz -- dnf list allLast metadata expiration check: 0:10:30 ago on Mon Mar 30 03:13:10 2020.Installed Packagesacl.x86_64                                           2.2.53-1.el8                                      @Systemaudit-libs.x86_64                                    3.0-0.10.20180831git0047a6c.el8                   @Systembasesystem.noarch                                    11-5.el8                                          @System>SNIP<


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.


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