apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
  name: backend
  namespace: {{ .Release.Namespace | quote }}
spec:
  refreshInterval: "1m"
  target:
    name: backend
    deletionPolicy: Delete
    template:
      type: Opaque
      data:
{{- range .Values.secrets }}
        {{ .podVariable }}: |-
          {{`{{`}} {{ print "." .name }} {{`}}`}}
{{- end }}
  data:
{{- range .Values.secrets }}
    - secretKey: {{ .name }}
      sourceRef:
        storeRef:
          name: {{ .clusterSecretStore }}
          kind: ClusterSecretStore
      remoteRef:
        key: {{ .itemId }}
        property: {{ .field }}
{{- end }}
