Skip to content

Commit

Permalink
build: create resources with k8s recommended labels
Browse files Browse the repository at this point in the history
Adding Recommended Labels on the rook resources,
for better visuals and management of k8s object

Closes: rook#8400
Signed-off-by: parth-gr <paarora@redhat.com>
  • Loading branch information
parth-gr committed Sep 14, 2021
1 parent 235d5a3 commit 4cd58d5
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 42 deletions.
10 changes: 9 additions & 1 deletion cluster/charts/rook-ceph/templates/_helpers.tpl
Expand Up @@ -18,9 +18,17 @@ 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 -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "rook-ceph.labels" -}}
app.kubernetes.io/operator: {{ "rook" -}}
app.kubernetes.io/storage-backend: {{ "ceph" -}}
{{- end -}}
29 changes: 14 additions & 15 deletions cluster/charts/rook-ceph/templates/clusterrole.yaml
Expand Up @@ -4,8 +4,8 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: rook-ceph-system
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

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. [...]
Expand All @@ -24,8 +24,8 @@ kind: ClusterRole
metadata:
name: rook-ceph-cluster-mgmt
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -54,8 +54,8 @@ kind: ClusterRole
metadata:
name: rook-ceph-global
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -174,8 +174,8 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: rook-ceph-mgr-cluster
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -226,9 +226,8 @@ kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: rook-ceph-object-bucket
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -272,8 +271,8 @@ kind: ClusterRole
metadata:
name: rook-ceph-agent-mount
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -458,8 +457,8 @@ kind: ClusterRole
metadata:
name: 'psp:rook'
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
rules:
- apiGroups:
Expand Down
20 changes: 10 additions & 10 deletions cluster/charts/rook-ceph/templates/clusterrolebinding.yaml
Expand Up @@ -4,8 +4,8 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: rook-ceph-system
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand All @@ -21,8 +21,8 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: rook-ceph-global
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down Expand Up @@ -120,8 +120,8 @@ kind: ClusterRoleBinding
metadata:
name: rook-ceph-system-psp
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand All @@ -138,8 +138,8 @@ metadata:
name: rook-ceph-default-psp
namespace: {{ .Release.Namespace }}
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand All @@ -155,8 +155,8 @@ kind: ClusterRoleBinding
metadata:
name: rook-ceph-system-psp-users
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
4 changes: 2 additions & 2 deletions cluster/charts/rook-ceph/templates/deployment.yaml
Expand Up @@ -3,8 +3,8 @@ kind: Deployment
metadata:
name: rook-ceph-operator
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
replicas: 1
Expand Down
4 changes: 2 additions & 2 deletions cluster/charts/rook-ceph/templates/role.yaml
Expand Up @@ -6,8 +6,8 @@ metadata:
name: rook-ceph-system
namespace: {{ .Release.Namespace }}
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

rules:
- apiGroups:
- ""
Expand Down
3 changes: 1 addition & 2 deletions cluster/charts/rook-ceph/templates/rolebinding.yaml
Expand Up @@ -6,8 +6,7 @@ metadata:
name: rook-ceph-system
namespace: {{ .Release.Namespace }}
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
16 changes: 8 additions & 8 deletions cluster/charts/rook-ceph/templates/serviceaccount.yaml
Expand Up @@ -5,8 +5,8 @@ metadata:
name: rook-ceph-system
namespace: {{ .Release.Namespace }}
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{ template "imagePullSecrets" . }}
---
Expand All @@ -17,8 +17,8 @@ metadata:
name: rook-ceph-osd
namespace: {{ .Release.Namespace }}
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{ template "imagePullSecrets" . }}
---
Expand All @@ -29,8 +29,8 @@ metadata:
name: rook-ceph-mgr
namespace: {{ .Release.Namespace }}
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{ template "imagePullSecrets" . }}
---
Expand All @@ -40,8 +40,8 @@ metadata:
name: rook-ceph-cmd-reporter
namespace: {{ .Release.Namespace }}
labels:
operator: rook
storage-backend: ceph
{{- include "rook-ceph.labels" . | nindent 4 }}

chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{ template "imagePullSecrets" . }}
---
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/ceph_base_file_test.go
Expand Up @@ -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
Expand Down

0 comments on commit 4cd58d5

Please sign in to comment.