Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: create rook resources with k8s recommended labels #8678

Merged
merged 1 commit into from Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion build/rbac/keep-rbac-yaml.sh
Expand Up @@ -27,7 +27,9 @@ $YQ eval '
select(.kind == "Role"),
select(.kind == "RoleBinding")
' - | # select all RBAC resource Kinds
$YQ eval 'del(.metadata.labels.chart)' - | # remove the 'chart' label that only applies to Helm-managed resources
$YQ eval 'del(.metadata.labels."helm.sh/chart")' - | # remove the 'helm.sh/chart' label that only applies to Helm-managed resources
$YQ eval 'del(.metadata.labels."app.kubernetes.io/managed-by")' - | # remove the 'labels.app.kubernetes.io/managed-by' label that only applies to Helm-managed resources
$YQ eval 'del(.metadata.labels."app.kubernetes.io/created-by")' - | # remove the 'app.kubernetes.io/created-by' label that only applies to Helm-managed resources
sed '/^$/d' | # remove empty lines caused by yq's display of header/footer comments
sed '/^# Source: /d' | # helm adds '# Source: <file>' comments atop of each yaml doc. Strip these
$YQ eval --split-exp '.kind + " " + .metadata.name + " "' - # split into files by <kind> <name> .yaml
Expand Down
16 changes: 16 additions & 0 deletions build/rbac/rbac.yaml
Expand Up @@ -75,6 +75,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups:
- policy
Expand Down Expand Up @@ -186,6 +187,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -218,6 +220,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -343,6 +346,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -399,6 +403,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups: [""]
resources: ["secrets", "configmaps"]
Expand Down Expand Up @@ -464,6 +469,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
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 Down Expand Up @@ -536,6 +542,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down Expand Up @@ -594,6 +601,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand All @@ -610,6 +618,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down Expand Up @@ -892,6 +901,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -1019,6 +1029,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down Expand Up @@ -1125,6 +1136,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand All @@ -1143,6 +1155,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
---
# Service account for Ceph mgrs
apiVersion: v1
Expand All @@ -1153,6 +1166,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
---
# Service account for Ceph OSDs
apiVersion: v1
Expand All @@ -1164,6 +1178,7 @@ metadata:
operator: rook
storage-backend: ceph
i-am-a-new-label: delete-me
app.kubernetes.io/part-of: rook-ceph-operator
---
# Service account for job that purges OSDs from a Rook-Ceph cluster
apiVersion: v1
Expand All @@ -1181,6 +1196,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
---
# Service account for the CephFS CSI driver
apiVersion: v1
Expand Down
1 change: 1 addition & 0 deletions deploy/charts/library/templates/_cluster-psp.tpl
Expand Up @@ -10,6 +10,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
{{- include "library.rook-ceph.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
3 changes: 3 additions & 0 deletions deploy/charts/library/templates/_cluster-serviceaccount.tpl
Expand Up @@ -12,6 +12,7 @@ metadata:
operator: rook
storage-backend: ceph
i-am-a-new-label: delete-me
{{- include "library.rook-ceph.labels" . | nindent 4 }}
{{ include "library.imagePullSecrets" . }}
---
# Service account for Ceph mgrs
Expand All @@ -23,6 +24,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
{{- include "library.rook-ceph.labels" . | nindent 4 }}
{{ include "library.imagePullSecrets" . }}
---
# Service account for the job that reports the Ceph version in an image
Expand All @@ -34,6 +36,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
{{- include "library.rook-ceph.labels" . | nindent 4 }}
{{ include "library.imagePullSecrets" . }}
---
# Service account for job that purges OSDs from a Rook-Ceph cluster
Expand Down
9 changes: 9 additions & 0 deletions deploy/charts/library/templates/_recommended-labels.tpl
@@ -0,0 +1,9 @@
{{/*
Common labels
*/}}
{{- define "library.rook-ceph.labels" -}}
app.kubernetes.io/part-of: rook-ceph-operator
app.kubernetes.io/managed-by: helm
app.kubernetes.io/created-by: helm
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- end -}}
5 changes: 5 additions & 0 deletions deploy/charts/rook-ceph/templates/clusterrole.yaml
Expand Up @@ -6,6 +6,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
{{- include "library.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 @@ -26,6 +27,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
{{- include "library.rook-ceph.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -58,6 +60,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
{{- include "library.rook-ceph.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -183,6 +186,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
{{- include "library.rook-ceph.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -239,6 +243,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
{{- include "library.rook-ceph.labels" . | nindent 4 }}
rules:
- apiGroups: [""]
resources: ["secrets", "configmaps"]
Expand Down
3 changes: 2 additions & 1 deletion deploy/charts/rook-ceph/templates/clusterrolebinding.yaml
Expand Up @@ -6,6 +6,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
{{- include "library.rook-ceph.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand All @@ -23,7 +24,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "library.rook-ceph.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
4 changes: 2 additions & 2 deletions deploy/charts/rook-ceph/templates/deployment.yaml
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "library.rook-ceph.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
Expand All @@ -15,7 +15,7 @@ spec:
metadata:
labels:
app: rook-ceph-operator
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- if .Values.annotations }}
annotations:
{{ toYaml .Values.annotations | indent 8 }}
Expand Down
4 changes: 2 additions & 2 deletions deploy/charts/rook-ceph/templates/psp.yaml
Expand Up @@ -84,7 +84,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "library.rook-ceph.labels" . | nindent 4 }}
rules:
- apiGroups:
- policy
Expand All @@ -102,7 +102,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "library.rook-ceph.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
1 change: 1 addition & 0 deletions deploy/charts/rook-ceph/templates/role.yaml
Expand Up @@ -8,6 +8,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
{{- include "library.rook-ceph.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
Expand Down
1 change: 1 addition & 0 deletions deploy/charts/rook-ceph/templates/rolebinding.yaml
Expand Up @@ -8,6 +8,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
{{- include "library.rook-ceph.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
2 changes: 1 addition & 1 deletion deploy/charts/rook-ceph/templates/serviceaccount.yaml
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
operator: rook
storage-backend: ceph
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "library.rook-ceph.labels" . | nindent 4 }}
{{ template "library.imagePullSecrets" . }}
---
# Service account for the CephFS CSI driver
Expand Down
38 changes: 38 additions & 0 deletions deploy/examples/common.yaml
Expand Up @@ -84,6 +84,13 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: "psp:rook"
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/name: rook-ceph
app.kubernetes.io/instance: rook-ceph
app.kubernetes.io/component: ceph-csi
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups:
- policy
Expand All @@ -98,6 +105,13 @@ kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: rbd-csi-nodeplugin
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/name: rook-ceph
app.kubernetes.io/instance: rook-ceph
app.kubernetes.io/component: ceph-csi
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups: [""]
resources: ["secrets"]
Expand Down Expand Up @@ -195,6 +209,10 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/name: rook-ceph
app.kubernetes.io/instance: rook-ceph
app.kubernetes.io/component: ceph-csi
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -227,6 +245,10 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/name: rook-ceph
app.kubernetes.io/instance: rook-ceph
app.kubernetes.io/component: ceph-csi
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -352,6 +374,10 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/name: rook-ceph
app.kubernetes.io/instance: rook-ceph
app.kubernetes.io/component: ceph-csi
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -408,6 +434,10 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/name: rook-ceph
app.kubernetes.io/instance: rook-ceph
app.kubernetes.io/component: ceph-csi
app.kubernetes.io/part-of: rook-ceph-operator
rules:
- apiGroups: [""]
resources: ["secrets", "configmaps"]
Expand Down Expand Up @@ -473,6 +503,10 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/name: rook-ceph
app.kubernetes.io/instance: rook-ceph
app.kubernetes.io/component: ceph-csi
app.kubernetes.io/part-of: rook-ceph-operator
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 Down Expand Up @@ -545,6 +579,10 @@ metadata:
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/name: rook-ceph
app.kubernetes.io/instance: rook-ceph
app.kubernetes.io/component: ceph-csi
app.kubernetes.io/part-of: rook-ceph-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down