ingress-gateway.yaml 2 KB
Newer Older
Vũ Hoàng Nam's avatar
Vũ Hoàng Nam committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
{{- if and .Values.gateway.enabled -}}
{{- if .Values.gateway.ingress.enabled -}}
{{- $ingressApiIsStable := eq (include "loki.ingress.isStable" .) "true" -}}
{{- $ingressSupportsIngressClassName := eq (include "loki.ingress.supportsIngressClassName" .) "true" -}}
{{- $ingressSupportsPathType := eq (include "loki.ingress.supportsPathType" .) "true" -}}
apiVersion: {{ include "loki.ingress.apiVersion" . }}
kind: Ingress
metadata:
  name: {{ include "loki.gatewayFullname" . }}
  namespace: {{ $.Release.Namespace }}
  labels:
    {{- include "loki.gatewayLabels" . | nindent 4 }}
    {{- range $labelKey, $labelValue := .Values.gateway.ingress.labels }}
    {{ $labelKey }}: {{ $labelValue | toYaml }}
    {{- end }}
  {{- with .Values.gateway.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  {{- if and $ingressSupportsIngressClassName .Values.gateway.ingress.ingressClassName }}
  ingressClassName: {{ .Values.gateway.ingress.ingressClassName }}
  {{- end -}}
  {{- if .Values.gateway.ingress.tls }}
  tls:
    {{- range .Values.gateway.ingress.tls }}
    - hosts:
        {{- range .hosts }}
        - {{ tpl . $ | quote }}
        {{- end }}
      {{- with .secretName }}
      secretName: {{ . }}
      {{- end }}
    {{- end }}
  {{- end }}
  rules:
    {{- range .Values.gateway.ingress.hosts }}
    - host: {{ tpl .host $ | quote }}
      http:
        paths:
          {{- range .paths }}
          - path: {{ .path }}
            {{- if $ingressSupportsPathType }}
            pathType: {{ .pathType }}
            {{- end }}
            backend:
              {{- if $ingressApiIsStable }}
              service:
                name: {{ include "loki.gatewayFullname" $ }}
                port:
                  number: {{ $.Values.gateway.service.port }}
              {{- else }}
              serviceName: {{ include "loki.gatewayFullname" $ }}
              servicePort: {{ $.Values.gateway.service.port }}
              {{- end }}
          {{- end }}
    {{- end }}
{{- end }}
{{- end }}