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

Use values from secrets env #67

Merged
merged 4 commits into from
Mar 4, 2024
Merged

Conversation

rahulinux
Copy link
Contributor

@rahulinux rahulinux commented Feb 27, 2024

Currently secrets used in command args and it's visible in deployment. this change will read take values from secrets and sets in env variable.

Once this is merge then we can test deployment with this change. https://github.com/neondatabase/aws/pull/1070

@rahulinux rahulinux requested a review from jcsp February 27, 2024 18:30
@rahulinux rahulinux force-pushed the storage-controller-add-secrets branch from 3814836 to 46f6048 Compare February 27, 2024 18:35
@rahulinux rahulinux requested a review from a team February 27, 2024 18:35
@rahulinux rahulinux force-pushed the storage-controller-add-secrets branch from 46f6048 to cf2b678 Compare February 27, 2024 18:38
@rahulinux
Copy link
Contributor Author

@jcsp --public-key= not clear for me. should we pass base64 content or file path because public key is multiline.

@rahulinux
Copy link
Contributor Author

@jcsp --public-key= not clear for me. should we pass base64 content or file path because public key is multiline.

Updated new config after confirming with John.

@rahulinux rahulinux force-pushed the storage-controller-add-secrets branch from cf2b678 to 0cdbc98 Compare February 28, 2024 12:42
secretKeyRef:
name: {{ include "neon-storage-controller.fullname" . }}
key: DATABASE_URL
- name: JWT_TOKEN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, we usually put secret key mounted somewhere and pass into the app location of that file.
Passing quite large key in env variable sounds strange to me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, JWT tokens are not actually that big, so this may be OK

{{- end }}
{{- if .Values.settings.publicKey }}
- --database-url $(DATABASE_URL)
- --jwt-token $(JWT_TOKEN)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the $(JWT_TOKEN) tries to say?
It's executing binary with the name JWT_TOKEN currently.
But ${JWT_TOKEN} also wrong as IIRC it doesn't have that envs in the context of evaluation of command line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to hide this secret from command line, binary itself should load this from well-known env variables, and not trying to inject into command line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env sets from secrets and it will pass to cmd args$(JWT_TOKEN) and yes it would be nice if controller support reading from config file. https://stackoverflow.com/a/50248608

@jcsp can we pass config file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env sets from secrets and it will pass to cmd args$(JWT_TOKEN) and yes it would be nice if controller support reading from config file. https://stackoverflow.com/a/50248608

Ok, then it is probably fine. But I never used this syntax, so you are on your own here.

@@ -47,21 +47,10 @@ spec:
- -l
# In the container, use the same port as service.
- 0.0.0.0:{{ .Values.service.port }}
{{- if .Values.settings.databaseUrl }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you removed this condition, meaning flag always set.
Which means AWS secret manager is never used, right?
Then this comment become incorrect: https://github.com/neondatabase/helm-charts/blob/main/charts/neon-storage-controller/values.yaml#L27

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it shouldn't use secrets from AWS manager, we will be moving to GitOps with fluxcd where all secrets are in sops, also we use sops in terraform. secrets in AWS secrets can be change from UI easily which can create issue, using secrets (sops) in git is safe and single source of truth.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update values.yaml then, please

Copy link
Contributor Author

@rahulinux rahulinux Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave that to @jcsp

@rahulinux rahulinux force-pushed the storage-controller-add-secrets branch 3 times, most recently from 389610f to 414bfcc Compare March 1, 2024 21:05
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds a lot like functionality that should not be a concern of packaging (helm) but app itself. This probably needs maintenance in the future, so it probably should be tested too, so it would be much more natural for that to live with the app in app repo - because that's where the development happens - rather than helm repo.

If the logic isn't built in with the app and has to be a separate script, could use initContainer for that for instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is temporary from script and once there is functionality then we can remove this script. also the reason I used post-install job because lifecycle.postStart doesn't have any retry mechanism. this script is copy of existing init script from ansble playbook and tested on dev.

@rahulinux rahulinux force-pushed the storage-controller-add-secrets branch 6 times, most recently from bc4e3f2 to 2f01383 Compare March 4, 2024 11:35
@rahulinux
Copy link
Contributor Author

@lassizci @jcsp I'm going to merge this to test helm chart on CI I'll open another PR if there is any change needed.

@rahulinux rahulinux force-pushed the storage-controller-add-secrets branch from 2f01383 to 8380bba Compare March 4, 2024 12:06
@rahulinux rahulinux merged commit 3fbbb09 into main Mar 4, 2024
3 checks passed
@rahulinux rahulinux deleted the storage-controller-add-secrets branch March 4, 2024 12:09
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

Successfully merging this pull request may close these issues.

3 participants