kustomize-controller icon indicating copy to clipboard operation
kustomize-controller copied to clipboard

Postbuild substitution should substitute when kustomization have no substitution defined

Open NFRBEZ opened this issue 7 months ago • 5 comments

Postbuild substitution is not working when there is no substitution in kustomization :

For example, the following kustomization

---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
  name: my-app
  namespace: flux-system
spec:
  path: ./apps/staging/my-app
  targetNamespace: my-app
  interval: 1m
  prune: true
  sourceRef:
    kind: GitRepository
    name: flux-system
  healthChecks:
    - apiVersion: helm.toolkit.fluxcd.io/v2beta1
      kind: HelmRelease
      name: my-app
      namespace: my-app

Generate me the following ressource

---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  labels:
    kustomize.toolkit.fluxcd.io/name: my-app
    kustomize.toolkit.fluxcd.io/namespace: flux-system
  name: my-app
  namespace: my-app
spec:
  chart:
    ...
  values:
    metricsServer:
      dnsPolicy: ${dnsPolicy:=ClusterFirst}
      useHostNetwork: ${hostnetwork:="false"}
...

Which result on problem with my release installation I need to add at least one postBuild argument to make the substitution occurs, even If it is not referred in my ressources So doing like this :

---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
  name: my-app
  namespace: flux-system
spec:
  path: ./apps/staging/my-app
  targetNamespace: my-app
  interval: 1m
  prune: true
  sourceRef:
    kind: GitRepository
    name: flux-system
  healthChecks:
    - apiVersion: helm.toolkit.fluxcd.io/v2beta1
      kind: HelmRelease
      name: my-app
      namespace: my-app
  postBuild:
    substitute:
      foo: bar

will work well :

---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  labels:
    kustomize.toolkit.fluxcd.io/name: my-app
    kustomize.toolkit.fluxcd.io/namespace: flux-system
  name: my-app
  namespace: my-app
spec:
  chart:
    ...
  values:
    metricsServer:
      dnsPolicy: ClusterFirst
      useHostNetwork: "false"
...

NFRBEZ avatar Nov 15 '23 14:11 NFRBEZ