-
-
Notifications
You must be signed in to change notification settings - Fork 61
feat: Add support for existingSecret for htpasswd authentication #180
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
base: master
Are you sure you want to change the base?
Conversation
Add support for referencing an existing Kubernetes secret for htpasswd authentication, avoiding plain text passwords in `values.yaml`. - Add `secrets.existingSecretHtpasswd` to reference an existing secret - Add `secrets.existingSecretHtpasswdKey` to specify the key name (defaults to "htpasswd") - Update templates to support both generated and existing secrets - Add README documentation ```yaml secrets: existingSecretHtpasswd: "my-htpasswd-secret" existingSecretHtpasswdKey: "htpasswd" # Optional ``` Create the secret: ```bash kubectl create secret generic my-htpasswd-secret \ --from-file=htpasswd=/path/to/htpasswd ``` If both `secrets.htpasswd` and `secrets.existingSecretHtpasswd` are set, the existing secret takes precedence.
47c516a to
c074381
Compare
|
@juanpicado Would you be the right person to review/merge this? 🙏🏻 |
|
Yep let me give it a read later :) and if I have no questions I will merge thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for referencing an existing Kubernetes secret for htpasswd authentication in the Verdaccio Helm chart, providing a more secure alternative to storing plain text credentials in values.yaml.
Key Changes:
- Added
secrets.existingSecretHtpasswdandsecrets.existingSecretHtpasswdKeyconfiguration options to reference external secrets - Updated deployment and statefulset templates to conditionally use either generated or existing secrets
- Modified secret generation logic to prevent conflicts when using existing secrets
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| charts/verdaccio/values.yaml | Adds configuration options for referencing existing htpasswd secrets |
| charts/verdaccio/templates/statefulset.yaml | Updates pod annotations, volume mounts, and secret references to support both generated and existing secrets |
| charts/verdaccio/templates/deployment.yaml | Updates pod annotations, volume mounts, and secret references to support both generated and existing secrets |
| charts/verdaccio/templates/htpasswd-secret.yaml | Modifies conditional to prevent secret generation when using existing secret |
| charts/verdaccio/Chart.yaml | Bumps chart version from 4.28.0 to 4.29.0 for this minor feature addition |
| README.md | Adds comprehensive documentation with usage examples for the new existing secret feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| {{- if .Values.secrets.existingSecretHtpasswd }} | ||
| checksum/htpasswd-secret: {{ .Values.secrets.existingSecretHtpasswd }}-{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }} | ||
| {{- end }} |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checksum annotation for existingSecretHtpasswd only concatenates the secret name and key, which won't detect changes to the actual secret content. This means pods won't automatically restart when the external secret is updated. Consider documenting that users need to manually trigger pod restarts when updating the external secret, or remove this checksum annotation entirely since Kubernetes doesn't automatically track changes to external secrets.
| {{- if .Values.secrets.existingSecretHtpasswd }} | |
| checksum/htpasswd-secret: {{ .Values.secrets.existingSecretHtpasswd }}-{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }} | |
| {{- end }} |
| - mountPath: /verdaccio/storage/htpasswd | ||
| name: htpasswd | ||
| subPath: htpasswd | ||
| subPath: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }}{{ else }}htpasswd{{ end }} |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline conditional for subPath makes the template harder to read. Consider moving this logic to a helper template or using a clearer multi-line if-else structure for better maintainability.
| subPath: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }}{{ else }}htpasswd{{ end }} | |
| {{- if .Values.secrets.existingSecretHtpasswd }} | |
| subPath: {{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }} | |
| {{- else }} | |
| subPath: htpasswd | |
| {{- end }} |
| - name: htpasswd | ||
| secret: | ||
| secretName: {{ include "verdaccio.fullname" . }}-htpasswd | ||
| secretName: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswd }}{{ else }}{{ include "verdaccio.fullname" . }}-htpasswd{{ end }} |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline conditional for secretName makes the template harder to read. Consider moving this logic to a helper template or using a clearer multi-line if-else structure for better maintainability.
| secretName: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswd }}{{ else }}{{ include "verdaccio.fullname" . }}-htpasswd{{ end }} | |
| {{- if .Values.secrets.existingSecretHtpasswd }} | |
| secretName: {{ .Values.secrets.existingSecretHtpasswd }} | |
| {{- else }} | |
| secretName: {{ include "verdaccio.fullname" . }}-htpasswd | |
| {{- end }} |
| - mountPath: /verdaccio/storage/htpasswd | ||
| name: htpasswd | ||
| subPath: htpasswd | ||
| subPath: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }}{{ else }}htpasswd{{ end }} |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline conditional for subPath makes the template harder to read. Consider moving this logic to a helper template or using a clearer multi-line if-else structure for better maintainability.
| subPath: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }}{{ else }}htpasswd{{ end }} | |
| subPath: {{- if .Values.secrets.existingSecretHtpasswd }} | |
| {{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }} | |
| {{- else }} | |
| htpasswd | |
| {{- end }} |
| - name: htpasswd | ||
| secret: | ||
| secretName: {{ include "verdaccio.fullname" . }}-htpasswd | ||
| secretName: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswd }}{{ else }}{{ include "verdaccio.fullname" . }}-htpasswd{{ end }} |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline conditional for secretName makes the template harder to read. Consider moving this logic to a helper template or using a clearer multi-line if-else structure for better maintainability.
| secretName: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswd }}{{ else }}{{ include "verdaccio.fullname" . }}-htpasswd{{ end }} | |
| {{- if .Values.secrets.existingSecretHtpasswd }} | |
| secretName: {{ .Values.secrets.existingSecretHtpasswd }} | |
| {{- else }} | |
| secretName: {{ include "verdaccio.fullname" . }}-htpasswd | |
| {{- end }} |
| {{- if .Values.secrets.existingSecretHtpasswd }} | ||
| checksum/htpasswd-secret: {{ .Values.secrets.existingSecretHtpasswd }}-{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }} | ||
| {{- end }} |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checksum annotation for existingSecretHtpasswd only concatenates the secret name and key, which won't detect changes to the actual secret content. This means pods won't automatically restart when the external secret is updated. Consider documenting that users need to manually trigger pod restarts when updating the external secret, or remove this checksum annotation entirely since Kubernetes doesn't automatically track changes to external secrets.
| {{- if .Values.secrets.existingSecretHtpasswd }} | |
| checksum/htpasswd-secret: {{ .Values.secrets.existingSecretHtpasswd }}-{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }} | |
| {{- end }} |
Summary
Add support for referencing an existing Kubernetes secret for htpasswd authentication, avoiding plain text passwords in
values.yaml.Changes
secrets.existingSecretHtpasswdto reference an existing secretsecrets.existingSecretHtpasswdKeyto specify the key name (defaults to "htpasswd")Usage
Create the secret:
If both
secrets.htpasswdandsecrets.existingSecretHtpasswdare set, the existing secret takes precedence.