{{- if index .Values "mariadb-galera" "istio" "enabled" }}
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: {{ template "kubezero-lib.fullname" $ }}-mariadb
  namespace: {{ .Release.Namespace }}
  labels:
{{ include "kubezero-lib.labels" . | indent 4 }}
spec:
  hosts:
  - {{ index .Values "mariadb-galera" "istio" "url" }}
  gateways:
  - {{ index .Values "mariadb-galera" "istio" "gateway" }}
  tcp:
  - match:
    - port: {{ default 3306 ( index .Values "mariadb-galera" "service" "port" ) }}
    route:
    - destination:
        host: {{ .Release.Name }}-mariadb-galera-headless
        port:
          number: {{ default 3306 ( index .Values "mariadb-galera" "service" "port" ) }}
{{- end }}
