You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/architecture/concepts.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Here are the key concepts of Template Operator:
4
4
5
5
## Template
6
6
7
-
A **Template** is a reusable blueprint in Template Operator that defines configurations for Kubernetes resources. It supports raw manifests, Helm charts, or resource mappings, enabling standardization and automation across multiple tenants.
7
+
A **Template** is a reusable blueprint in Template Operator that defines configurations for Kubernetes resources. It supports raw manifests, gotemplate based dynamic manifests, Helm charts, or resource mappings, enabling standardization and automation across multiple tenants.
Copy file name to clipboardExpand all lines: content/kubernetes-resources/template.md
+44-2Lines changed: 44 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Also, you can define custom variables in `Template`, `TemplateInstance` and `Clu
8
8
9
9
## Specification
10
10
11
-
`Template` Custom Resource (CR) supports three key methods for defining and managing resources: `manifests`, `helm`, and `resource mapping`. Let’s dive into each method, their differences, and their use cases:
11
+
`Template` Custom Resource (CR) supports three key methods for defining and managing resources: `manifests`, `helm`, `gotemplate`, and `resource mapping`. Let’s dive into each method, their differences, and their use cases:
12
12
13
13
### 1. Manifests
14
14
@@ -140,7 +140,49 @@ A brief explanation of the fields in the Helm section:
140
140
* `forceString`: Whether to use `--set` or `--set-string` when setting the value. Default is `false` (use `--set`).
141
141
* `values`: The values file for the Helm chart.
142
142
143
-
### 3. Resource Mapping
143
+
### 3. GoTemplate
144
+
145
+
This method uses inline Go templates to dynamically generate Kubernetes manifests. It leverages Go’s `text/template` syntax along with Sprig functions for string operations, date formatting, conditionals, arithmetic, and more.
146
+
147
+
#### How It Works
148
+
149
+
* The `gotemplate` section contains YAML written with Go template expressions such as `{{ .Name }}` or `{{ now | date "2006-01-02" }}`.
150
+
* Template `parameters` are injected at runtime, and Sprig functions can be used to transform or compute values.
151
+
* The rendered output must be valid Kubernetes YAML, which the operator then applies to the target namespaces.
152
+
153
+
#### Use Cases
154
+
155
+
* Ideal for dynamic resource generation without maintaining a full Helm chart.
156
+
* Useful when you need lightweight templating with conditional or computed fields.
157
+
* Suitable for resources that change based on tenant, namespace, or environment attributes.
158
+
159
+
#### Example
160
+
161
+
```yaml
162
+
apiVersion: templates.stakater.com/v1alpha1
163
+
kind: Template
164
+
metadata:
165
+
name: inline-gotemplate
166
+
parameters:
167
+
- name: Name
168
+
value: "sample-App"
169
+
- name: LogLevel
170
+
value: "INFO"
171
+
resources:
172
+
gotemplate: |
173
+
apiVersion: v1
174
+
kind: ConfigMap
175
+
metadata:
176
+
name: "{{ .Name | lower }}-config"
177
+
labels:
178
+
app: "{{ .Name | lower }}"
179
+
data:
180
+
appName: "{{ .Name }}"
181
+
logLevel: "{{ .LogLevel }}"
182
+
configVersion: "{{ now | date "2006-01-02" }}"
183
+
```
184
+
185
+
### 4. Resource Mapping
144
186
145
187
This approach maps secrets and ConfigMaps from one tenant's namespace to another tenant's namespace, or within a tenant's namespace.
0 commit comments