fluxcd / flux

Successor: https://github.com/fluxcd/flux2
https://fluxcd.io
Apache License 2.0
6.9k stars 1.08k forks source link

Init Container Image Auto Release #3574

Closed jlevertov closed 2 years ago

jlevertov commented 2 years ago

Describe the bug

Hi, I am using flux with helm operator in Kubernetes. I have a helm chart with an init container. when I release a new version of the init container's image, Flux doesn't create a commit to my git repo with update of the new image's tag. In all other cases Flux works perfectly, detects a new image, commits the change to my git repo, syncs and reconfigures the helmrelease with the new version. Is this a bug or am I missing something with the structure or variables?

Steps to reproduce

I am using flux kubernetes deployment, deployed using Helm chart. Flux docker version: 1.22.2 My deployment's init container definition looks like this:

initContainers:
      - name: {{ .Values.initContainers.name }}
        image: {{ .Values.image.registry}}/{{ .Values.initContainers.image.repository }}:{{ .Values.initContainers.image.tag }}
        imagePullPolicy: {{ .Values.image.pullPolicy }}

My Values.yaml:

image:
  registry: <my private registry>
  repository: <my-repo>/<main pod container image>
initContainers:
  image:
    repository: <my-repo>/<pod init container image>
    tag: latest

My HelmRelease

...
spec:
  <my chart's name>:
    initContainers:
      image:
        repository: <my-repo>/<pod init container image>
        tag: <latest tag (not "latest")>

Expected behavior

When a new init container image version is released, fluxcd should detect that there is a new version, commit a change to my helmrelease with an update to the initContainrs.image.tag field and deploy the updated file to the kubernetes for helm operator to update the helm release

Kubernetes version / Distro / Cloud provider

kubernetes 1.19/GKE

Flux version

Flux 1.22.2/flux helm chart version 1.9.0

Git provider

github

Container Registry provider

gcr

Additional context

No response

Maintenance Acknowledgement

Code of Conduct

stefanprodan commented 2 years ago

You need to tell Flux the json path where the image is, please see the docs here: https://fluxcd.io/legacy/flux/references/helm-operator-integration/#annotations

jlevertov commented 2 years ago

Thank you very much it solved the problem! :)