fluxcd / flux2-kustomize-helm-example

A GitOps workflow example for multi-env deployments with Flux, Kustomize and Helm.
https://fluxcd.io
Apache License 2.0
935 stars 992 forks source link

How to integrate ImageUpdateAutomation #27

Closed hobbsh closed 3 years ago

hobbsh commented 3 years ago

Hi,

First of all, thank you for your amazing work on this! I have based our flux2+kustomize repo on this and am wondering how I would integrate ImageUpdateAutomation to this? I have been unsuccessful getting it to work, which I'm starting to think may be related to this: https://github.com/fluxcd/flux2/discussions/1207. It's also likely an implementation error so let me explain my setup:

ImageUpdateAutomation in infrastructure

infrastructure/base/gitops-toolkit
├── image-update-automation.yaml
├── kustomization.yaml
├── notifications.yaml
└── secrets.yaml

The spec is very standard, with the path omitted (it's patched in infrastructure/<env>/image-update-automation-patch.yaml. The resource within the cluster includes the path

apiVersion: image.toolkit.fluxcd.io/v1alpha2
kind: ImageUpdateAutomation
metadata:
  name: flux-system
  namespace: flux-system
spec:
  interval: 1m0s
  sourceRef:
    kind: GitRepository
    name: flux-system
  git:
    checkout:
      ref:
        branch: main
    commit:
      author:
        email: fluxcdbot@users.noreply.github.com
        name: fluxcdbot
      messageTemplate: '{{range .Updated.Images}}{{println .}}{{end}}'
    push:
      branch: main
  update:
    strategy: Setters
    # path: ./clusters/development # Patched in environment

The anticipated target is a HelmRelease in services/company/portal/release.yaml. I have tried adding the image policy marker in the deployment of the helm chart itself, in the HelmRelease, and in the Kustomization images: [] field, but nothing is working. I see that the image policies in the cluster are up to date with the latest matching tags, so it just seems like the image-automation-controller is not doing its job. This makes me think the policy markers are not being seen or making it into the cluster. There are no logs coming out of the image-automation-controller that indicate its erroring or doing any work at all.

services
├── company
│   └── portal
│       ├── image-policy.yaml
│       ├── image-repo.yaml
│       ├── kustomization.yaml
│       ├── namespace.yaml
│       ├── notifications.yaml
│       ├── release.yaml
│       └── secrets.yaml
├── development
│   ├── image-policy-patches.yaml
│   ├── image-repo-patches.yaml
│   ├── kustomization.yaml
│   ├── release-patches.yaml
│   └── secret-patches.yaml
hobbsh commented 3 years ago

The problem ended up being this issue: https://github.com/fluxcd/image-automation-controller/pull/157 as I was creating the image policies/repos in the service's namespace. Hopefully this becomes a thing soon and thank you again for your great work!