Difference between revisions of "Secrets diff"
Jump to navigation
Jump to search
(Created page with "# Secrets diff and create ``` if ! kubectl get secret netbox-tls -o yaml | grep -q "$(base64 < tls.crt)"; then kubectl delete secret netbox-tls --ignore-not-found kubectl...") |
|||
| Line 14: | Line 14: | ||
kubectl create secret tls netbox-tls --cert=tls.crt --key=tls.key | kubectl create secret tls netbox-tls --cert=tls.crt --key=tls.key | ||
| + | ``` | ||
| + | |||
| + | netbox.secrets.yaml.tpl | ||
| + | ``` | ||
| + | apiVersion: v1 | ||
| + | kind: Secret | ||
| + | metadata: | ||
| + | name: netbox-tls | ||
| + | type: kubernetes.io/tls | ||
| + | stringData: | ||
| + | tls.crt: | | ||
| + | {{ NETBOX_TLS_CRT | indent(4) }} | ||
| + | tls.key: | | ||
| + | {{ NETBOX_TLS_KEY | indent(4) }} | ||
| + | ``` | ||
| + | |||
| + | ``` | ||
| + | set -a NETBOX_TLS_CRT="..." | ||
| + | envtpl --keep-template netbox.secrets.yaml.tpl | ||
``` | ``` | ||
Latest revision as of 19:50, 12 February 2025
Secrets diff and create
if ! kubectl get secret netbox-tls -o yaml | grep -q "$(base64 < tls.crt)"; then kubectl delete secret netbox-tls --ignore-not-found kubectl create secret tls netbox-tls --cert=tls.crt --key=tls.key fi
kubectl get secret netbox-tls -o yaml | diff - <(kubectl create secret tls netbox-tls --cert=tls.crt --key=tls.key --dry-run=client -o yaml) || \ kubectl delete secret netbox-tls --ignore-not-found && \ kubectl create secret tls netbox-tls --cert=tls.crt --key=tls.key
netbox.secrets.yaml.tpl
apiVersion: v1
kind: Secret
metadata:
name: netbox-tls
type: kubernetes.io/tls
stringData:
tls.crt: |
{{ NETBOX_TLS_CRT | indent(4) }}
tls.key: |
{{ NETBOX_TLS_KEY | indent(4) }}
set -a NETBOX_TLS_CRT="..." envtpl --keep-template netbox.secrets.yaml.tpl