diff --git a/cluster/charts/rook-ceph/templates/_helpers.tpl b/cluster/charts/rook-ceph/templates/_helpers.tpl index 529b4901755eb..54ec5660befd0 100644 --- a/cluster/charts/rook-ceph/templates/_helpers.tpl +++ b/cluster/charts/rook-ceph/templates/_helpers.tpl @@ -18,9 +18,16 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{/* Define imagePullSecrets option to pass to all service accounts */}} -{{- define "imagePullSecrets" }} +{{- define "imagePullSecrets" -}} {{- if .Values.imagePullSecrets -}} imagePullSecrets: {{ toYaml .Values.imagePullSecrets }} {{- end -}} + +{{/* +Common labels +*/}} +{{- define "labels" -}} +app.kubernetes.io/operator: rook +app.kubernetes.io/storage-backend: ceph{{- end -}} {{- end -}} diff --git a/cluster/charts/rook-ceph/templates/clusterrole.yaml b/cluster/charts/rook-ceph/templates/clusterrole.yaml index d9565da51fbf9..4358d33ced44f 100644 --- a/cluster/charts/rook-ceph/templates/clusterrole.yaml +++ b/cluster/charts/rook-ceph/templates/clusterrole.yaml @@ -4,8 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: rook-ceph-system labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} rules: # Most resources are represented by a string representation of their name, such as “pods”, just as it appears in the URL for the relevant API endpoint. # However, some Kubernetes APIs involve a “subresource”, such as the logs for a pod. [...] @@ -24,8 +23,7 @@ kind: ClusterRole metadata: name: rook-ceph-cluster-mgmt labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} rules: - apiGroups: - "" @@ -54,8 +52,7 @@ kind: ClusterRole metadata: name: rook-ceph-global labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} rules: - apiGroups: - "" @@ -174,8 +171,7 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: rook-ceph-mgr-cluster labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} rules: - apiGroups: - "" @@ -226,9 +222,7 @@ kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: name: rook-ceph-object-bucket - labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} rules: - apiGroups: - "" @@ -272,8 +266,7 @@ kind: ClusterRole metadata: name: rook-ceph-agent-mount labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} rules: - apiGroups: - "" @@ -458,8 +451,7 @@ kind: ClusterRole metadata: name: 'psp:rook' labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" rules: - apiGroups: diff --git a/cluster/charts/rook-ceph/templates/clusterrolebinding.yaml b/cluster/charts/rook-ceph/templates/clusterrolebinding.yaml index d3c22ca74c696..209e76bdb6d19 100644 --- a/cluster/charts/rook-ceph/templates/clusterrolebinding.yaml +++ b/cluster/charts/rook-ceph/templates/clusterrolebinding.yaml @@ -4,8 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: rook-ceph-system labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole @@ -21,8 +20,7 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: rook-ceph-global labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" roleRef: apiGroup: rbac.authorization.k8s.io @@ -120,8 +118,7 @@ kind: ClusterRoleBinding metadata: name: rook-ceph-system-psp labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" roleRef: apiGroup: rbac.authorization.k8s.io @@ -138,8 +135,7 @@ metadata: name: rook-ceph-default-psp namespace: {{ .Release.Namespace }} labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" roleRef: apiGroup: rbac.authorization.k8s.io @@ -155,8 +151,7 @@ kind: ClusterRoleBinding metadata: name: rook-ceph-system-psp-users labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" roleRef: apiGroup: rbac.authorization.k8s.io diff --git a/cluster/charts/rook-ceph/templates/deployment.yaml b/cluster/charts/rook-ceph/templates/deployment.yaml index 7efb599ebe433..5a53d65f97f0f 100644 --- a/cluster/charts/rook-ceph/templates/deployment.yaml +++ b/cluster/charts/rook-ceph/templates/deployment.yaml @@ -3,8 +3,7 @@ kind: Deployment metadata: name: rook-ceph-operator labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: replicas: 1 diff --git a/cluster/charts/rook-ceph/templates/role.yaml b/cluster/charts/rook-ceph/templates/role.yaml index 70f899c5dc40d..a981c3efcfc3e 100644 --- a/cluster/charts/rook-ceph/templates/role.yaml +++ b/cluster/charts/rook-ceph/templates/role.yaml @@ -6,8 +6,7 @@ metadata: name: rook-ceph-system namespace: {{ .Release.Namespace }} labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} rules: - apiGroups: - "" diff --git a/cluster/charts/rook-ceph/templates/rolebinding.yaml b/cluster/charts/rook-ceph/templates/rolebinding.yaml index aeda4636ad7be..b7bd7d9257bde 100644 --- a/cluster/charts/rook-ceph/templates/rolebinding.yaml +++ b/cluster/charts/rook-ceph/templates/rolebinding.yaml @@ -6,8 +6,7 @@ metadata: name: rook-ceph-system namespace: {{ .Release.Namespace }} labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role diff --git a/cluster/charts/rook-ceph/templates/serviceaccount.yaml b/cluster/charts/rook-ceph/templates/serviceaccount.yaml index f9317cb0a8962..70f14e5662bf2 100644 --- a/cluster/charts/rook-ceph/templates/serviceaccount.yaml +++ b/cluster/charts/rook-ceph/templates/serviceaccount.yaml @@ -5,8 +5,7 @@ metadata: name: rook-ceph-system namespace: {{ .Release.Namespace }} labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" {{ template "imagePullSecrets" . }} --- @@ -17,8 +16,7 @@ metadata: name: rook-ceph-osd namespace: {{ .Release.Namespace }} labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" {{ template "imagePullSecrets" . }} --- @@ -29,8 +27,7 @@ metadata: name: rook-ceph-mgr namespace: {{ .Release.Namespace }} labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" {{ template "imagePullSecrets" . }} --- @@ -40,8 +37,7 @@ metadata: name: rook-ceph-cmd-reporter namespace: {{ .Release.Namespace }} labels: - operator: rook - storage-backend: ceph + {{- template "labels" . -}} chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" {{ template "imagePullSecrets" . }} --- diff --git a/tests/integration/ceph_base_file_test.go b/tests/integration/ceph_base_file_test.go index f2acba483cb3a..f714ffefb4dca 100644 --- a/tests/integration/ceph_base_file_test.go +++ b/tests/integration/ceph_base_file_test.go @@ -555,8 +555,8 @@ kind: ClusterRoleBinding metadata: name: rook-ceph-agent-mount labels: - operator: rook - storage-backend: ceph + app.kubernetes.io/operator: rook + app.kubernetes.io/storage-backend: ceph roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole