webserver-ingress.yaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. ################################
  18. ## Airflow Webserver Ingress
  19. #################################
  20. {{- if or .Values.ingress.web.enabled .Values.ingress.enabled }}
  21. {{- $apiIsStable := semverCompare ">= 1.19.x" (include "kubeVersion" .) -}}
  22. {{- if $apiIsStable }}
  23. apiVersion: networking.k8s.io/v1
  24. {{- else }}
  25. apiVersion: networking.k8s.io/v1beta1
  26. {{- end }}
  27. kind: Ingress
  28. metadata:
  29. name: {{ .Release.Name }}-airflow-ingress
  30. labels:
  31. tier: airflow
  32. component: airflow-ingress
  33. release: {{ .Release.Name }}
  34. chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  35. heritage: {{ .Release.Service }}
  36. {{- with .Values.labels }}
  37. {{- toYaml . | nindent 4 }}
  38. {{- end }}
  39. {{- with .Values.ingress.web.annotations }}
  40. annotations:
  41. {{- toYaml . | nindent 4 }}
  42. {{- end }}
  43. spec:
  44. {{- if and .Values.ingress.web.hosts (.Values.ingress.web.hosts | first | kindIs "string" | not) }}
  45. {{- $anyTlsHosts := false -}}
  46. {{- range .Values.ingress.web.hosts }}
  47. {{- if .tls }}
  48. {{- if .tls.enabled }}
  49. {{- $anyTlsHosts = true -}}
  50. {{- end }}
  51. {{- end }}
  52. {{- end }}
  53. {{- if $anyTlsHosts }}
  54. tls:
  55. {{- range .Values.ingress.web.hosts }}
  56. {{- if .tls }}
  57. {{- if .tls.enabled }}
  58. - hosts:
  59. - {{ .name | quote }}
  60. secretName: {{ .tls.secretName }}
  61. {{- end }}
  62. {{- end }}
  63. {{- end }}
  64. {{- end }}
  65. {{- else if .Values.ingress.web.tls.enabled }}
  66. tls:
  67. - hosts:
  68. {{- .Values.ingress.web.hosts | default (list .Values.ingress.web.host) | toYaml | nindent 8 }}
  69. secretName: {{ .Values.ingress.web.tls.secretName }}
  70. {{- end }}
  71. rules:
  72. {{- range .Values.ingress.web.hosts | default (list .Values.ingress.web.host) }}
  73. - http:
  74. paths:
  75. {{- range $.Values.ingress.web.precedingPaths }}
  76. - path: {{ .path }}
  77. {{- if $apiIsStable }}
  78. pathType: {{ .pathType }}
  79. {{- end }}
  80. backend:
  81. {{- if $apiIsStable }}
  82. service:
  83. name: {{ .serviceName }}
  84. port:
  85. name: {{ .servicePort }}
  86. {{- else }}
  87. serviceName: {{ .serviceName }}
  88. servicePort: {{ .servicePort }}
  89. {{- end }}
  90. {{- end }}
  91. - backend:
  92. {{- if $apiIsStable }}
  93. service:
  94. name: {{ $.Release.Name }}-webserver
  95. port:
  96. name: airflow-ui
  97. {{- else }}
  98. serviceName: {{ $.Release.Name }}-webserver
  99. servicePort: airflow-ui
  100. {{- end }}
  101. {{- if $.Values.ingress.web.path }}
  102. path: {{ $.Values.ingress.web.path }}
  103. {{- if $apiIsStable }}
  104. pathType: {{ $.Values.ingress.web.pathType }}
  105. {{- end }}
  106. {{- end }}
  107. {{- range $.Values.ingress.web.succeedingPaths }}
  108. - path: {{ .path }}
  109. {{- if $apiIsStable }}
  110. pathType: {{ .pathType }}
  111. {{- end }}
  112. backend:
  113. {{- if $apiIsStable }}
  114. service:
  115. name: {{ .serviceName }}
  116. port:
  117. name: {{ .servicePort }}
  118. {{- else }}
  119. serviceName: {{ .serviceName }}
  120. servicePort: {{ .servicePort }}
  121. {{- end }}
  122. {{- end }}
  123. {{- $hostname := . -}}
  124. {{- if . | kindIs "string" | not }}
  125. {{- $hostname = .name -}}
  126. {{- end }}
  127. {{- if $hostname }}
  128. host: {{ $hostname | quote }}
  129. {{- end }}
  130. {{- end }}
  131. {{- if and .Values.ingress.web.ingressClassName $apiIsStable }}
  132. ingressClassName: {{ .Values.ingress.web.ingressClassName }}
  133. {{- end }}
  134. {{- end }}