1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00
external-secrets/docs/snippets/template-v2-from-secret.yaml
Gustavo Fernandes de Carvalho 0bd9ea4dbd
Templates from string (#1748)
* Adds templates from string

Signed-off-by: Gustavo Carvalho <gusfcarvalho@gmail.com>
2023-01-03 19:02:43 -03:00

70 lines
1.7 KiB
YAML

{% raw %}
# define your template in a config map
apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-config-tpl
data:
config.yaml: |
datasources:
- name: Graphite
type: graphite
access: proxy
url: "{{ .uri }}"
password: "{{ .password }}"
user: "{{ .user }}"
templated: |
# key and value templated
my-application-{{ .user}}: {{ .password | b64enc }}
# conditional keys
{{- if hasPrefix "oci://" .uri }}
enableOCI: true
{{- else }}
enableOCI: false
{{- end }}
# Fixed values
application-type: grafana
annotations: |
#dynamic timestamp generation
last-synced-for-user/{{ .user }}: {{ now }}
---
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: my-template-example
spec:
# ...
target:
name: secret-to-be-created
template:
engineVersion: v2
templateFrom:
- target: Data
configMap:
# name of the configmap to pull in
name: grafana-config-tpl
# here you define the keys that should be used as template
items:
- key: config.yaml
templateAs: Values
- key: generated
templateAs: KeysAndValues
- target: Annotations
configMap:
# name of the configmap to pull in
name: grafana-config-tpl
# here you define the keys that should be used as template
items:
- key: annotations
templateAs: KeysAndValues
data:
- secretKey: user
remoteRef:
key: /grafana/user
- secretKey: password
remoteRef:
key: /grafana/password
- secretKey: uri
remoteRef:
key: /grafana/uri
{% endraw %}