# istio_remote-istiod-service.yaml
{{- if or (eq .Values.global.resourceScope "all") (eq .Values.global.resourceScope "namespace") }}
# This file is only used for remote
{{- if and .Values.global.remotePilotAddress .Values.istiodRemote.enabled }}
apiVersion: v1
kind: Service
metadata:
  {{- if .Values.istiodRemote.enabledLocalInjectorIstiod }}
  # only primary `istiod` to xds and local `istiod` injection installs.
  name: istiod{{- if .Values.revision }}-{{ .Values.revision}}{{- end }}-remote
  {{- else }}
  name: istiod{{- if .Values.revision }}-{{ .Values.revision}}{{- end }}
  {{- end }}
  namespace: {{ .Release.Namespace }}
  labels:
    istio.io/rev: {{ .Values.revision | default "default" | quote }}
    app.kubernetes.io/name: "istiod"
    {{ include "istio.labels" . | nindent 4 }}
spec:
  ports:
  - port: 15012
    name: tcp-istiod
    protocol: TCP
  - port: 443
    targetPort: 15017
    name: tcp-webhook
    protocol: TCP
  {{- if and .Values.global.remotePilotAddress (not (or (regexMatch "^([0-9]*\\.){3}[0-9]*$" .Values.global.remotePilotAddress) (regexMatch "^([0-9a-fA-F]*:)+[0-9a-fA-F]*$" .Values.global.remotePilotAddress))) }}
  # if the remotePilotAddress is not an IP addr (IPv4 or IPv6), we use ExternalName
  type: ExternalName
  externalName: {{ .Values.global.remotePilotAddress }}
  {{- end }}
{{- if .Values.global.ipFamilyPolicy }}
  ipFamilyPolicy: {{ .Values.global.ipFamilyPolicy }}
{{- end }}
{{- if .Values.global.ipFamilies }}
  ipFamilies:
{{- range .Values.global.ipFamilies }}
  - {{ . }}
{{- end }}
{{- end }}
---
{{- end }}
{{- end }}