AlexRogalskiy/java-patterns

View on GitHub
charts/templates/virtualservice.yaml

Summary

Maintainability
Test Coverage
{{- if .Values.virtualservice.enabled -}}
{{- $fullName := include "backend-java-patterns.fullname" . -}}
{{- $svcPort := .Values.service.ports.http -}}
{{- $svcHost := .Values.virtualservice.serviceHost -}}
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: {{ $fullName }}
  namespace: {{ .Release.Namespace | quote }}
  labels:
    {{- include "backend-java-patterns.labels" . | nindent 4 }}
  {{- if .Values.virtualservice.annotations }}
  {{- with .Values.virtualservice.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  {{- end }}
spec:
  exportTo:
  - '*'
  {{- range .Values.virtualservice.hosts }}
  hosts:
  - {{ .host | quote }}
  gateways:
  - istio-system/gateway
  http:
  {{- range .names }}
  - name: {{ .name | quote }}
    match:
    {{- range .uris }}
    - uri:
        prefix: {{ .prefix | quote }}
    - uri:
        exact: {{ .exact | quote }}
    {{- end }}
    {{- range .rewrites }}
    rewrite:
      uri: {{ . | quote }}
    {{- end }}
    route:
    - destination:
        host: {{ $svcHost }}
        port:
          number: {{ $svcPort }}
  {{- end }}
{{- end }}
{{- end }}