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

---

repositories:
  - name: istio
    url: https://istio-release.storage.googleapis.com/charts
  - name: bedag
    url: https://bedag.github.io/helm-charts/

releases:
  - name: istio-gateway-{{ .Values.name }}
    namespace: istio-system
    chart: bedag/raw
    version: {{ $.Values.version.raw }}
    disableValidationOnInstall: true
    dependencies:
      - chart: istio/gateway
        alias: gateway
        version: {{ $.Values.version.istio }}
    values:
      - gateway: {}
        resources:
          - apiVersion: v1
            kind: ConfigMap
            metadata:
              name: istio-gateway-foo-{{ .Values.name }}
            data:
              foo: "bar"
    {{- range $gateway_index, $gateway := .Values.gateways }}
          - apiVersion: networking.istio.io/v1beta1
            kind: Gateway
            metadata:
              name: istio-gateway-{{ $gateway.name }}
            spec:
              selector:
                app: istio-gateway-{{ $.Values.name }}
                istio: gateway-{{ $.Values.name }}
              servers:
      {{- range $host_index, $host := $gateway.hosts }}
                - port:
                    name: http-{{ $host.name }}
                    number: 80
                    protocol: HTTP
                  hosts:
                    - {{ $host.name | quote }}
        {{- if hasKey $host "tls" }}
                - port:
                    name: https-{{ $host.name }}
                    number: 443
                    protocol: HTTPS
                  hosts:
                    - {{ $host.name | quote }}
                  tls:
                    # TODO: Switch certs based on wildcard or not
          {{- if hasKey $host.tls "certRef" }}
                    credentialName: {{ $host.tls.certRef | quote }}
          {{- else if hasPrefix "*." $host.name }}
                    credentialName: istio-gateway-wildcardcert-{{ $host.name | replace "*." "" }}
          {{- else }}
                    credentialName: istio-gateway-cert-{{ $host.name }}
          {{- end }}
                    mode: {{ $host.tls.mode | quote }}
        {{- end }}
      {{- end }}
      {{- range $host_index, $host := $gateway.hosts }}
        {{- if hasKey $host "tls" }}
          {{- if not (hasKey $host.tls "certRef") }}
          - apiVersion: cert-manager.io/v1
            kind: Certificate
            metadata:
            {{- if hasPrefix "*." $host.name }}
              name: istio-gateway-wildcardcert-{{ $host.name | replace "*." "" }}
            {{- else }}
              name: istio-gateway-cert-{{ $host.name }}
            {{- end }}
            spec:
            {{- if hasPrefix "*." $host.name }}
              secretName: istio-gateway-wildcardcert-{{ $host.name | replace "*i." "" }}
            {{- else }}
              secretName: istio-gateway-cert-{{ $host.name }}
            {{- end }}
              dnsNames:
                - {{ $host.name | quote }}
              issuerRef: {{ $host.tls.issuerRef | toYaml | nindent 18 }}
          {{- end }}
        {{- end }}
      {{- end }}
    {{- end }}
---