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

ImageUpdateAutomation misinterprets Registry URL when port is defined #858

Open
satriashp opened this issue Mar 4, 2025 · 3 comments
Open

Comments

@satriashp
Copy link

FluxCD's ImageUpdateAutomation is incorrectly parsing the image repository URL when using a local registry (registry.localhost:5000). Instead of properly recognizing the repository and tag, it misinterprets the port number as part of the image name.

To Reproduce

  1. Set up a local registry: http://registry.localhost:5000

  2. Push an image: registry.localhost:5000/sample-web:0.1.0

  3. Define the following ImageRepository:

apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: ImageRepository
metadata:
  name: sample-web
  namespace: flux-system
spec:
  image: registry.localhost:5000/sample-web
  provider: generic
  interval: 1m
  allowInsecure: true

  1. Define ImagePolicy:
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImagePolicy
metadata:
  name: sample-web
  namespace: flux-system
spec:
  imageRepositoryRef:
    name: sample-web
  policy:
    semver:
      range: "0.1.x"

  1. Apply ImageUpdateAutomation
  2. Observe the status of ImageUpdateAutomation:
status:
  observedPolicies:
    sample-web:
      name: registry.localhost
      tag: 5000/sample-web:0.1.1

Expected:
The tag should be 0.1.1, and the repository should remain registry.localhost:5000/sample-web.

Actual:
Flux treats 5000/sample-web as the repository, misplacing the port number.

Expected behavior
FluxCD should correctly interpret the image repository as registry.localhost:5000/sample-web without breaking the tag format.

Environment
FluxCD Version: 2.5.1
Kubernetes Version: v1.32.2
Additional Context:
I'm using k3d to setup kubernetes local cluster
Running Flux with flux-system namespace
Local registry is accessible and works with docker pull registry.localhost:5000/sample-web:0.1.0
Issue persists even with allowInsecure: true
Changing localhost to registry.localhost in /etc/hosts does not fix the issue
Is this a known issue, and is there a workaround?

@matheuscscp
Copy link
Member

How about the statuses of ImageRepository and ImagePolicy, did you notice anything strange on them or is it just ImageUpdateAutomation?

@makkes
Copy link
Member

makkes commented Mar 4, 2025

I would guess the root cause is this code. The good thing is that only the status file is affected but all other functionality should still work as expected.

@satriashp
Copy link
Author

How about the statuses of ImageRepository and ImagePolicy, did you notice anything strange on them or is it just ImageUpdateAutomation?

Here status from 'ImageRepositoty' and 'ImagePolicy', its seem correctly tag image with 0.1.x.

status:
  canonicalImageName: registry.localhost:5000/sample-web
  conditions:
  - lastTransitionTime: "2025-03-15T03:07:37Z"
    message: 'successful scan: found 2 tags'
    observedGeneration: 1
    reason: Succeeded
    status: "True"
    type: Ready
  lastScanResult:
    latestTags:
    - 0.1.1
    - 0.1.0
    scanTime: "2025-03-15T03:07:37Z"
    tagCount: 2
  observedExclusionList:
  - ^.*\.sig$
  observedGeneration: 1
status:
  conditions:
  - lastTransitionTime: "2025-03-15T03:07:37Z"
    message: Latest image tag for 'registry.localhost:5000/sample-web' resolved to
      0.1.1
    observedGeneration: 1
    reason: Succeeded
    status: "True"
    type: Ready
  latestImage: registry.localhost:5000/sample-web:0.1.1
  observedGeneration: 1

I would guess the root cause is this code. The good thing is that only the status file is affected but all other functionality should still work as expected.

I cant tell its related but whenever new image tag being push its not automatically update the deployments.

@makkes makkes changed the title FluxCD ImageUpdateAutomation Misinterprets Registry URL and Tag Describe the bug FluxCD ImageUpdateAutomation misinterprets Registry URL when port is defined Mar 17, 2025
@makkes makkes changed the title FluxCD ImageUpdateAutomation misinterprets Registry URL when port is defined ImageUpdateAutomation misinterprets Registry URL when port is defined Mar 17, 2025
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

3 participants