traefik-helm-chart icon indicating copy to clipboard operation
traefik-helm-chart copied to clipboard

Support for volume mounting secrets with dots in name

Open mrdima opened this issue 5 years ago • 0 comments

When you have a secret named star.bla.com it's impossible to volume mount this using this in the chart:

volumes:
- name: star.bla.com
  mountPath: "/certs"
  type: secret

The error you get is: cannot patch "traefik" with kind Deployment: Deployment.apps "traefik" is invalid: [spec.template.spec.volumes[2].name: Invalid value: "star.bla.com": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is 'a-z0-9?')

So star.bla.com is a perfectly valid secretName (even helm uses it), but not a valid volumeName. The helm template uses the same name for volume and secretName. Can this be changed so the volumeName is autogenerated with a proper name?

In this specific case it's as simple as replacing the dots with hyphens, so putting the below on the volumeMount and volumes part in deployment.yaml

- name: {{ tpl (.name) $root | replace "." "-" }}

mrdima avatar Nov 11 '20 13:11 mrdima