Skip to content

Commit

Permalink
Rename cluster-wide resources to use namespace as prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
mewa committed Mar 5, 2024
1 parent dfa6993 commit 8c913ff
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions chart/newsfragments/37197.significant.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Fixed name clashes when using multiple Airflow deployments in ``multiNamespaceMode`` across several namespaces.

``ClusterRole``s and ``ClusterRoleBinding``s created when ``multiNamespaceMode`` is enabled have been renamed to ensure unique names:
* ``{{ include "airflow.fullname" . }}-pod-launcher-role`` has been renamed to ``{{ include "airflow.fullname" . }}-{{ .Release.Namespace }}-pod-launcher-role``
* ``{{ include "airflow.fullname" . }}-pod-launcher-rolebinding`` has been renamed to ``{{ include "airflow.fullname" . }}-{{ .Release.Namespace }}-pod-launcher-rolebinding``
* ``{{ include "airflow.fullname" . }}-pod-log-reader-role`` has been renamed to ``{{ include "airflow.fullname" . }}-{{ .Release.Namespace }}-pod-log-reader-role``
* ``{{ include "airflow.fullname" . }}-pod-log-reader-rolebinding`` has been renamed to ``{{ include "airflow.fullname" . }}-{{ .Release.Namespace }}-pod-log-reader-rolebinding``
* ``{{ include "airflow.fullname" . }}-scc-rolebinding`` has been renamed to ``{{ include "airflow.fullname" . }}-{{ .Release.Namespace }}-scc-rolebinding``
* ``{{ include "airflow.fullname" . }}-pod-launcher-role`` has been renamed to ``{{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-pod-launcher-role``
* ``{{ include "airflow.fullname" . }}-pod-launcher-rolebinding`` has been renamed to ``{{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-pod-launcher-rolebinding``
* ``{{ include "airflow.fullname" . }}-pod-log-reader-role`` has been renamed to ``{{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-pod-log-reader-role``
* ``{{ include "airflow.fullname" . }}-pod-log-reader-rolebinding`` has been renamed to ``{{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-pod-log-reader-rolebinding``
* ``{{ include "airflow.fullname" . }}-scc-rolebinding`` has been renamed to ``{{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-scc-rolebinding``
2 changes: 1 addition & 1 deletion chart/templates/rbac/pod-launcher-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ metadata:
name: {{ include "airflow.fullname" . }}-pod-launcher-role
namespace: "{{ .Release.Namespace }}"
{{- else }}
name: {{ include "airflow.fullname" . }}-{{ .Release.Namespace }}-pod-launcher-role
name: {{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-pod-launcher-role
{{- end }}
labels:
tier: airflow
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/rbac/pod-launcher-rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ metadata:
namespace: "{{ .Release.Namespace }}"
name: {{ include "airflow.fullname" . }}-pod-launcher-rolebinding
{{- else }}
name: {{ include "airflow.fullname" . }}-{{ .Release.Namespace }}-pod-launcher-rolebinding
name: {{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-pod-launcher-rolebinding
{{- end }}
labels:
tier: airflow
Expand All @@ -51,7 +51,7 @@ roleRef:
apiGroup: rbac.authorization.k8s.io
{{- if .Values.multiNamespaceMode }}
kind: ClusterRole
name: {{ include "airflow.fullname" . }}-{{ .Release.Namespace }}-pod-launcher-role
name: {{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-pod-launcher-role
{{- else }}
kind: Role
name: {{ include "airflow.fullname" . }}-pod-launcher-role
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/rbac/pod-log-reader-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ metadata:
name: {{ include "airflow.fullname" . }}-pod-log-reader-role
namespace: "{{ .Release.Namespace }}"
{{- else }}
name: {{ include "airflow.fullname" . }}-{{ .Release.Namespace}}-pod-log-reader-role
name: {{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-pod-log-reader-role
{{- end }}
labels:
tier: airflow
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/rbac/pod-log-reader-rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ metadata:
namespace: "{{ .Release.Namespace }}"
name: {{ include "airflow.fullname" . }}-pod-log-reader-rolebinding
{{- else }}
name: {{ include "airflow.fullname" . }}-{{ .Release.Namespace }}-pod-log-reader-rolebinding
name: {{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-pod-log-reader-rolebinding
{{- end }}
labels:
tier: airflow
Expand All @@ -49,7 +49,7 @@ roleRef:
apiGroup: rbac.authorization.k8s.io
{{- if .Values.multiNamespaceMode }}
kind: ClusterRole
name: {{ include "airflow.fullname" . }}-{{ .Release.Namespace }}-pod-log-reader-role
name: {{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-pod-log-reader-role
{{- else }}
kind: Role
name: {{ include "airflow.fullname" . }}-pod-log-reader-role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ metadata:
name: {{ include "airflow.fullname" . }}-scc-rolebinding
namespace: "{{ .Release.Namespace }}"
{{- else }}
name: {{ include "airflow.fullname" . }}-{{ .Release.Namespace }}-scc-rolebinding
name: {{ .Release.Namespace }}-{{ include "airflow.fullname" . }}-scc-rolebinding
{{- end }}
labels:
tier: airflow
Expand Down
12 changes: 6 additions & 6 deletions helm_tests/airflow_aux/test_pod_launcher_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def test_pod_launcher_role(self, executor, rbac, allow, expected_accounts):
(
True,
"namespace",
"release-name-namespace-pod-launcher-role",
"release-name-namespace-pod-launcher-rolebinding",
"namespace-release-name-pod-launcher-role",
"namespace-release-name-pod-launcher-rolebinding",
),
(
True,
"other-ns",
"release-name-other-ns-pod-launcher-role",
"release-name-other-ns-pod-launcher-rolebinding",
"other-ns-release-name-pod-launcher-role",
"other-ns-release-name-pod-launcher-rolebinding",
),
(False, "namespace", "release-name-pod-launcher-role", "release-name-pod-launcher-rolebinding"),
],
Expand Down Expand Up @@ -95,8 +95,8 @@ def test_pod_launcher_rolebinding_multi_namespace(
@pytest.mark.parametrize(
"multiNamespaceMode, namespace, expectedRole",
[
(True, "namespace", "release-name-namespace-pod-launcher-role"),
(True, "other-ns", "release-name-other-ns-pod-launcher-role"),
(True, "namespace", "namespace-release-name-pod-launcher-role"),
(True, "other-ns", "other-ns-release-name-pod-launcher-role"),
(False, "namespace", "release-name-pod-launcher-role"),
],
)
Expand Down
12 changes: 6 additions & 6 deletions helm_tests/security/test_rbac_pod_log_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ def test_pod_log_reader_role(self, triggerer, webserver, expected):
(
True,
"namespace",
"release-name-namespace-pod-log-reader-role",
"release-name-namespace-pod-log-reader-rolebinding",
"namespace-release-name-pod-log-reader-role",
"namespace-release-name-pod-log-reader-rolebinding",
),
(
True,
"other-ns",
"release-name-other-ns-pod-log-reader-role",
"release-name-other-ns-pod-log-reader-rolebinding",
"other-ns-release-name-pod-log-reader-role",
"other-ns-release-name-pod-log-reader-rolebinding",
),
(
False,
Expand Down Expand Up @@ -115,8 +115,8 @@ def test_pod_log_reader_rolebinding_multi_namespace(
@pytest.mark.parametrize(
"multiNamespaceMode, namespace, expectedRole",
[
(True, "namespace", "release-name-namespace-pod-log-reader-role"),
(True, "other-ns", "release-name-other-ns-pod-log-reader-role"),
(True, "namespace", "namespace-release-name-pod-log-reader-role"),
(True, "other-ns", "other-ns-release-name-pod-log-reader-role"),
(False, "namespace", "release-name-pod-log-reader-role"),
],
)
Expand Down
4 changes: 2 additions & 2 deletions helm_tests/security/test_scc_rolebinding.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def test_create_scc(self, rbac_enabled, scc_enabled, created):
@pytest.mark.parametrize(
"rbac_enabled,scc_enabled,created,namespace,expected_name",
[
(True, True, True, "default", "release-name-default-scc-rolebinding"),
(True, True, True, "other-ns", "release-name-other-ns-scc-rolebinding"),
(True, True, True, "default", "default-release-name-scc-rolebinding"),
(True, True, True, "other-ns", "other-ns-release-name-scc-rolebinding"),
],
)
def test_create_scc_multinamespace(self, rbac_enabled, scc_enabled, created, namespace, expected_name):
Expand Down

0 comments on commit 8c913ff

Please sign in to comment.