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

[Cadence] Pull value from secret rather than plaintext in job #1302

Closed
wants to merge 7 commits into from

Conversation

johnkost
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
API breaks? no
Deprecations? no
Related tickets fixes #1301
License Apache 2.0

What's in this PR?

This PR has the setup job pull from the secret rather than requiring a plaintext password to be passed in

Why?

When deploying the chart using an existing secret and setup job, you have to pass in both the secret and the plaintext password for the job.

Checklist

  • Code meets the Developer Guide
  • User guide and development docs updated (if needed)
  • Related Helm chart(s) updated (if needed)

@sagikazarmark
Copy link
Member

@johnkost Thanks a lot for sending a PR!

The problem with this change is that it won't work in every case. When the job is executed as a pre-install hook, the secret won't be there (yet).

It would be nice if Helm could provide additional tools to make sure secrets get installed before hooks, but I'm not aware of anything like that.

@johnkost
Copy link
Contributor Author

@johnkost Thanks a lot for sending a PR!

The problem with this change is that it won't work in every case. When the job is executed as a pre-install hook, the secret won't be there (yet).

It would be nice if Helm could provide additional tools to make sure secrets get installed before hooks, but I'm not aware of anything like that.

I just pushed a fix that uses the conditional for the pre/post hook when determining if we should use the value or secret. Let me know if this addresses your concerns.

Copy link
Member

@sagikazarmark sagikazarmark left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@sagikazarmark sagikazarmark left a comment

Choose a reason for hiding this comment

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

Thanks @johnkost!

Can you please fix the above two typos?

cadence/templates/server-job.yaml Outdated Show resolved Hide resolved
cadence/templates/server-job.yaml Outdated Show resolved Hide resolved
Co-authored-by: Márk Sági-Kazár <[email protected]>
Copy link
Member

@pregnor pregnor left a comment

Choose a reason for hiding this comment

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

Your patience is appreciated, I was out of office last week.

Thank you for the PR, I like it in general, I'm also almost perfectly satisfied by it, left a question regarding one of the conditions and an optionally fixable typo comment, I leave the latter to decide up to you.

{{- if or .Values.cassandra.enabled .Values.mysql.enabled }}
valueFrom:
secretKeyRef:
name: {{ include "cadence.persistence.secretName" (list $ $store) | quote }}
Copy link
Member

Choose a reason for hiding this comment

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

Optional: typo.

Suggested change
name: {{ include "cadence.persistence.secretName" (list $ $store) | quote }}
name: {{ include "cadence.persistence.secretName" (list $ $store) | quote }}

Same at lines 171 and 302.
I am going to add references to those lines as well for tracking and web-UI suggestion committing purposes.

{{- if or .Values.cassandra.enabled .Values.mysql.enabled }}
valueFrom:
secretKeyRef:
name: {{ include "cadence.persistence.secretName" (list $ $store) | quote }}
Copy link
Member

@pregnor pregnor Nov 4, 2021

Choose a reason for hiding this comment

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

Reference: https://github.com/banzaicloud/banzai-charts/pull/1302/files#r742588952.

Suggested change
name: {{ include "cadence.persistence.secretName" (list $ $store) | quote }}
name: {{ include "cadence.persistence.secretName" (list $ $store) | quote }}

{{ - if or .Values.cassandra.enabled .Values.mysql.enabled }}
valueFrom:
secretKeyRef:
name: {{ include "cadence.persistence.secretName" (list $ $store) | quote }}
Copy link
Member

@pregnor pregnor Nov 4, 2021

Choose a reason for hiding this comment

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

Reference: https://github.com/banzaicloud/banzai-charts/pull/1302/files#r742588952.

Suggested change
name: {{ include "cadence.persistence.secretName" (list $ $store) | quote }}
name: {{ include "cadence.persistence.secretName" (list $ $store) | quote }}

cadence/templates/server-job.yaml Outdated Show resolved Hide resolved
cadence/templates/server-job.yaml Outdated Show resolved Hide resolved
cadence/templates/server-job.yaml Outdated Show resolved Hide resolved
@pregnor pregnor changed the title Pull value from secret rather than plaintext in job [Cadence] Pull value from secret rather than plaintext in job Nov 4, 2021
Copy link
Member

@pregnor pregnor left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes, I'm going to merge and release it ASAP.

cadence/templates/server-job.yaml Outdated Show resolved Hide resolved
@johnkost
Copy link
Contributor Author

johnkost commented Nov 5, 2021

After further testing, I realized what I'm trying to accomplish won't work because of the cadence-sql-cli tool. I was hoping that it would be idempotent but it doesn't do a check to see if the tables exists first resulting in an error if they are run more than once. I'll have to find another work around.

Appreciate the help on both PRs!

@johnkost johnkost closed this Nov 5, 2021
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.

[Cadence] Setup Job doesn't pull value from secret
3 participants