Argocd + env var + applicationset + kustomize #9814
-
|
We are running into an issue where we would like to simply add an environment variable
We continue to see references to the CMP where we are "supposed" to just be able to use: plugin:
env:
- name: IMAGETAG
value: "{{version}}"However, when using that we run into : rpc error: code = Unknown desc = plugin sidecar failed. Couldn't find cmp-server plugin supporting repository .apps/core-api/deploy/overlays/stagingSo, how, exactly are we supposed to add an environment variable to kustomize templating from an applicationset? I know how to retrieve it on the templating side, but setting it on the applicationset seems to either be impossible or completely undocumented? Any pointers here or help would be fantastic! Thanks! Documentation Sources: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
|
Actually I solved my own problem, but this was a HUGE combination of documented pieces from around the web... ok so here are the pieces... In my plugin:
env:
- name: IMAGETAG
value: "{{version}}"
name: kustomized-helmIn argocd helm configuration for plugins: # server.config.configManagementPlugins
configManagementPlugins: |
- name: kustomized-helm
generate:
command: ["/bin/sh", "-c"]
args: ["IMAGETAG=${ARGOCD_ENV_IMAGETAG} kustomize build --enable-helm"]Local configMapGenerator:
- name: image-tag-var
env: image.tag.properties
replacements:
- path: image-tag-replacement.yamlLocal IMAGETAGNotice the deployment name and the Local source:
kind: ConfigMap
name: image-tag-var
fieldPath: data.IMAGETAG
version: v1
targets:
- select:
name: my-deployment
kind: Deployment
fieldPaths:
- spec.template.spec.containers.[name=my-container].image
options:
delimiter: ':'
index: 1
create: true
|
Beta Was this translation helpful? Give feedback.
-
|
I'm trying to use this for my setup as well but I have encountered a problem: When I want to open a new PR, a new app is created but it also updates the existing ones too. Do we have a solution and/or an explanation of why this occurs? I tried the same setup with Helm and everything works as expected. |
Beta Was this translation helpful? Give feedback.
-
|
I recently had to create a custom Config Management Plugin (CMP) for Carvel ytt, and I ran into a similar challenge. Initially, I wasn’t sure how to pass those dynamic arguments from an ApplicationSet into the plugin. However, I ran into a subtle but important issue with how the command was defined in the plugin spec:
The issue happened because Argo CD executes the command directly (without a shell), This change finally allowed me to pass per-application arguments like: configManagementPlugins: |
- name: carvel-ytt-cmp
generate:
command: ["/bin/sh", "-c"]
args: ["ytt -f . ${ARGOCD_ENV_YTT_EXTRA_ARGS}"]plugin:
name: carvel-ytt-cmp
env:
- name: YTT_EXTRA_ARGS
value: "-f path/to/values.yml" |
Beta Was this translation helpful? Give feedback.
Actually I solved my own problem, but this was a HUGE combination of documented pieces from around the web... ok so here are the pieces...
In my
applicationSet:In argocd helm configuration for plugins:
Local
kustomization.yaml: