TLS Secrets Helper
Create kubernetes.io/tls Secrets with the ohMyHelm tlsSecrets helper, including networking.k8s.io/v1 Ingress wiring and lookup rotation notes.
TLS Secrets Helper
With the root helper tlsSecrets (camelCase!), you can create Kubernetes Secrets of type kubernetes.io/tls for TLS termination on Ingress controllers or internal services.
Supported Fields
According to values.schema.json, each entry in tlsSecrets[] accepts exactly these fields (additionalProperties: false):
| Field | Required | Description |
|---|---|---|
name |
Yes | Name of the generated TLS Secret |
namespace |
Optional | Target namespace (defaults to the release namespace) |
values."tls.crt" |
Yes | PEM-encoded certificate (including intermediate chain if applicable); automatically Base64-encoded |
values."tls.key" |
Yes | PEM-encoded private key; automatically Base64-encoded |
Basic Configuration
tlsSecrets:
- name: acme-app-tls
namespace: acme-prod
values:
tls.crt: |
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJALa8...
-----END CERTIFICATE-----
tls.key: |
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0B...
-----END PRIVATE KEY-----
Passing Certificates Securely via --set-file
Because ohMyHelm does not run tpl templating in values.yaml (expressions like {{ .Files.Get ... }} do not work) and private keys should never be stored unencrypted in Git, pass certificate files via --set-file from your pipeline:
helm upgrade --install acme-app . \
--namespace acme-prod \
-f values.yaml \
--set-file 'tlsSecrets[0].values.tls\.crt=./certs/tls.crt' \
--set-file 'tlsSecrets[0].values.tls\.key=./certs/tls.key'
Combining with a networking.k8s.io/v1 Ingress
tlsSecrets:
- name: acme-app-tls
namespace: acme-prod
values:
tls.crt: |
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJALa8...
-----END CERTIFICATE-----
tls.key: |
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0B...
-----END PRIVATE KEY-----
ingress:
- name: acme-app-ingress
tls:
- secretName: acme-app-tls
hosts:
- app.acme.example
hosts:
- host: app.acme.example
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: acme-app
port:
name: http
Important Note on Certificate Rotation and GitOps (lookup)
- **During direct `helm upgrade` against the cluster:** If the TLS Secret already exists, the template keeps the **old** content from the cluster instead of applying the new values from your `values.yaml`. Direct certificate rotation via `helm upgrade` therefore does not take place (workaround: delete the old Secret beforehand or automate certificate management).
- **With GitOps (`helm template`, Argo CD, Flux):** `lookup` always returns empty, so the values from the supplied values files are always rendered.
**Production recommendation:** Whenever possible, manage TLS certificates automatically via **cert-manager** (for example, using the `cert-manager.io/cluster-issuer` Ingress annotation or a `Certificate` CRD in the [`manifests` helper](/docs/ohmyhelm/helpers/manifests/)) rather than manually through `tlsSecrets`.