You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a collection of manifests that I am mutating for a specific set of environments.
Specifically, a subset of these manifests are Deployments. I want to add an environment variable if it doesn't already exist. This poses 3 problems:
For each Deployment I want to update the spec/template/spec/containers/N where N.name == the metadata.name
In the Containers object in the deployment mentioned in update readme w/ travis #1, I want to add env if it doesn't already exist.
If env does exist, and the variable I want is present, I want to alter its value, if it's not present, I want to add a new element to the array that contains my intended name and value.
I thought I might be able to accomplish part one using vars, but I keep running into Error: var '{DEPLOYMENT_NAME apps_v1_Deployment {metadata.name}}' cannot be mapped to a field in the set of known resources
I am not sure what is causing the cannot be mapped to a field... error, but even if I got past that, I am assuming that I can't use $(DEPLOYMENT_NAME) as a selector.
Is there an alternate approach for this that might work?
After I accomplish that, how can I "upsert" both the env object and its contents?
In the approaches that I've tried, I can't seem to get kustomize to not just create another array entry so that the result ends up looking like
Thinking about this more, I think that there is no good way in most merge languages to describe such a conditional inclusion into an array. Not with a single step, at least.
@monopole - Thanks for your response. Do you think there is anything actionable that could be done after a test? Can it be used as conditional branches? It would be nice to have a boolean grouping in jsonpatch: e.g. { op: "and" : [ { op: "test" ...}, { op: "replace" ... }] }
I don't know if that would ever make it off the editing room floor in an RFC :)
I have a collection of manifests that I am mutating for a specific set of environments.
Specifically, a subset of these manifests are Deployments. I want to add an environment variable if it doesn't already exist. This poses 3 problems:
spec/template/spec/containers/N
whereN.name
== themetadata.name
env
if it doesn't already exist.I thought I might be able to accomplish part one using vars, but I keep running into
Error: var '{DEPLOYMENT_NAME apps_v1_Deployment {metadata.name}}' cannot be mapped to a field in the set of known resources
The relevant part of my kustomize is:
Then the setenv.yaml:
I am not sure what is causing the
cannot be mapped to a field...
error, but even if I got past that, I am assuming that I can't use $(DEPLOYMENT_NAME) as a selector.Is there an alternate approach for this that might work?
After I accomplish that, how can I "upsert" both the env object and its contents?
In the approaches that I've tried, I can't seem to get kustomize to not just create another array entry so that the result ends up looking like
Am I taking the wrong approach here? I would really like to avoid having to spell out a kustomization patch for every named deployment I am using.
The text was updated successfully, but these errors were encountered: