{{- if .Values.rabbitmq.istio.enabled }}
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: rabbit-amqp
  namespace: {{ .Release.Namespace }}
  labels:
{{ include "kubezero-lib.labels" . | indent 4 }}
spec:
  gateways:
  - {{ .Values.rabbitmq.istio.gateway }}
  hosts:
{{ toYaml .Values.rabbitmq.hosts | indent 2 }}
  http:
  - route:
    - destination:
        host: rabbitmq
        port:
          number: 15672
  tcp:
  - match:
    - port: 5671
    route:
    - destination:
        host: rabbitmq
        port:
          number: 5672
  {{- if .Values.rabbitmq.istio.amqp }}
  - match:
    - port: 5672
    route:
    - destination:
        host: rabbitmq
        port:
          number: 5672
  {{- end }}
  {{- if .Values.rabbitmq.istio.mqtts }}
  - match:
    - port: 8883
    route:
    - destination:
        host: rabbitmq
        port:
          number: 1883
  {{- end }}
  {{- if .Values.rabbitmq.istio.mqtt }}
  - match:
    - port: 1883
    route:
    - destination:
        host: rabbitmq
        port:
          number: 1883
  {{- end }}
{{- end }}
