1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-14 11:57:59 +00:00

added some example for v2 literal templating (#3007)

Signed-off-by: Robert Paschedag <robert.paschedag@sap.com>
Co-authored-by: Robert Paschedag <robert.paschedag@sap.com>
This commit is contained in:
Robert Paschedag 2024-01-09 09:38:23 +01:00 committed by GitHub
parent f32ea9f91d
commit 45e2bd3796
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View file

@ -55,6 +55,22 @@ You do not have to define your templates inline in an ExternalSecret but you can
Lastly, `TemplateFrom` also supports adding `Literal` blocks for quick templating. These `Literal` blocks differ from `Template.Data` as they are rendered as a a `key:value` pair (while the `Template.Data`, you can only template the value).
See an example, how to produce a `htpasswd` file that can be used by an ingress-controller (for example: https://kubernetes.github.io/ingress-nginx/examples/auth/basic/) where the contents of the `htpasswd` file needs to be presented via the `auth` key. We use the `htpasswd` function to create a `bcrytped` hash of the password.
Suppose you have multiple key-value pairs within your provider secret like
```json
{
"user1": "password1",
"user2": "password2",
...
}
```
```yaml
{% include 'template-v2-literal-example.yaml' %}
```
### Extract Keys and Certificates from PKCS#12 Archive
You can use pre-defined functions to extract data from your secrets. Here: extract keys and certificates from a PKCS#12 archive and store it as PEM.

View file

@ -0,0 +1,23 @@
{% raw %}
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
literal: |-
{{- $creds := list }}
{{- range $user, $pw := . }}
{{- $creds = append $creds (printf "%s" (htpasswd $user $pw)) }}
{{- end }}
auth: {{ $creds | join "\n" | quote }}
dataFrom:
- extract:
key: /ingress-controller/valid-users
{% endraw %}