Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kustomize rips ImagePolicy comment from image definition #2633

Closed
1 task done
alec-eu opened this issue Apr 12, 2022 · 3 comments
Closed
1 task done

Kustomize rips ImagePolicy comment from image definition #2633

alec-eu opened this issue Apr 12, 2022 · 3 comments

Comments

@alec-eu
Copy link

alec-eu commented Apr 12, 2022

Describe the bug

base/podinfo/deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: podinfo
spec:
  template:
    spec:
      containers:
        - name: account-web
          image: XXXXXXXXXX.dkr.ecr.us-west-2.amazonaws.com/podinfo:754754b # {"$imagepolicy": "flux-system:podinfo"}

demo/podinfo/kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base/podinfo
- podinfo-config.yaml

namespace: demo

I am aware of #1522, however I properly indented the spec and it is still removing the comment.

Steps to reproduce

  1. Install flux with image controllers
  2. Create a base deployment.yaml that includes an image policy reference
  3. Reference that base in a different location, and run kustomize

Expected behavior

The image policy comment should be appended to the image definition

Screenshots and recordings

No response

OS / Distro

N/A

Flux version

v0.28.4

Flux check

N/A

Git provider

GitHub

Container Registry provider

ECR

Additional context

The one thought I had is the line length - since it is using an image from ECR, the line is fairly long with the comment included. So far I have not found any damning evidence that this is the cause, however

Code of Conduct

  • I agree to follow this project's Code of Conduct
@stefanprodan
Copy link
Member

kustomize the CLI, removes all comments on build. You need to set the image policy comment in the Flux Kustomization object that reconciles the app on the cluster, like so:

apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
  name: podinfo
  namespace: default
spec:
  images:
    - name: ghcr.io/stefanprodan/podinfo
      newName: ghcr.io/stefanprodan/podinfo
      newTag: 5.0.0 # {"$imagepolicy": "flux-system:podinfo:tag"}

Docs here: https://fluxcd.io/docs/guides/image-update/#configure-image-update-for-custom-resources

@alec-eu
Copy link
Author

alec-eu commented Apr 12, 2022

Thanks @stefanprodan . My only follow up - currently those flux Kustomizations are not in YAML. I have exported the YAML but am unsure if I can put it in the gotk-sync.yaml file as it explicitly says "DO NOT EDIT". Should I put them in another file in that directory?

@stefanprodan
Copy link
Member

The flux-system Kustomization should only apply other Flux Kustomizations not apps directly. Also you don't need to run kustomize build on your repo, Flux does that in-cluster for you. See here how to organise repos: https://github.com/fluxcd/flux2-kustomize-helm-example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants