carvel-dev / kapp

kapp is a simple deployment tool focused on the concept of "Kubernetes application" — a set of resources with the same label
https://carvel.dev/kapp
Apache License 2.0
899 stars 108 forks source link

Add a "kapp images list" command. #240

Open GrahamDumpleton opened 3 years ago

GrahamDumpleton commented 3 years ago

Describe the problem/challenge you have

Want an easy way of being able to list all images used by an application deployment and what top most resource they were specified in, eg., Deployment, DaemonSet, StatefulSet, or if no owner they are created from, then the Pod.

Describe the solution you'd like

Would like to be able to say:

kapp images list -a example

Anything else you would like to add:

There are already commands for:

kapp config-map list -a example
kapp service-account list -a example

This would fit in with how these are possible and have similar sort of result.

The command to list images would be useful when trying to verify the the outcome of image rewrites due to using kbld to map to hash, or when doing image relocation via imgpkg.


Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible" 👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

cc @jorgemoralespou

GrahamDumpleton commented 3 years ago

And am aware that could feed resources into kbld inspect, however would be nice to have self contained solution in kapp itself which provides simplified output. Using kbld inspect it shows images against all resources in chain and not just top most owner, which is what would really care about.

Also, due to #239, you can't do:

kapp inspect --raw -a example | kbld inspect -f-
cppforlife commented 3 years ago

Using kbld inspect it shows images against all resources in chain and not just top most owner, which is what would really care about.

what do you mean by "top most owner" here?

jorgemoralespou commented 3 years ago

what do you mean by "top most owner" here?

With that command:

kapp inspect --raw -a example  --tty=false | kbld inspect -f-

you get all the images for the pods, replicasets and deployments as it's the output of what kapp returns. There's a lot of duplicated values here since we only care for the values of the top level elements, typically Deployments, but any of the 3 that has been actually the resource generated by the user and not the one that the system generated because of the wrapping.

An example output is:

kapp inspect --raw -a educates --tty=false | kbld inspect -f -
Images

Image     gcr.io/google_containers/pause:latest  
Metadata  -  
Resource  controllerrevision/educates-prepull-7bbd48554c (apps/v1) namespace: eduk8s  

Image     gcr.io/google_containers/pause:latest  
Metadata  -  
Resource  daemonset/educates-prepull (apps/v1) namespace: eduk8s  

Image     gcr.io/google_containers/pause:latest  
Metadata  -  
Resource  pod/educates-prepull-7v2tg (v1) namespace: eduk8s  

Image     gcr.io/google_containers/pause:latest  
Metadata  -  
Resource  pod/educates-prepull-7v2tg (v1) namespace: eduk8s  

Image     quay.io/eduk8s/base-environment:210508.015017.4546935  
Metadata  -  
Resource  controllerrevision/educates-prepull-7bbd48554c (apps/v1) namespace: eduk8s  

Image     quay.io/eduk8s/base-environment:210508.015017.4546935  
Metadata  -  
Resource  daemonset/educates-prepull (apps/v1) namespace: eduk8s  

Image     quay.io/eduk8s/base-environment:210508.015017.4546935  
Metadata  -  
Resource  pod/educates-prepull-7v2tg (v1) namespace: eduk8s  

Image     quay.io/eduk8s/base-environment:210508.015017.4546935  
Metadata  -  
Resource  pod/educates-prepull-7v2tg (v1) namespace: eduk8s  

Image     quay.io/eduk8s/eduk8s-operator:develop  
Metadata  -  
Resource  deployment/eduk8s-operator (apps/v1) namespace: eduk8s  

Image     quay.io/eduk8s/eduk8s-operator:develop  
Metadata  -  
Resource  pod/eduk8s-operator-65458598b5-z2fd8 (v1) namespace: eduk8s  

Image     quay.io/eduk8s/eduk8s-operator:develop  
Metadata  -  
Resource  pod/eduk8s-operator-65458598b5-z2fd8 (v1) namespace: eduk8s  

Image     quay.io/eduk8s/eduk8s-operator:develop  
Metadata  -  
Resource  replicaset/eduk8s-operator-65458598b5 (apps/v1) namespace: eduk8s  

12 images

Succeeded

When in reality only 3 images should have been shown as a result of the command we're asking for:

NAMESPACE RESOURCE_TYPE RESOURCE IMAGE
eduk8s deployment eduk8s-operator quay.io/eduk8s/eduk8s-operator:develop
eduk8s daemonset educates-prepull quay.io/eduk8s/base-environment:210508.015017.4546935
eduk8s daemonset educates-prepull gcr.io/google_containers/pause:latest