helmfile.yaml 5.93 KB
bases:
  - ../common/environments.yaml

---

repositories:
  - name: bedag
    url: https://bedag.github.io/helm-charts/

releases:
  - name: http-support
    namespace: {{ .Values.namespace }}
    chart: charts/http-support
    dependencies:
      - chart: bedag/raw
        alias: raw
        version: {{ $.Values.versions.raw }}
    values:
      - raw:
          resources:
            {{- range $redirect_index, $redirect := .Values.redirect }}
              {{- if $.Values.istio.enabled }}
            - apiVersion: networking.istio.io/v1alpha3
              kind: VirtualService
              metadata:
                name: http-support-redirect-{{ $redirect_index }}-{{ index $redirect.hosts 0 }}
              spec:
                hosts:
                  {{- $redirect.hosts | toYaml | nindent 20 }}
                gateways:
                  - {{ $.Values.istio.gateway }}
                http:
                  - match:
                      - uri:
                          prefix: /
                    redirect:
                      redirectCode: 302
                      authority: {{ $redirect.target }}
              {{- end }}
              {{- if $.Values.gatewayAPI.enabled }}
            - apiVersion: gateway.networking.k8s.io/v1beta1
              kind: HTTPRoute
              metadata:
                name: http-support-redirect-{{ $redirect_index }}-{{ index $redirect.hosts 0 }}
              spec:
                parentRefs:
                  - name: {{ $.Values.gatewayAPI.gateway }}
                hostnames:
                  {{- $redirect.hosts | toYaml | nindent 20 }}
                rules:
                  - matches:
                      - path:
                          type: PathPrefix
                          value: /
                    filters:
                      - type: RequestRedirect
                        requestRedirect:
                          scheme: https
                          statusCode: 302
                          hostname: {{ $redirect.target }}
              {{- end }}
            {{- end }}
            - apiVersion: v1
              kind: ConfigMap
              metadata:
                name: http-support-nginx-configs
              data:
                {{- range $proxy_index, $proxy := .Values.proxy }}
                  proxy-{{ $proxy_index }}.conf: |-
                    {{- $proxy.config | nindent 20 }}
                {{- end }}
                  status.conf: |-
                    server {
                            server_name _;
                            listen 80 default;

                            location /status.html {
                                    return 200 'OK';
                                    add_header Content-Type text/plain;
                                    access_log /dev/null;
                            }
                    }
            {{- range $proxy_index, $proxy := .Values.proxy }}
              {{- if $.Values.istio.enabled }}
            - apiVersion: networking.istio.io/v1alpha3
              kind: VirtualService
              metadata:
                name: http-support-proxy-{{ $proxy_index }}-{{ index $proxy.frontend.host 0 }}
              spec:
                hosts:
                  - {{ $proxy.frontend.host }}
                gateways:
                  - {{ $.Values.istio.gateway }}
                http:
                  - match:
                      - uri:
                          prefix: /
                    rewrite:
                      authority: {{ $proxy.authority }}
                    route:
                      - destination:
                          port:
                            number: 80
                          host: http-support-proxy
                        headers:
                          request:
                            set:
                              x-frontend-host: {{ $proxy.frontend.host }}
                              x-frontend-stub: {{ $proxy.frontend.stub }}
                              x-backend-host: {{ $proxy.backend.host }}
                              x-backend-stub: {{ $proxy.backend.stub }}
                              x-backend-address: {{ $proxy.backend.address }}
                              x-backend-scheme: {{ $proxy.backend.scheme }}
              {{- end }}
              {{- if $.Values.gatewayAPI.enabled }}
            - apiVersion: gateway.networking.k8s.io/v1beta1
              kind: HTTPRoute
              metadata:
                name: http-support-proxy-{{ $proxy_index }}-{{ index $proxy.frontend.host 0 }}
              spec:
                parentRefs:
                  - name: {{ $.Values.gatewayAPI.gateway }}
                hostnames:
                  - {{ $proxy.frontend.host }}
                rules:
                  - matches:
                      - path:
                          type: PathPrefix
                          value: /
                    filters:
                      - type: URLRewrite
                        urlRewrite:
                          hostname: {{ $proxy.authority }}
                      - type: RequestHeaderModifier
                        requestHeaderModifier:
                          set:
                            - name: x-frontend-host
                              value: {{ $proxy.frontend.host }}
                            - name: x-frontend-stub
                              value: {{ $proxy.frontend.stub }}
                            - name: x-backend-host
                              value: {{ $proxy.backend.host }}
                            - name: x-backend-stub
                              value: {{ $proxy.backend.stub }}
                            - name: x-backend-address
                              value: {{ $proxy.backend.address }}
                            - name: x-backend-scheme
                              value: {{ $proxy.backend.scheme }}
                    backendRefs:
                      - name: http-support-proxy
                        port: 80
              {{- end }}
            {{- end }}