1
votes

I have a Helm chart that uses Nginx chart as a dependency. Is it possible to specify different repo for pulling the image?

My dependencies:

dependencies:
  - name: nginx-ingress
    version: "3.15.2"
    repository: "https://kubernetes.github.io/ingress-nginx"
    condition: master.ingress.create_controller
    tags:
      - ingressController

What I want to achieve is to make k8s pull image from private Docker registry instead of Docker Hub. I've checked Helm docs, but couldn't find a corresponding parameter. I understand that I can download the chart and change the value inside, but this is my plan B.

1

1 Answers

2
votes

This is possible only if the chart has an option to do it.

If you look at the chart's values.yaml file you can see that it has settings:

controller:
  image:
    repository: k8s.gcr.io/ingress-nginx/controller

And, correspondingly in the Deployment template:

{{- with .Values.controller.image }}
image: "{{.repository}}:{{ .tag }}{{- if (.digest) -}} @{{.digest}} {{- end -}}"
{{- end }}

So when you deploy the chart, you can add to your deploy-time settings

nginx-ingress:
  controller:
    image:
      repository: docker-mirror.example.com/k8s.gcr.io/ingress-nginx/controller

You can also default this in the parent chart.

Different charts handle this in different ways. The Bitnami charts, for example, let you separately specify the registry and image names, and support a global: { imageRegistry: ... } option. (Which is just used via string concatenation, so if you have a path prefix in your local registry mirror, you can include both parts there.)