diff --git a/chart/operator/templates/_helpers.tpl b/chart/operator/templates/_helpers.tpl index 70adb03a..f1838eec 100644 --- a/chart/operator/templates/_helpers.tpl +++ b/chart/operator/templates/_helpers.tpl @@ -40,6 +40,10 @@ helm.sh/chart: {{ include "chart.chart" . }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} +app.kubernetes.io/part-of: k8sgpt-operator +{{- if .Values.additionalLabels}} +{{ toYaml .Values.additionalLabels }} +{{- end }} {{- end }} {{/* diff --git a/chart/operator/templates/controller-manager-metrics-monitor.yaml b/chart/operator/templates/controller-manager-metrics-monitor.yaml index b3c48348..3d31b5e2 100644 --- a/chart/operator/templates/controller-manager-metrics-monitor.yaml +++ b/chart/operator/templates/controller-manager-metrics-monitor.yaml @@ -5,11 +5,9 @@ metadata: name: {{ include "chart.fullname" . }}-controller-manager-metrics-monitor namespace: {{ .Values.serviceMonitor.namespace | default (include "k8sgpt-operator.namespace" . ) }} labels: - app.kubernetes.io/component: metrics - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator control-plane: controller-manager {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: metrics {{- if .Values.serviceMonitor.additionalLabels }} {{- toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }} {{- end }} @@ -29,4 +27,5 @@ spec: selector: matchLabels: control-plane: controller-manager + {{- include "chart.selectorLabels" . | nindent 6 }} {{ end -}} diff --git a/chart/operator/templates/deployment.yaml b/chart/operator/templates/deployment.yaml index ae3ee005..b7d4fc13 100644 --- a/chart/operator/templates/deployment.yaml +++ b/chart/operator/templates/deployment.yaml @@ -3,32 +3,29 @@ kind: ServiceAccount metadata: name: {{ include "chart.fullname" . }}-controller-manager labels: - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator - {{- include "chart.labels" . | nindent 4 }} + {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: controller-manager --- apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "chart.fullname" . }}-controller-manager labels: - app.kubernetes.io/component: manager - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator control-plane: controller-manager - {{- include "chart.labels" . | nindent 4 }} + {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: controller-manager spec: replicas: {{ .Values.controllerManager.replicas }} selector: matchLabels: control-plane: controller-manager - {{- include "chart.selectorLabels" . | nindent 6 }} + {{- include "chart.selectorLabels" . | nindent 6 }} template: metadata: labels: control-plane: controller-manager - {{- include "chart.selectorLabels" . | nindent 8 }} + {{- include "chart.labels" . | nindent 8 }} + app.kubernetes.io/component: controller-manager annotations: kubectl.kubernetes.io/default-container: manager spec: diff --git a/chart/operator/templates/grafana-k8sgpt-dashboard.yaml b/chart/operator/templates/grafana-k8sgpt-dashboard.yaml index ba820875..a5e0c666 100644 --- a/chart/operator/templates/grafana-k8sgpt-dashboard.yaml +++ b/chart/operator/templates/grafana-k8sgpt-dashboard.yaml @@ -6,10 +6,8 @@ metadata: {{ .Values.grafanaDashboard.folder.annotation }}: {{ .Values.grafanaDashboard.folder.name }} labels: {{ .Values.grafanaDashboard.label.key }}: {{ .Values.grafanaDashboard.label.value | quote }} - app.kubernetes.io/component: configmap - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator - {{- include "chart.labels" . | nindent 4 }} + {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: dashboard name: k8sgpt-overview namespace: {{ .Values.grafanaDashboard.namespace | default (include "k8sgpt-operator.namespace" .) }} data: @@ -21,10 +19,8 @@ apiVersion: grafana.integreatly.org/v1beta1 kind: GrafanaDashboard metadata: labels: - app.kubernetes.io/component: grafana-dashboard - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator - {{- include "chart.labels" . | nindent 4 }} + {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: dashboard name: k8sgpt-overview namespace: {{ .Values.grafanaDashboard.namespace | default (include "k8sgpt-operator.namespace" .) }} spec: diff --git a/chart/operator/templates/k8sgpt-cluster-role-binding.yaml b/chart/operator/templates/k8sgpt-cluster-role-binding.yaml index a911be8f..26d27022 100644 --- a/chart/operator/templates/k8sgpt-cluster-role-binding.yaml +++ b/chart/operator/templates/k8sgpt-cluster-role-binding.yaml @@ -4,6 +4,7 @@ metadata: name: {{ include "chart.fullname" . }}-k8sgpt labels: {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: rbac roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/chart/operator/templates/k8sgpt-cluster-role.yaml b/chart/operator/templates/k8sgpt-cluster-role.yaml index dec9e729..90dafafd 100644 --- a/chart/operator/templates/k8sgpt-cluster-role.yaml +++ b/chart/operator/templates/k8sgpt-cluster-role.yaml @@ -4,6 +4,7 @@ metadata: name: {{ include "chart.fullname" . }}-k8sgpt labels: {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: rbac rules: - apiGroups: - '*' diff --git a/chart/operator/templates/k8sgpt-sa.yaml b/chart/operator/templates/k8sgpt-sa.yaml index 105a4a93..119cf9d8 100644 --- a/chart/operator/templates/k8sgpt-sa.yaml +++ b/chart/operator/templates/k8sgpt-sa.yaml @@ -4,12 +4,9 @@ kind: ServiceAccount metadata: name: {{ default "k8sgpt" .Values.serviceAccount.name }} labels: - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: rbac {{- if .Values.serviceAccount.annotations }} annotations: {{ toYaml .Values.serviceAccount.annotations | nindent 4 }} {{- end }} {{- end }} - diff --git a/chart/operator/templates/leader-election-rbac.yaml b/chart/operator/templates/leader-election-rbac.yaml index 43ace33e..98e620cd 100644 --- a/chart/operator/templates/leader-election-rbac.yaml +++ b/chart/operator/templates/leader-election-rbac.yaml @@ -3,10 +3,8 @@ kind: Role metadata: name: {{ include "chart.fullname" . }}-leader-election-role labels: + {{- include "chart.labels" . | nindent 4 }} app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator - {{- include "chart.labels" . | nindent 4 }} rules: - apiGroups: - "" @@ -45,10 +43,8 @@ kind: RoleBinding metadata: name: {{ include "chart.fullname" . }}-leader-election-rolebinding labels: + {{- include "chart.labels" . | nindent 4 }} app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator - {{- include "chart.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role @@ -56,4 +52,4 @@ roleRef: subjects: - kind: ServiceAccount name: '{{ include "chart.fullname" . }}-controller-manager' - namespace: '{{ .Release.Namespace }}' \ No newline at end of file + namespace: '{{ .Release.Namespace }}' diff --git a/chart/operator/templates/manager-rbac.yaml b/chart/operator/templates/manager-rbac.yaml index d73ab24e..c5c1c902 100644 --- a/chart/operator/templates/manager-rbac.yaml +++ b/chart/operator/templates/manager-rbac.yaml @@ -3,7 +3,8 @@ kind: ClusterRole metadata: name: {{ include "chart.fullname" . }}-manager-role labels: - {{- include "chart.labels" . | nindent 4 }} + {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: manager-rbac rules: - apiGroups: - '*' @@ -67,10 +68,8 @@ kind: ClusterRoleBinding metadata: name: {{ include "chart.fullname" . }}-manager-rolebinding labels: - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator - {{- include "chart.labels" . | nindent 4 }} + {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: manager-rbac roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/chart/operator/templates/metrics-reader-rbac.yaml b/chart/operator/templates/metrics-reader-rbac.yaml index dd2247d2..89921e30 100644 --- a/chart/operator/templates/metrics-reader-rbac.yaml +++ b/chart/operator/templates/metrics-reader-rbac.yaml @@ -3,12 +3,10 @@ kind: ClusterRole metadata: name: {{ include "chart.fullname" . }}-metrics-reader labels: - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator - {{- include "chart.labels" . | nindent 4 }} + {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: metrics-reader rules: - nonResourceURLs: - /metrics verbs: - - get \ No newline at end of file + - get diff --git a/chart/operator/templates/metrics-service.yaml b/chart/operator/templates/metrics-service.yaml index 7ddb9daf..50072a19 100644 --- a/chart/operator/templates/metrics-service.yaml +++ b/chart/operator/templates/metrics-service.yaml @@ -3,15 +3,13 @@ kind: Service metadata: name: {{ include "chart.fullname" . | trunc 20}}-controller-manager-metrics-service labels: - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator control-plane: controller-manager - {{- include "chart.labels" . | nindent 4 }} + {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: metrics-reader spec: type: {{ .Values.metricsService.type }} selector: control-plane: controller-manager - {{- include "chart.selectorLabels" . | nindent 4 }} + {{- include "chart.selectorLabels" . | nindent 4 }} ports: - {{- .Values.metricsService.ports | toYaml | nindent 2 -}} \ No newline at end of file + {{- .Values.metricsService.ports | toYaml | nindent 2 -}} diff --git a/chart/operator/templates/proxy-rbac.yaml b/chart/operator/templates/proxy-rbac.yaml index 05e73254..f7827be3 100644 --- a/chart/operator/templates/proxy-rbac.yaml +++ b/chart/operator/templates/proxy-rbac.yaml @@ -3,10 +3,8 @@ kind: ClusterRole metadata: name: {{ include "chart.fullname" . }}-proxy-role labels: + {{- include "chart.labels" . | nindent 4 }} app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator - {{- include "chart.labels" . | nindent 4 }} rules: - apiGroups: - authentication.k8s.io @@ -26,10 +24,8 @@ kind: ClusterRoleBinding metadata: name: {{ include "chart.fullname" . }}-proxy-rolebinding labels: + {{- include "chart.labels" . | nindent 4 }} app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: k8sgpt-operator - app.kubernetes.io/part-of: k8sgpt-operator - {{- include "chart.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole @@ -37,4 +33,4 @@ roleRef: subjects: - kind: ServiceAccount name: '{{ include "chart.fullname" . }}-controller-manager' - namespace: '{{ .Release.Namespace }}' \ No newline at end of file + namespace: '{{ .Release.Namespace }}' diff --git a/chart/operator/values.yaml b/chart/operator/values.yaml index e083ff67..393702c8 100644 --- a/chart/operator/values.yaml +++ b/chart/operator/values.yaml @@ -7,6 +7,9 @@ serviceAccount: name: "k8sgpt" # -- Annotations for the managed k8sgpt workload service account annotations: {} +# labels that'll be applied to all resources +additionalLabels: {} + # app: k8s-operator serviceMonitor: enabled: false additionalLabels: {}