Argo-cd: ENV variables from "params"

Created on 6 Jun 2019  Â·  20Comments  Â·  Source: argoproj/argo-cd

Is your feature request related to a problem? Please describe.
Hi there, firstly thanks for a really well composed system (a few rough edges but all together great!)

Describe the solution you'd like
Id like to know the possibility of allowing argocd app set guestbook -p MY_VAR=MY_VALUE to be used as environment vars with kustomize .. as there are certain workflows that would require this.

Have you thought about contributing yourself?

Would love to.. need to powerup the go skills tho

config-management enhancement good first issue help wanted usability

All 20 comments

This looks like a neat feature. As I mentioned in Slack:

Anyone wanting to contribute but worried you don't know Go, spend 2h on the tutorial https://tour.golang.org, I read this before lunch and was commit changes before my first afternoon coffee.

This is where you'd need to add this:

Ok so, using Cobera for cli, its then a case of

  1. find the Params hash
  2. decide on creating a new proj subcommand probably argocd proj upsert-envvar|delete-envvar NAME=VALUE
  3. write a generic env method to add/remove env vars to the cmd.Env
  4. find the kustomize command caller and use the updated cmd.Env when calling kustomize and use envsubst or similar to pipe to content

question

  1. using kustomize build or the new kubctl -k may be worth investigating the new kustomze integration

Sound about right?

@rosscdh you're bang-on right.

A thought I have is that with kubectl, you have --env="DNS_DOMAIN=cluster" (note we can't use --env, but it's already used, but we could use -e. Environment variables be a nice feature for all the tools (Helm, Ksonnet, plain YAML), but just do Kustomize today.

This would be ... more complex:

  1. In types.go to ApplicationSource a Envmap[string]string.
  2. Generate the code using make codegen.

Optionally, any of the following depending on how you personally want to set/see the env, change the following:

  • NewApplicationCreateCommand
  • NewApplicationSetCommand
  • NewApplicationGetCommand

And maybe display in the UI somewhere.

Don't implement something you won't use mind you!

@jessesuen thoughts?

Unfortunately I am on holiday for 2 weeks in FR if i get a chance ill hack otherwise will do when i get back (if someone else hasn't claimed it)

on codegen it seems redis-ha has been removed from : https://kubernetes-charts.storage.googleapis.com

+ helm dependency update ./chart --skip-refresh
Error: Can't get a valid version for repositories redis-ha. Try changing the version constraint in requirements.yaml

Manually downloaded and now proceeding (strange internet pipes here)

@rosscdh you mention that there are examples when you'd use this for Kustomize?

I think you could achieve this now using a custom plugin + envsubst.

Yes thats what i thought initially too; in fact i have one build that still
makes use of it for secrets atm.

Coudl oyu point me at the custom plugin please?

On Wed, Jul 3, 2019 at 12:09 AM Alex Collins notifications@github.com
wrote:

I think you could achieve this now using a custom plugin + envsubst.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/argoproj/argo-cd/issues/1705?email_source=notifications&email_token=AADA6MVSAWQVEY537WLBRFLP5PGZTA5CNFSM4HVCU4BKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZCWCGY#issuecomment-507863323,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADA6MWP3WD4A3MKBQPIGZDP5PGZTANCNFSM4HVCU4BA
.

Ah https://argoproj.github.io/argo-cd/user-guide/config-management-plugins/ yes that would def work, tho would be better integrated with vaule or similar for secrets. https://argoproj.github.io/argo-cd/user-guide/config-management-plugins/ tho hacking things into the pod is a little anti-patterny.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I want set env vars into argocd which kustomize could use.
Something like circle ci does.

@ptux I had the same thought, however you should not be using dynamic variables in kustomize (there is a specific reason why they opted against it)

2415 supports some special env vars for Helm/Jsonnet. I don't think we can do this for Kustomize because we invoke kustomize build . and this does not have parameters nor take the env into account. Am I missing something?

$ kustomize version
Version: {KustomizeVersion:3.1.0 GitCommit:95f3303493fdea243ae83b767978092396169baf BuildDate:2019-07-26T19:21:45+01:00 GoOs:darwin GoArch:amd64}

Here is what I can I do on local .

 $ tree
.
├── kustomization.yaml
└── secret.env

0 directories, 2 files
$ cat kustomization.yaml 
namespace: hello-cloudbuild-dev

secretGenerator:
- name: mysecret
  envs:
  - secret.env
  type: Opaque

generatorOptions:
  disableNameSuffixHash: true
$ cat secret.env 
SECRET_USERNAME
SECRET_PASSWORD
$ env | grep SECRET
SECRET_PASSWORD=password2
SECRET_USERNAME=admin2
$ kustomize build .
apiVersion: v1
data:
  SECRET_PASSWORD: cGFzc3dvcmQy
  SECRET_USERNAME: YWRtaW4y
kind: Secret
metadata:
  name: mysecret
  namespace: hello-cloudbuild-dev
type: Opaque

So, I want to add env to argo CD server.
Somthing like this.

argocd app creat appname --env SECRET_USERNAME=admin2 --env SECRET_PASSWORD=password2

So you want Argo CD to create the secret.env file?

Well, technically speaking, I want Argo CD to create values for env vars.

secret.env file just only holds the keys of env vars but not the values.

SECRET_USERNAME
SECRET_PASSWORD

So we could push secret.env to the git repo.

OK. So you need a file containing a list of the available envvars so you can use them in your secrets? Where do the values of those vars come from?

https://github.com/kubernetes-sigs/kustomize/blob/master/examples/secretGeneratorPlugin.md#secret-values-from-local-files

I would like to set env vars into argocd which kustomize could use.
IMHO, kustomize custom plugin can use the envs

Was this page helpful?
0 / 5 - 0 ratings