Skip to content

Commit aec7a56

Browse files
committed
chore(airflow): add networkPolicy enabled
1 parent 64ff722 commit aec7a56

7 files changed

Lines changed: 123 additions & 6 deletions

File tree

addons/airflow/2/chart/airflow/templates/_helpers.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,17 +349,17 @@ Add environment variables to configure redis values
349349
*/}}
350350
{{- define "airflow.configure.redis" -}}
351351
{{- if (not (or (eq .Values.executor "KubernetesExecutor" ) (eq .Values.executor "LocalKubernetesExecutor" ))) }}
352-
- name: CELERY_BROKER_URL
352+
- name: AIRFLOW_CELERY_BROKER_URL
353353
valueFrom:
354354
secretKeyRef:
355355
name: {{ printf "%s-%s" .Release.Name "celerybroker" }}
356-
key: celeryBrokerUrl
356+
key: celery-broker-url
357357
{{- if .Values.celeryBrokerTransportOption }}
358-
- name: CELERY_BROKER_TRANSPORT_OPTION
358+
- name: AIRFLOW_CELERY_BROKER_TRANSPORT_OPTIONS
359359
valueFrom:
360360
secretKeyRef:
361361
name: {{ printf "%s-%s" .Release.Name "celerybroker" }}
362-
key: celeryBrokerTransportOption
362+
key: celery-broker-transport-option
363363
{{- end }}
364364
{{- end }}
365365
{{- end -}}

addons/airflow/2/chart/airflow/templates/config/secret-external-broker.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ metadata:
1515
type: Opaque
1616
data:
1717
{{- if .Values.celeryBrokerUrl }}
18-
celeryBrokerUrl: {{ .Values.celeryBrokerUrl | b64enc | quote }}
18+
celery-broker-url: {{ .Values.celeryBrokerUrl | b64enc | quote }}
1919
{{- end }}
2020
{{- if .Values.celeryBrokerTransportOption }}
21-
celeryBrokerTransportOption: {{ .Values.celeryBrokerTransportOption | b64enc | quote }}
21+
celery-broker-transport-option: {{ .Values.celeryBrokerTransportOption | b64enc | quote }}
2222
{{- end }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{- if .Values.networkPolicy.enabled }}
2+
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
3+
kind: NetworkPolicy
4+
metadata:
5+
name: {{ printf "%s-scheduler" (include "common.names.fullname" .) }}
6+
namespace: {{ .Release.Namespace | quote }}
7+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
8+
app.kubernetes.io/component:
9+
{{- if .Values.commonLabels }}
10+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11+
{{- end }}
12+
{{- if .Values.commonAnnotations }}
13+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
14+
{{- end }}
15+
spec:
16+
podSelector:
17+
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
18+
app.kubernetes.io/component: scheduler
19+
ingress:
20+
{{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }}
21+
- from:
22+
{{- if .Values.networkPolicy.allowCurrentNamespace }}
23+
- namespaceSelector:
24+
matchLabels:
25+
kubernetes.io/metadata.name: {{ .Release.Namespace }}
26+
{{- end }}
27+
{{- range $namespace := .Values.networkPolicy.allowNamespaces }}
28+
{{- if $namespace }}
29+
- namespaceSelector:
30+
matchLabels:
31+
kubernetes.io/metadata.name: {{ $namespace }}
32+
{{- end }}
33+
{{- end }}
34+
{{- end }}
35+
{{- end }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{- if or .Values.networkPolicy.enabled (eq .Values.service.type "ClusterIP" ) }}
2+
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
3+
kind: NetworkPolicy
4+
metadata:
5+
name: {{ printf "%s-web" (include "common.names.fullname" .) }}
6+
namespace: {{ .Release.Namespace | quote }}
7+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
8+
app.kubernetes.io/component:
9+
{{- if .Values.commonLabels }}
10+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11+
{{- end }}
12+
{{- if .Values.commonAnnotations }}
13+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
14+
{{- end }}
15+
spec:
16+
podSelector:
17+
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
18+
app.kubernetes.io/component: web
19+
ingress:
20+
{{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }}
21+
- from:
22+
{{- if .Values.networkPolicy.allowCurrentNamespace }}
23+
- namespaceSelector:
24+
matchLabels:
25+
kubernetes.io/metadata.name: {{ .Release.Namespace }}
26+
{{- end }}
27+
{{- range $namespace := .Values.networkPolicy.allowNamespaces }}
28+
{{- if $namespace }}
29+
- namespaceSelector:
30+
matchLabels:
31+
kubernetes.io/metadata.name: {{ $namespace }}
32+
{{- end }}
33+
{{- end }}
34+
{{- end }}
35+
{{- end }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{- if .Values.networkPolicy.enabled }}
2+
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
3+
kind: NetworkPolicy
4+
metadata:
5+
name: {{ printf "%s-worker" (include "common.names.fullname" .) }}
6+
namespace: {{ .Release.Namespace | quote }}
7+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
8+
app.kubernetes.io/component: worker
9+
{{- if .Values.commonLabels }}
10+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
11+
{{- end }}
12+
{{- if .Values.commonAnnotations }}
13+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
14+
{{- end }}
15+
spec:
16+
podSelector:
17+
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
18+
app.kubernetes.io/component: worker
19+
ingress:
20+
{{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }}
21+
- from:
22+
{{- if .Values.networkPolicy.allowCurrentNamespace }}
23+
- namespaceSelector:
24+
matchLabels:
25+
kubernetes.io/metadata.name: {{ .Release.Namespace }}
26+
{{- end }}
27+
{{- range $namespace := .Values.networkPolicy.allowNamespaces }}
28+
{{- if $namespace }}
29+
- namespaceSelector:
30+
matchLabels:
31+
kubernetes.io/metadata.name: {{ $namespace }}
32+
{{- end }}
33+
{{- end }}
34+
{{- end }}
35+
{{- end }}

addons/airflow/2/chart/airflow/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,15 @@ statsd:
14401440
podAnnotations: {}
14411441
env: []
14421442

1443+
## Add networkpolicies
1444+
##
1445+
networkPolicy:
1446+
## @param networkPolicy.enabled Enable network policies
1447+
##
1448+
enabled: true
1449+
allowCurrentNamespace: true
1450+
allowNamespaces: []
1451+
14431452
## @section Airflow database parameters
14441453

14451454
## PostgreSQL chart configuration

addons/airflow/2/meta.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ allow_parameters:
4242
- name: "statsd.enable"
4343
required: false
4444
description: "statsd enable or not config for values.yaml"
45+
- name: "networkPolicy.allowNamespaces"
46+
required: false
47+
description: "networkPolicy allowNamespaces config for values.yaml"
4548
- name: "externalDatabase"
4649
required: true
4750
description: "externalDatabase config for values.yaml"

0 commit comments

Comments
 (0)