nikhilsbhat / helm-images

Helm plugin to fetch all possible images from the chart before deployment or from a deployed release
https://artifacthub.io/packages/helm-plugin/images/images
MIT License
59 stars 12 forks source link

Recognize and extract kube-prometheus-stack images provided via container args #21

Closed blazs3fs closed 8 months ago

blazs3fs commented 8 months ago

Reason for PR

helm-images does not recognize the prometheus-config-reloader and thanos images provided via container arguments. This PR adds and additional check and append the additional images to the final output.

I've first tried to resolve this issue with the kube-prometheus-stack maintainers and they also opened an issue with artifact.hub but unfortunately it was closed. More about the discussion can be read here and here.

Other fixes

When I tried building the project with the make local.build command failed and after some investigation on how goreleaser works I've also implemented some build process fixes. Please see commits for details.

Test procedure for container image extraction fix

Download kube-prometheus-stack and extract it (not the newest version, but this is the one I tested with)

$ curl -sLO https://github.com/prometheus-community/helm-charts/releases/download/kube-prometheus-stack-51.10.0/kube-prometheus-stack-51.10.0.tgz
$ tar xf kube-prometheus-stack-51.10.0.tgz

Extract images without fix

$ helm images get prometheus-community kube-prometheus-stack -f kube-prometheus-stack/values.yaml
quay.io/prometheus/node-exporter:v1.6.1
quay.io/kiwigrid/k8s-sidecar:1.25.1
quay.io/kiwigrid/k8s-sidecar:1.25.1
docker.io/grafana/grafana:10.1.5
registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.10.0
quay.io/prometheus-operator/prometheus-operator:v0.68.0
quay.io/prometheus/alertmanager:v0.26.0
quay.io/prometheus/prometheus:v2.47.1
docker.io/bats/bats:v1.4.1
registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20221220-controller-v1.5.1-58-g787ea74b6
registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20221220-controller-v1.5.1-58-g787ea74b6

Extract images with fix (I am using an ARM based Mac, so I chose the darwin_arm64 binary)

$ export HELM_BIN=$(which helm)
$ make local.snapshot
$ ./dist/helm-images_darwin_arm64/helm-images get prometheus-community kube-prometheus-stack -f kube-prometheus-stack/values.yaml
quay.io/prometheus/node-exporter:v1.6.1
quay.io/kiwigrid/k8s-sidecar:1.25.1
quay.io/kiwigrid/k8s-sidecar:1.25.1
docker.io/grafana/grafana:10.1.5
registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.10.0
quay.io/prometheus-operator/prometheus-operator:v0.68.0
quay.io/prometheus-operator/prometheus-config-reloader:v0.68.0
quay.io/thanos/thanos:v0.32.4
quay.io/prometheus/alertmanager:v0.26.0
quay.io/prometheus/prometheus:v2.47.1
docker.io/bats/bats:v1.4.1
registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20221220-controller-v1.5.1-58-g787ea74b6
registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20221220-controller-v1.5.1-58-g787ea74b6

Observe these additional extracted images

blazs3fs commented 8 months ago

I know the argument names are fixed strings but currently there is no other way to detect these to images. Maybe we could find a way to automatically check if the arguments change in the helm template of the kube-prometheus-stack project.

nikhilsbhat commented 8 months ago

@blazs3fs, I'll check both the referenced issues and the changes made by you on helm-images and get back to you.

blazs3fs commented 8 months ago

Hi @nikhilsbhat! Did you have any time to check my PR? I could also split the build fixes into a separate PR if that makes things any easier?

nikhilsbhat commented 8 months ago

@blazs3fs , I'm on a long leave, mostly I will be back next week. I'll check this out once I'm back.