flower-networkpolicy.yaml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 Flower NetworkPolicy
  19. #################################
  20. {{- if .Values.flower.enabled }}
  21. {{- $celery_executors := list "CeleryExecutor" "CeleryKubernetesExecutor"}}
  22. {{- if and .Values.networkPolicies.enabled (has .Values.executor $celery_executors) }}
  23. {{- $from := or .Values.flower.networkPolicy.ingress.from .Values.flower.extraNetworkPolicies }}
  24. apiVersion: networking.k8s.io/v1
  25. kind: NetworkPolicy
  26. metadata:
  27. name: {{ .Release.Name }}-flower-policy
  28. labels:
  29. tier: airflow
  30. component: airflow-flower-policy
  31. release: {{ .Release.Name }}
  32. chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  33. heritage: {{ .Release.Service }}
  34. {{- with .Values.labels }}
  35. {{ toYaml . | indent 4 }}
  36. {{- end }}
  37. spec:
  38. podSelector:
  39. matchLabels:
  40. tier: airflow
  41. component: flower
  42. release: {{ .Release.Name }}
  43. policyTypes:
  44. - Ingress
  45. {{- if $from }}
  46. ingress:
  47. - from:
  48. {{ toYaml $from | indent 6 }}
  49. ports:
  50. {{ range .Values.flower.networkPolicy.ingress.ports }}
  51. -
  52. {{- range $key, $val := . }}
  53. {{ $key }}: {{ tpl (toString $val) $ }}
  54. {{- end }}
  55. {{- end }}
  56. {{- end }}
  57. {{- end }}
  58. {{- end }}