mirror of
https://github.com/morten-olsen/homelab-apps.git
synced 2026-02-08 01:36:28 +01:00
4.6 KiB
4.6 KiB
Values Templating Guide
This document explains how templating works in values.yaml files and what placeholders are available.
Current Placeholders
The templating system supports the following placeholders in values.yaml:
| Placeholder | Maps To | Example |
|---|---|---|
{release} |
.Release.Name |
forgejo, audiobookshelf |
{namespace} |
.Release.Namespace |
prod, default |
{fullname} |
common.fullname helper |
audiobookshelf, forgejo |
{subdomain} |
.Values.subdomain |
code, audiobookshelf |
{domain} |
.Values.globals.domain |
olsen.cloud |
{timezone} |
.Values.globals.timezone |
Europe/Amsterdam |
Available Values
Release Object (.Release.*)
.Release.Name- The release name (chart instance name).Release.Namespace- The namespace the release will be installed into.Release.Service- The service that rendered the chart (usually "Helm").Release.Revision- The revision number of this release
Chart Object (.Chart.*)
.Chart.Name- The name of the chart.Chart.Version- The version of the chart.Chart.AppVersion- The app version of the chart
Values Object (.Values.*)
.Values.subdomain- The subdomain for this application.Values.globals.environment- The environment (e.g.,prod).Values.globals.domain- The domain (e.g.,olsen.cloud).Values.globals.timezone- The timezone (e.g.,Europe/Amsterdam).Values.globals.istio.gateways.public- Public Istio gateway.Values.globals.istio.gateways.private- Private Istio gateway.Values.globals.authentik.ref.name- Authentik server name.Values.globals.authentik.ref.namespace- Authentik server namespace.Values.globals.networking.private.ip- Private network IP
Usage Examples
Simple String Replacement
env:
BASE_URL:
value: "https://{subdomain}.{domain}"
# Renders to: "https://audiobookshelf.olsen.cloud"
Secret Reference with Release Name
env:
DATABASE_URL:
valueFrom:
secretKeyRef:
name: "{release}-database"
key: url
# Renders to: name: "audiobookshelf-database"
Complex String with Multiple Placeholders
env:
SSH_DOMAIN:
value: "ssh-{subdomain}.{domain}"
# Renders to: "ssh-code.olsen.cloud"
Extending Placeholders
To add more placeholders, edit apps/charts/common/templates/_helpers.tpl in the common.env helper:
Current Implementation
value: {{ $value
| replace "{release}" $.Release.Name
| replace "{namespace}" $.Release.Namespace
| replace "{fullname}" (include "common.fullname" $)
| replace "{subdomain}" $.Values.subdomain
| replace "{domain}" $.Values.globals.domain
| replace "{timezone}" $.Values.globals.timezone
| quote }}
Note: {fullname} uses the common.fullname helper which:
- Returns
.Release.Nameif it contains the chart name - Otherwise returns
{release}-{chart-name} - Respects
.Values.fullnameOverrideif set
Important: Update both locations:
- Line ~245: For
value:entries (when$value.valueexists) - Line ~248: For simple string values
Example Usage
env:
NAMESPACE:
value: "{namespace}"
# Renders to: "prod" (or whatever namespace the release is in)
TIMEZONE:
value: "{timezone}"
# Renders to: "Europe/Amsterdam"
APP_NAME:
value: "{fullname}"
# Renders to: "audiobookshelf" (or "release-chartname" if different)
FULL_URL:
value: "https://{subdomain}.{domain}"
# Renders to: "https://audiobookshelf.olsen.cloud"
SECRET_NAME:
valueFrom:
secretKeyRef:
name: "{fullname}-secrets"
key: apiKey
# Renders to: name: "audiobookshelf-secrets"
Limitations
- No nested placeholders: Placeholders cannot reference other placeholders
- No conditional logic: Placeholders are simple string replacements
- No functions: Cannot use Helm template functions in values.yaml
- Order matters: Replacements happen in order, so
{release}is replaced before{subdomain}
Best Practices
- Use placeholders for dynamic values: Release names, domains, subdomains
- Keep it simple: Use placeholders for common values, not complex logic
- Document custom placeholders: If you add new ones, document them
- Test thoroughly: Verify placeholders render correctly in your environment
Troubleshooting
If a placeholder isn't being replaced:
- Check the placeholder name matches exactly (case-sensitive)
- Verify the value exists in the context (
.Release.*or.Values.*) - Check the replacement chain in
_helpers.tpl - Use
helm template --debugto see the rendered output