Skip to content

Have an optionalFiles field in secretGenerator #5903

Open
@sei-areuter

Description

@sei-areuter

Eschewed features

  • This issue is not requesting templating, unstuctured edits, build-time side-effects from args or env vars, or any other eschewed feature.

What would you like to have added?

Not sure if many other people have faced this issue, but we have a secret that we need to mount into our kustomize deployment if it exists. If not then the deployment can disregard it. I was wondering if there would be any value in setting up something like the following in the kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - ns.yaml
  - rbac.yaml
  - deployment.yaml
configMapGenerator:
  - name: test-deployment
     files:
    - state-values.yaml
secretGenerator:
  - name: ace-secrets
    files:
    - secret-values.yaml
    optionalFiles:                   # new feature. IF any files under this key do not exist then still deploy
    - LDAP_PASSWORD=./secrets/gitlab/ldap/password
namespace: test-deployment-system

Why is this needed?

If we need optional configs in our deployment depending on where our kustomizes get deployed then this is needed

Example: Gitlab has support for ldap single-sign on. We want to use this in certain environments and need to mount the password. In other environments we don't have LDAP support and don't want to use the password

Can you accomplish the motivating task without this feature, and if so, how?

Technically yes. At the moment I am just creating a blank file. It is a hacky solution, but it would work for us

What other solutions have you considered?

if kustomize had env support we could wrap that section so it isn't deployed (don't want to create this file with a bash script)

I know this goes against kustomize so I am not suggesting support for this solution - if there was a way to accomplish this using patching then that is a valid solution

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - ns.yaml
  - rbac.yaml
  - deployment.yaml
configMapGenerator:
  - name: test-deployment
     files:
    - state-values.yaml
secretGenerator:
  - name: ace-secrets
    files:
    - secret-values.yaml
    {{ if $LDAP_ENABLED }}
   - LDAP_PASSWORD=./secrets/gitlab/ldap/password
   {{ end }}
namespace: test-deployment-system

Anything else we should know?

No response

Feature ownership

  • I am interested in contributing this feature myself! 🎉

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions