It is a plugin for Kustomize that allows you to template manifests by using Go's text/template library.
This plugin uses ([{
and }])
as delimiters to avoid collision with other libraries.
A Template transformer can be defined as:
apiVersion: incognia.com/v1alpha1
kind: Template
metadata:
name: _
data:
aws:
account:
name: example-aws-account-1234
number: 1234
cluster:
name: blue
owner: mario
Specify ./template.yaml
as a transform on kustomization.yaml
:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
transformers:
- ./template.yaml
resources:
- deployment.yaml
If your ./deployment.yaml
file look like:
apiVersion: apps/v1
kind: Deployment
metadata:
name: example
spec:
template:
spec:
containers:
- name: example
command:
- example-cmd
- input-arg=([{ .aws.account.name }])
It'll be outputted as:
apiVersion: apps/v1
kind: Deployment
metadata:
name: example
spec:
template:
spec:
containers:
- name: example
command:
- example-cmd
- input-arg=example-aws-account-1234