Skip to content

Conversation

@Andrea-Gallicchio
Copy link

@Andrea-Gallicchio Andrea-Gallicchio commented Nov 28, 2025

Summary

Add support for referencing an existing Kubernetes secret for htpasswd authentication, avoiding plain text passwords in values.yaml.

Changes

  • 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

Usage

secrets:
  existingSecretHtpasswd: "my-htpasswd-secret"
  existingSecretHtpasswdKey: "htpasswd"  # Optional

Create the secret:

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.

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.
@Andrea-Gallicchio
Copy link
Author

@juanpicado Would you be the right person to review/merge this? 🙏🏻

@juanpicado
Copy link
Member

Yep let me give it a read later :) and if I have no questions I will merge thanks

Copy link
Contributor

Copilot AI left a 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.existingSecretHtpasswd and secrets.existingSecretHtpasswdKey configuration 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.

Comment on lines +38 to +40
{{- if .Values.secrets.existingSecretHtpasswd }}
checksum/htpasswd-secret: {{ .Values.secrets.existingSecretHtpasswd }}-{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }}
{{- end }}
Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
{{- if .Values.secrets.existingSecretHtpasswd }}
checksum/htpasswd-secret: {{ .Values.secrets.existingSecretHtpasswd }}-{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }}
{{- end }}

Copilot uses AI. Check for mistakes.
- mountPath: /verdaccio/storage/htpasswd
name: htpasswd
subPath: htpasswd
subPath: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }}{{ else }}htpasswd{{ end }}
Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
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 }}

Copilot uses AI. Check for mistakes.
- name: htpasswd
secret:
secretName: {{ include "verdaccio.fullname" . }}-htpasswd
secretName: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswd }}{{ else }}{{ include "verdaccio.fullname" . }}-htpasswd{{ end }}
Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
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 }}

Copilot uses AI. Check for mistakes.
- mountPath: /verdaccio/storage/htpasswd
name: htpasswd
subPath: htpasswd
subPath: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }}{{ else }}htpasswd{{ end }}
Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
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 }}

Copilot uses AI. Check for mistakes.
- name: htpasswd
secret:
secretName: {{ include "verdaccio.fullname" . }}-htpasswd
secretName: {{ if .Values.secrets.existingSecretHtpasswd }}{{ .Values.secrets.existingSecretHtpasswd }}{{ else }}{{ include "verdaccio.fullname" . }}-htpasswd{{ end }}
Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
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 }}

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +33
{{- if .Values.secrets.existingSecretHtpasswd }}
checksum/htpasswd-secret: {{ .Values.secrets.existingSecretHtpasswd }}-{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }}
{{- end }}
Copy link

Copilot AI Dec 22, 2025

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.

Suggested change
{{- if .Values.secrets.existingSecretHtpasswd }}
checksum/htpasswd-secret: {{ .Values.secrets.existingSecretHtpasswd }}-{{ .Values.secrets.existingSecretHtpasswdKey | default "htpasswd" }}
{{- end }}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants