{{- if and (or .Values.externalWorkloads.enabled .Values.clustermesh.useAPIServer) .Values.clustermesh.apiserver.tls.auto.enabled (eq .Values.clustermesh.apiserver.tls.auto.method "cronJob") }}
{{- $crt := .Values.clustermesh.apiserver.tls.ca.cert | default .Values.tls.ca.cert -}}
{{- $key := .Values.clustermesh.apiserver.tls.ca.key | default .Values.tls.ca.key -}}
{{- if and $crt $key }}
---
apiVersion: v1
kind: Secret
metadata:
  name: clustermesh-apiserver-ca-cert
  namespace: {{ .Release.Namespace }}
data:
  ca.crt: {{ $crt }}
  ca.key: {{ $key }}
{{- end }}
{{- end }}
