{{- /* TODO: remove this once we update Kubeflow TensorBoards: https://github.com/kubeflow/kubeflow/pull/6902 */ -}}
{{- if and .Values.deployKF.gateway.tls.enabled (not .Values.deployKF.gateway.tls.matchSNI) }}
{{- if .Values.deployKF.kubeflow.tensorboards.enabled }}
################
## This DestinationRule tells Istio to use TLS when connecting to our tensorboards-redirect service.
## See `VirtualService/tensorboards-redirect` for more details.
################
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: tensorboards-redirect
  labels:
    helm.sh/chart: {{ include "deploykf-istio-gateway.labels.chart" . }}
    app.kubernetes.io/name: {{ include "deploykf-istio-gateway.labels.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
  host: "tensorboards-redirect.{{ .Values.deployKF.gateway.hostname }}"
  workloadSelector:
    matchLabels:
     {{- toYaml .Values.deployKF.gateway.selectorLabels | nindent 6 }}
  trafficPolicy:
    portLevelSettings:
      - port:
          number: {{ .Values.deployKF.gateway.servicePorts.https | default .Values.deployKF.gateway.ports.https | int }}
        tls:
            mode: SIMPLE
{{- end }}
{{- end }}