0

Helmfile:

spec:
      containers:
        - name: {{ .Values.app.name }}
          image: {{ .Values.image.name }} --> execute shell script here
          imagePullPolicy: Always
          ports:
            - containerPort: 8081
          env:
            - name: BACKEND_HOST
              value: {{ .Values.backend.host }}

I want to execute bash script to check if this image exists. If not, than other image would be taken. How to do it with helm? Or is there any solution to do it?

Fagam32
  • 83
  • 1
  • 7

1 Answers1

0

Helm doesn't have any way to call out to other processes, make network connections, or do any other sort of external lookup (with one specific exception where it can read Kubernetes objects out of the cluster). You'd have to pass this value in when you run the helm install command instead:

helm install release-name ./chart-directory \
  --set image.name=$(the command you want to run)

If this is getting run from part of some larger process, you may find it easier to write a JSON or YAML file that can be passed to the helm install -f option instead of dynamically calling out to the script; the helm install --set option has some unusual syntax and behavior. You can even go one step further and check that per-installation YAML file into source control, and have another step in your deployment pipeline notice the commit and actually do the installation ("GitOps" style).

David Maze
  • 130,717
  • 29
  • 175
  • 215