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

Default value ignore in substitute #1350

Open
yodamad opened this issue Jan 30, 2025 · 1 comment
Open

Default value ignore in substitute #1350

yodamad opened this issue Jan 30, 2025 · 1 comment

Comments

@yodamad
Copy link

yodamad commented Jan 30, 2025

Hi,

I'm trying to use substitute mechanism with a default value.

Current version of flux : ghcr.io/fluxcd/kustomize-controller:v1.4.0

So I defined a Namespaceobject :

---
apiVersion: v1
kind: Namespace
metadata:
  name: ${frontend_ns_name:=dev}

And define my GitRepository and Kustomization but without overriding the default value for my default env.

---
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
  name: commons-gitops
  namespace: flux-system
spec:
  interval: 1m0s
  ref:
    branch: feat/fluxcd
  timeout: 60s
  url: https://gitlab.com/xxx/demo/manifests.git
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: flux-demo-frontend
  namespace: flux-system
spec:
  interval: 1m0s
  path: ./frontend
  prune: true
  sourceRef:
    kind: GitRepository
    name: commons-gitops

When Flux try to reconcile the information, it fails explaining that the value is not valid :

Reconciliation failed after 150.548712ms, next try in 1m0s","controller":"kustomization","controllerGroup":"kustomize.toolkit.fluxcd.io","controllerKind":"Kustomization","Kustomization":{"name":"flux-demo-frontend","namespace":"flux-system"},"namespace":"flux-system","name":"flux-demo-frontend","reconcileID":"5ed498e8-b838-42e1-8d82-dc6671ae7f3a","revision":"feat/fluxcd@sha1:4aa0ecf8882974ab1c8670e457f6ff6cb26544a9
[...]
"Namespace/${frontend_ns_name:=dev} dry-run failed (Invalid): Namespace \"${frontend_ns_name:=dev}\" is invalid: [metadata.name: Invalid value: \"${frontend_ns_name:=dev}\": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-' ...

Don't know what I'm doing wrong here as I think that I follow correctly the doc sample

@yodamad
Copy link
Author

yodamad commented Jan 30, 2025

If I add the configuration :

  postBuild:
    substitute:
      frontend_ns_name: "dev"

It works, but I suppose that default value should work without this

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

1 participant