{{- $cn := "outline" -}}
{{- $ca := genCA "outline-ca" 3650 -}}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ .Release.Name }}-vpn-tls
type: kubernetes.io/tls
data:
{{- $existingSecret := lookup "v1" "Secret" .Release.Namespace (printf "%s-vpn-tls" .Release.Name) }}
  {{- if $existingSecret }}
  ca.crt: {{ index $existingSecret.data "ca.crt" }}
  tls.crt: {{ index $existingSecret.data "tls.crt" }}
  tls.key: {{ index $existingSecret.data "tls.key" }}
  {{- else }}
  {{- with genSignedCert $cn nil nil 3650 $ca }}
  cacert: {{ b64enc $ca.Cert }}
  tls.crt: {{ b64enc .Cert }}
  tls.key: {{ b64enc .Key }}
  {{- end }}
  {{- end }}
