Coder Social home page Coder Social logo

nikhilsbhat / helm-images Goto Github PK

View Code? Open in Web Editor NEW
49.0 5.0 11.0 395 KB

Helm plugin to fetch all possible images from the chart before deployment or from a deployed release

Home Page: https://artifacthub.io/packages/helm-plugin/images/images

License: MIT License

Makefile 5.18% Go 88.01% Shell 4.32% Mustache 2.49%
helm helm-plugin helm-plugins helm-images images registry golang helm-extensions kubernetes

helm-images's Introduction

Hi there, I'm Nikhil Bhat ๐Ÿ‘‹

I'm a passionate DevOps Engineer and an open-source enthusiast.

nikhilsbhat

About Me

  • ๐ŸŒŸ Creator of helm-images, helm-drift, and etc.
  • ๐Ÿ’ป Experienced in Kubernetes, Helm, Terraform, and Docker.
  • ๐Ÿ› ๏ธ Focused on building scalable and resilient infrastructure.
  • ๐Ÿน Enthusiastic about Go programming language.

Projects

Helm Plugins
  • helm-images: A Helm plugin to manage container images in your Helm charts.
  • helm-drift: A Helm plugin to detect drifts between your Helm releases and the Kubernetes cluster.
Other Notable Projects
  • k3d-terraform-provider: A Terraform provider for managing K3D clusters.
  • gocd-terraform-provider: A Terraform provider for managing GoCD resources.
  • terragen: A tool for scaffolding Terraform providers.

ย nikhilsbhat ย  ย  ย  nikhilsbhat


helm-images's People

Contributors

blazs3fs avatar dependabot[bot] avatar itayporezky avatar nikhilsbhat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

helm-images's Issues

problem to extract images from cluster-autoscaler helm chart

Hi Nikhil Bhat,

i am using your plugin to synchronise a private helm registry with newest versions available online. All is fine, except for a specific chart that we are using called "cluster-autoscaler" (used to vertically provision new nodes on a kubernetes cluster).
{"name": "cluster-autoscaler", "url": "https://kubernetes.github.io/autoscaler"}
No image is extracted from this one. It seems the code is not parsing the deployment.yaml template. When i remove the "if" condition at the beginning of the template it works:

{{- if or ( or .Values.autoDiscovery.clusterName .Values.autoDiscovery.labels ) .Values.autoscalingGroups }}
{{/* one of the above is required */}}
apiVersion: {{ template "deployment.apiVersion" . }}
kind: Deployment
metadata:

Best regards,

Franรงois

Handle the case where "metadata" key is not present

In kub-prometheus-stack, there is a List entry which has no metadata field and this makes the plugin crash.

Proposal would be to update the Get function like so (in k8s.go, line 81):

func (name *Name) Get(dataMap string) (string, error) {
	var kindYaml map[string]interface{}
	if err := yaml.Unmarshal([]byte(dataMap), &kindYaml); err != nil {
		return "", err
	}

	if len(kindYaml) != 0 {

		metadata, metadataExists := kindYaml["metadata"].(map[string]interface{})
		if !metadataExists {
			return "", &ImageError{Message: "failed to get 'metadata' from the manifest"}
		}

		value, failedManifest := kindYaml["metadata"].(map[string]interface{})["name"].(string)
		if !failedManifest {
			return "", &imgErrors.ImageError{Message: "failed to get name from the manifest, 'name' is not type string"}
		}

		return value, nil
	}

	return "", nil
}

--no-color should be the default

I was using this plugin in our deployment pipeline and with the latest update the --no-color broke our automation as we didn't know we need to explicitly turn it off since we are piping through jq. IMO by default the color should be off, to where you have to explicitly turn it on.

Just a thought

Missing images from kube-prom-stack

Hello,

Is it possible to get the images from Charts like: prometheus-community/kube-prometheus-stack which heavily use CRDs ?
https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack

By the output of

> helm images get --set alertmanager.enabled=true prometheus prometheus-community/kube-prometheus-stack
quay.io/prometheus/node-exporter:v1.5.0
quay.io/kiwigrid/k8s-sidecar:1.22.0
quay.io/kiwigrid/k8s-sidecar:1.22.0
docker.io/grafana/grafana:9.5.1
registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.8.2
quay.io/prometheus-operator/prometheus-operator:v0.65.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%      

I think that many images are not listed, like alertmanager's

Is it some config issue or unsupported case?

Update to 0.1.5 through helm plugin does not work

Looks like the 0.1.5 is pointing to 0.1.4:

helm plugin install https://github.com/nikhilsbhat/helm-images --version 0.1.5
Installing helm-images...
download url set to https://github.com/nikhilsbhat/helm-images/releases/download/v0.1.4/helm-images_0.1.4_Linux_x86_64.tar.gz

artifact name with path /home/sboutet/.local/share/helm/plugins/helm-images/helm-images.tar.gz

downloading https://github.com/nikhilsbhat/helm-images/releases/download/v0.1.4/helm-images_0.1.4_Linux_x86_64.tar.gz to /home/sboutet/.local/share/helm/plugins/helm-images

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 14.8M  100 14.8M    0     0  10.9M      0  0:00:01  0:00:01 --:--:-- 24.6M
successfully download the archive proceeding to install

HELM_PLUGIN_ARTIFACT_PATH: /xxx/helm-images/helm-images.tar.gzPreparing to install into /xxx/plugins/helm-images

install on debian arm64 fails (tries to use aarch64 instead of arm64)

running on debian on arm-m1

helm plugin install https://github.com/nikhilsbhat/helm-images

errors out with

Installing helm-images...
download url set to https://github.com/nikhilsbhat/helm-images/releases/download/v0.1.0/helm-images_0.1.0_Linux_aarch64.tar.gz

artifact name with path /root/.local/share/helm/plugins/helm-images/helm-images.tar.gz

downloading https://github.com/nikhilsbhat/helm-images/releases/download/v0.1.0/helm-images_0.1.0_Linux_aarch64.tar.gz to /root/.local/share/helm/plugins/helm-images

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404 
failed while downloading helm archive

Failed to install helm images
Error: plugin install hook for "images" exited with error
The command '/bin/bash -o pipefail -x -c /var/opt/kar/installers/deb/k8s.helm-plugins.sh' returned a non-zero code: 1

Since the files listed in releases have arm64 instead of aarch64, this is prob the cause.

cert-manager-acmesolver image not found by helm image plugin

The cert-manager chart contains cert-manager-acmesolver which is not deployed immediately upon chart installation. Helm images plugin does not list it. Is this expected? Is this an bug with helm images plugin or with the helm chart (cert-manager). Any workaround?

Below the output in order to reproduce:

helm repo add jetstack https://charts.jetstack.io
helm repo update
helm pull jetstack/cert-manager

The values.yaml contains:
acmesolver:
image:
repository: quay.io/jetstack/cert-manager-acmesolver

However this image is not listed:

helm images get cert-manager cert-manager-v1.12.3.tgz -f cert-manager/values.yaml --unique
quay.io/jetstack/cert-manager-cainjector:v1.12.3
quay.io/jetstack/cert-manager-controller:v1.12.3
quay.io/jetstack/cert-manager-webhook:v1.12.3
quay.io/jetstack/cert-manager-ctl:v1.12.3

Handle images in HelmChartConfig

For my use case, I have a HelmChartConfig template that edits the default configuration for the Traefik instance in my clusters. It seems that helm-images is not able to get the images inside of that object type.

Here is an example:

apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
  name: traefik
  namespace: kube-system
spec:
  valuesContent: |-
    deployment:
      kind: DaemonSet
      additionalContainers:
        - name: nxlog
          image: {{ tpl .Values.log.images.nxlog . | replace "//" "/" }}
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          env:
            - name: "PUID"
              value: "65532"
            - name: "GUID"
              value: "65532"
          volumeMounts:
            - name: fifo-logs
              mountPath: /logs
            - name: traefik-nxlog-config
              mountPath: /etc/nxlog/nxlog.conf
              subPath: nxlog.conf

In this case, the images in the valuesContent are not handled. Could this be added?

Thanks!

Get images from chart registry

I've been thinking about writing something that does exactly what your plugin does. Thank you for making it open.

It seems to me that I have to either have a chart locally or have it installed to get the images.

Is there a way to get the images from a chart that is not installed. My use case is that before I install a chart, I may need to get a list of all images the chart uses and pull those into my own registry. My cluster may not let me install from public, so in this case I would not have a release in cluster to get the images from.

I was looking for something like:

helm images get oci://my-repo/charts/my-chart

Where the [RELEASE] is not required as part of the command.

"image" in a configmap triggers output

Bug description

It seems that occurrences of the word image in the configmap data trigger the parsing.

How to reproduce

Given the following configmap in a test chart:

apiVersion: v1
kind: ConfigMap
metadata:
  name: test
data:
  test.yml: |
    foo_image_bar: SHOLD_NOT_PRINT_THIS

Get the list of images:

$ helm images get release ./test
SHOLD_NOT_PRINT_THIS

Version

0.1.5

Failure if ConfigMap contains a stringified json array

If a helm chart contains

apiVersion: v1
kind: ConfigMap
metadata:
  name: datasources-json
data:
  default-datasources.json.template: |
    [
      {
        "name": "virtu",
        "type": "foo"
      },
      {
        "name": "foolist",
        "type": "bar"
      }
    ]

helm images get fails with

$ helm images get -l debug ./helm-chart
{"level":"debug","msg":"looks like no release name specified, hence it would be set to 'sample' by default","time":"2024-03-13T08:29:00+01:00"}
{"level":"debug","msg":"got all required values to fetch the images from chart/release 'sample' proceeding furter to fetch the same","time":"2024-03-13T08:29:00+01:00"}
{"level":"debug","msg":"fetching manifests for 'sample' by rendering helm template locally","time":"2024-03-13T08:29:00+01:00"}
{"level":"debug","msg":"rendering helm chart with following commands/flags 'template, sample, ./helm-chart, --set, global.keycloak.address=example.cm, --debug'","time":"2024-03-13T08:29:00+01:00"}
{"level":"debug","msg":"running following command to render the helm template: /usr/local/bin/helm template sample ./helm-chart --set global.keycloak.address=example.cm --debug","time":"2024-03-13T08:29:00+01:00"}
{"level":"debug","msg":"splitting helm manifests with regex pattern: '---\\n# Source:\\s.*.'","time":"2024-03-13T08:29:00+01:00"}
{"level":"debug","msg":"either helm-images plugin does not support kind 'Secret' at the moment or manifest might not have images to filter","time":"2024-03-13T08:29:00+01:00"}
{"level":"debug","msg":"either helm-images plugin does not support kind 'Secret' at the moment or manifest might not have images to filter","time":"2024-03-13T08:29:00+01:00"}
{"level":"debug","msg":"fetching images from kind 'ConfigMap'","time":"2024-03-13T08:29:00+01:00"}
Error: json: cannot unmarshal array into Go value of type map[string]interface {}
2024/03/13 08:29:00 cmd.go:22: json: cannot unmarshal array into Go value of type map[string]interface {}
Error: plugin "images" exited with error

Helm images version: {"version":"0.1.3","revision":"2f7926e1f7461e2819e39fff2b04a3cf5dfcac8e","environment":"production","build-date":"2024-03-12T04:14:40Z","go-version":"go1.22.0","platform":"linux/amd64"}

Error converting YAML to JSON

The images plugin doesn't seem to work with my Helm chart.

$ helm repo add hedera https://hashgraph.github.io/hedera-mirror-node/charts
$ helm images get hedera/hedera-mirror
Error: deserializing yaml data of configmap errored with 'error converting YAML to JSON: yaml: line 3: did not find expected alphabetic or numeric character'
2024/05/14 22:52:24 cmd.go:22: deserializing yaml data of configmap errored with 'error converting YAML to JSON: yaml: line 3: did not find expected alphabetic or numeric character'
Error: plugin "images" exited with error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.