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

Versioning and env valueFrom does not work in generators #120

Open
lingwooc opened this issue Apr 11, 2022 · 0 comments
Open

Versioning and env valueFrom does not work in generators #120

lingwooc opened this issue Apr 11, 2022 · 0 comments

Comments

@lingwooc
Copy link
Contributor

lingwooc commented Apr 11, 2022

If you do this with a versioned secret:

  components:
    echo-server:
      <other config>
      env:
        KAPITAN_SECRET:
          secretKeyRef:
            key: 'kapitan_secret'

You would expect the name found to include the version, but its taking its information from a bit of the dataset that doesn't yet have versions (they haven't been calculated yet).

A solution could be something like this (in WorkloadCommon):

    def update_env_for_versions(self, objects):
        for object in objects.root:
            rendered_name = object.root.metadata.name

            containers = self.root.spec.template.spec.containers
            for container in containers:
                for env in container.env:
                    if "valueFrom" in env and "secretKeyRef" in env["valueFrom"]:
                        if env["valueFrom"].secretKeyRef.name == rendered_name.rsplit('-', 1)[0]:
                            env["valueFrom"].secretKeyRef.name = rendered_name

called after
workload.add_volumes_for_objects(secrets)
I can't help but feel theres a neater solution, this could do unexpected things. It also only does secrets.

Applogies for the lack of PR, my generator is hacked about quite a bit in ways you wouldn't want and I'm pushed for time. I'll try and backport the other bits that are globally applicable and do a PR for this if no one can see a better solution.


The env["valueFrom"] pains me, but python insisted...

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