apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
  name: tunnel-outbound-traffic-to-external-svc-via-external-forward-proxy
spec:
  host: external-forward-proxy.{{ .externalNamespace }}.svc.cluster.local
  subsets:
  - name: external-svc-tcp
    trafficPolicy:
      tunnel:
        targetHost: external.{{ .externalNamespace }}
        targetPort: {{ .externalSvcTcpPort }}
  - name: external-svc-tls
    trafficPolicy:
      tunnel:
        targetHost: external.{{ .externalNamespace }}
        targetPort: {{ .externalSvcTlsPort }}
---
{{ if .tlsEnabled }}
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
  name: originate-tls-for-outbound-traffic-to-external-forward-proxy
spec:
  host: external-forward-proxy.{{ .externalNamespace }}.svc.cluster.local
  trafficPolicy:
    portLevelSettings:
    - port:
        number: {{ .forwardProxyPort }}
      tls:
        mode: SIMPLE
        sni: external-forward-proxy.{{ .externalNamespace }}.svc.cluster.local
        insecureSkipVerify: true
{{ end }}
