From f8c74aaae8d84264b21f0da3a9b47d8b48830b19 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Mon, 4 Nov 2024 07:53:22 +0100 Subject: [PATCH 1/4] feat(helm): clean Kubernetes labels Signed-off-by: Nicolas Lamirault --- chart/operator/templates/_helpers.tpl | 2 ++ .../controller-manager-metrics-monitor.yaml | 3 +-- chart/operator/templates/deployment.yaml | 13 +++++-------- .../templates/grafana-k8sgpt-dashboard.yaml | 4 ---- .../templates/k8sgpt-cluster-role-binding.yaml | 1 + chart/operator/templates/k8sgpt-cluster-role.yaml | 1 + chart/operator/templates/k8sgpt-crd.yaml | 5 ++--- chart/operator/templates/k8sgpt-sa.yaml | 3 --- chart/operator/templates/leader-election-rbac.yaml | 6 ++---- chart/operator/templates/manager-rbac.yaml | 3 ++- chart/operator/templates/metrics-reader-rbac.yaml | 6 ++---- chart/operator/templates/metrics-service.yaml | 8 +++----- chart/operator/templates/proxy-rbac.yaml | 10 +++------- chart/operator/templates/result-crd.yaml | 3 ++- 14 files changed, 26 insertions(+), 42 deletions(-) diff --git a/chart/operator/templates/_helpers.tpl b/chart/operator/templates/_helpers.tpl index 70adb03a..775f310d 100644 --- a/chart/operator/templates/_helpers.tpl +++ b/chart/operator/templates/_helpers.tpl @@ -40,6 +40,8 @@ helm.sh/chart: {{ include "chart.chart" . }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} +app.kubernetes.io/created-by: k8sgpt-operator +app.kubernetes.io/part-of: k8sgpt-operator {{- end }} {{/* diff --git a/chart/operator/templates/controller-manager-metrics-monitor.yaml b/chart/operator/templates/controller-manager-metrics-monitor.yaml index b3c48348..7de61b3a 100644 --- a/chart/operator/templates/controller-manager-metrics-monitor.yaml +++ b/chart/operator/templates/controller-manager-metrics-monitor.yaml @@ -6,8 +6,6 @@ metadata: 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 }} {{- if .Values.serviceMonitor.additionalLabels }} @@ -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..8765c843 100644 --- a/chart/operator/templates/deployment.yaml +++ b/chart/operator/templates/deployment.yaml @@ -4,9 +4,7 @@ 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 }} --- apiVersion: apps/v1 kind: Deployment @@ -14,21 +12,20 @@ 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 }} 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 }} + app.kubernetes.io/component: rbac + {{- include "chart.selectorLabels" . | nindent 8 }} 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..19de5223 100644 --- a/chart/operator/templates/grafana-k8sgpt-dashboard.yaml +++ b/chart/operator/templates/grafana-k8sgpt-dashboard.yaml @@ -7,8 +7,6 @@ metadata: 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 }} name: k8sgpt-overview namespace: {{ .Values.grafanaDashboard.namespace | default (include "k8sgpt-operator.namespace" .) }} @@ -22,8 +20,6 @@ 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 }} name: k8sgpt-overview namespace: {{ .Values.grafanaDashboard.namespace | default (include "k8sgpt-operator.namespace" .) }} diff --git a/chart/operator/templates/k8sgpt-cluster-role-binding.yaml b/chart/operator/templates/k8sgpt-cluster-role-binding.yaml index a911be8f..9fc56dc7 100644 --- a/chart/operator/templates/k8sgpt-cluster-role-binding.yaml +++ b/chart/operator/templates/k8sgpt-cluster-role-binding.yaml @@ -3,6 +3,7 @@ kind: ClusterRoleBinding metadata: name: {{ include "chart.fullname" . }}-k8sgpt labels: + app.kubernetes.io/component: rbac {{- include "chart.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io diff --git a/chart/operator/templates/k8sgpt-cluster-role.yaml b/chart/operator/templates/k8sgpt-cluster-role.yaml index dec9e729..e418ff98 100644 --- a/chart/operator/templates/k8sgpt-cluster-role.yaml +++ b/chart/operator/templates/k8sgpt-cluster-role.yaml @@ -3,6 +3,7 @@ kind: ClusterRole metadata: name: {{ include "chart.fullname" . }}-k8sgpt labels: + app.kubernetes.io/component: rbac {{- include "chart.labels" . | nindent 4 }} rules: - apiGroups: diff --git a/chart/operator/templates/k8sgpt-crd.yaml b/chart/operator/templates/k8sgpt-crd.yaml index a6b79cca..19314a80 100644 --- a/chart/operator/templates/k8sgpt-crd.yaml +++ b/chart/operator/templates/k8sgpt-crd.yaml @@ -6,7 +6,8 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.14.0 labels: - {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: crd + {{- include "chart.labels" . | nindent 4 }} spec: group: core.k8sgpt.ai names: @@ -215,5 +216,3 @@ status: plural: "" conditions: [] storedVersions: [] - - diff --git a/chart/operator/templates/k8sgpt-sa.yaml b/chart/operator/templates/k8sgpt-sa.yaml index 105a4a93..a334bd49 100644 --- a/chart/operator/templates/k8sgpt-sa.yaml +++ b/chart/operator/templates/k8sgpt-sa.yaml @@ -5,11 +5,8 @@ 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 }} {{- 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..fbf38503 100644 --- a/chart/operator/templates/leader-election-rbac.yaml +++ b/chart/operator/templates/leader-election-rbac.yaml @@ -4,9 +4,7 @@ metadata: name: {{ include "chart.fullname" . }}-leader-election-role 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 }} rules: - apiGroups: - "" @@ -56,4 +54,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..b10574e7 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 }} + app.kubernetes.io/component: manager-rbac + {{- include "chart.labels" . | nindent 4 }} rules: - apiGroups: - '*' diff --git a/chart/operator/templates/metrics-reader-rbac.yaml b/chart/operator/templates/metrics-reader-rbac.yaml index dd2247d2..2e107369 100644 --- a/chart/operator/templates/metrics-reader-rbac.yaml +++ b/chart/operator/templates/metrics-reader-rbac.yaml @@ -4,11 +4,9 @@ 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 }} 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..d562234f 100644 --- a/chart/operator/templates/metrics-service.yaml +++ b/chart/operator/templates/metrics-service.yaml @@ -4,14 +4,12 @@ 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 }} 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..ff18b5ce 100644 --- a/chart/operator/templates/proxy-rbac.yaml +++ b/chart/operator/templates/proxy-rbac.yaml @@ -4,9 +4,7 @@ metadata: name: {{ include "chart.fullname" . }}-proxy-role 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 }} rules: - apiGroups: - authentication.k8s.io @@ -27,9 +25,7 @@ metadata: name: {{ include "chart.fullname" . }}-proxy-rolebinding 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 }} 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/templates/result-crd.yaml b/chart/operator/templates/result-crd.yaml index 0f799b86..f5e17d30 100644 --- a/chart/operator/templates/result-crd.yaml +++ b/chart/operator/templates/result-crd.yaml @@ -5,7 +5,8 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.14.0 labels: - {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: crd + {{- include "chart.labels" . | nindent 4 }} spec: group: core.k8sgpt.ai names: From 5fe9c9cf185e5b44a0d7a3766e9b303234f51c33 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Thu, 12 Dec 2024 15:54:27 +0100 Subject: [PATCH 2/4] feat(helm): sync CRD Signed-off-by: Nicolas Lamirault --- chart/operator/templates/k8sgpt-crd.yaml | 403 ++++++++++++----------- 1 file changed, 215 insertions(+), 188 deletions(-) diff --git a/chart/operator/templates/k8sgpt-crd.yaml b/chart/operator/templates/k8sgpt-crd.yaml index 19314a80..de00e3fb 100644 --- a/chart/operator/templates/k8sgpt-crd.yaml +++ b/chart/operator/templates/k8sgpt-crd.yaml @@ -6,8 +6,7 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.14.0 labels: - app.kubernetes.io/component: crd - {{- include "chart.labels" . | nindent 4 }} + {{- include "chart.labels" . | nindent 4 }} spec: group: core.k8sgpt.ai names: @@ -17,202 +16,230 @@ spec: singular: k8sgpt scope: Namespaced versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: K8sGPT is the Schema for the k8sgpts API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: K8sGPTSpec defines the desired state of K8sGPT - properties: - ai: - properties: - anonymized: - default: true - type: boolean - backOff: - properties: - enabled: - default: false - type: boolean - maxRetries: - default: 5 - type: integer - required: - - enabled - - maxRetries - type: object - backend: - default: openai - enum: - - ibmwatsonxai - - openai - - localai - - azureopenai - - amazonbedrock - - cohere - - amazonsagemaker - - google - - googlevertexai - type: string - baseUrl: - type: string - enabled: - type: boolean - engine: - type: string - language: - default: english - type: string - model: - default: gpt-3.5-turbo - type: string - proxyEndpoint: - type: string - region: - type: string - secret: - properties: - key: - type: string - name: - type: string - type: object - required: - - backend - type: object - extraOptions: - properties: - backstage: - properties: - enabled: - type: boolean - type: object - type: object - filters: - items: - type: string - type: array - imagePullSecrets: - items: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: K8sGPT is the Schema for the k8sgpts API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: K8sGPTSpec defines the desired state of K8sGPT + properties: + ai: properties: - name: + anonymized: + default: true + type: boolean + backOff: + properties: + enabled: + default: false + type: boolean + maxRetries: + default: 5 + type: integer + required: + - enabled + - maxRetries + type: object + backend: + default: openai + enum: + - ibmwatsonxai + - openai + - localai + - azureopenai + - amazonbedrock + - cohere + - amazonsagemaker + - google + - googlevertexai type: string + baseUrl: + type: string + enabled: + type: boolean + engine: + type: string + language: + default: english + type: string + maxTokens: + default: "2048" + type: string + model: + default: gpt-3.5-turbo + type: string + providerId: + type: string + proxyEndpoint: + type: string + region: + type: string + secret: + properties: + key: + type: string + name: + type: string + type: object + topk: + default: "50" + type: string + required: + - backend type: object - type: array - integrations: - properties: - trivy: - properties: - enabled: - type: boolean - namespace: - type: string - skipInstall: - type: boolean - type: object - type: object - kubeconfig: - description: Define the kubeconfig the Deployment must use. If empty, - the Deployment will use the ServiceAccount provided by Kubernetes - itself. - properties: - key: - type: string - name: - type: string - type: object - noCache: - type: boolean - nodeSelector: - additionalProperties: - type: string - type: object - remoteCache: - properties: - azure: - properties: - containerName: - type: string - storageAccount: - type: string - type: object - credentials: + customAnalyzers: + items: properties: + connection: + properties: + port: + type: integer + url: + type: string + type: object name: type: string type: object - gcs: - properties: - bucketName: - type: string - projectId: - type: string - region: - type: string - type: object - s3: - properties: - bucketName: - type: string - region: - type: string - type: object - type: object - repository: - default: ghcr.io/k8sgpt-ai/k8sgpt - type: string - sink: - properties: - channel: - type: string - icon_url: + type: array + extraOptions: + properties: + backstage: + properties: + enabled: + type: boolean + type: object + type: object + filters: + items: type: string - secret: + type: array + imagePullSecrets: + items: properties: - key: - type: string name: type: string type: object - type: - enum: - - slack - - mattermost - type: string - username: - type: string - webhook: + type: array + integrations: + properties: + trivy: + properties: + enabled: + type: boolean + namespace: + type: string + skipInstall: + type: boolean + type: object + type: object + kubeconfig: + description: |- + Define the kubeconfig the Deployment must use. + If empty, the Deployment will use the ServiceAccount provided by Kubernetes itself. + properties: + key: + type: string + name: + type: string + type: object + noCache: + type: boolean + nodeSelector: + additionalProperties: type: string - type: object - targetNamespace: - type: string - version: - type: string - type: object - status: - description: K8sGPTStatus defines the observed state of K8sGPT show the current backend used - type: object - type: object - served: true - storage: true - subresources: - status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] + type: object + remoteCache: + properties: + azure: + properties: + containerName: + type: string + storageAccount: + type: string + type: object + credentials: + properties: + name: + type: string + type: object + gcs: + properties: + bucketName: + type: string + projectId: + type: string + region: + type: string + type: object + interplex: + properties: + endpoint: + type: string + type: object + s3: + properties: + bucketName: + type: string + region: + type: string + type: object + type: object + repository: + default: ghcr.io/k8sgpt-ai/k8sgpt + type: string + sink: + properties: + channel: + type: string + icon_url: + type: string + secret: + properties: + key: + type: string + name: + type: string + type: object + type: + enum: + - slack + - mattermost + type: string + username: + type: string + webhook: + type: string + type: object + targetNamespace: + type: string + version: + type: string + type: object + status: + description: |- + K8sGPTStatus defines the observed state of K8sGPT + show the current backend used + type: object + type: object + served: true + storage: true + subresources: + status: {} From 25e2e34d8f6e01788a886ccbe53f9b96a253f168 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Thu, 12 Dec 2024 16:05:33 +0100 Subject: [PATCH 3/4] feat(helm): cleanup Signed-off-by: Nicolas Lamirault --- chart/operator/templates/_helpers.tpl | 1 - .../templates/controller-manager-metrics-monitor.yaml | 2 +- chart/operator/templates/deployment.yaml | 8 ++++---- chart/operator/templates/grafana-k8sgpt-dashboard.yaml | 8 ++++---- chart/operator/templates/k8sgpt-cluster-role-binding.yaml | 2 +- chart/operator/templates/k8sgpt-cluster-role.yaml | 2 +- chart/operator/templates/k8sgpt-sa.yaml | 2 +- chart/operator/templates/leader-election-rbac.yaml | 6 ++---- chart/operator/templates/manager-rbac.yaml | 8 +++----- chart/operator/templates/metrics-reader-rbac.yaml | 2 +- chart/operator/templates/metrics-service.yaml | 2 +- chart/operator/templates/proxy-rbac.yaml | 4 ++-- chart/operator/templates/result-crd.yaml | 3 +-- 13 files changed, 22 insertions(+), 28 deletions(-) diff --git a/chart/operator/templates/_helpers.tpl b/chart/operator/templates/_helpers.tpl index 775f310d..f3c8b1cd 100644 --- a/chart/operator/templates/_helpers.tpl +++ b/chart/operator/templates/_helpers.tpl @@ -40,7 +40,6 @@ helm.sh/chart: {{ include "chart.chart" . }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} -app.kubernetes.io/created-by: k8sgpt-operator app.kubernetes.io/part-of: k8sgpt-operator {{- end }} diff --git a/chart/operator/templates/controller-manager-metrics-monitor.yaml b/chart/operator/templates/controller-manager-metrics-monitor.yaml index 7de61b3a..3d31b5e2 100644 --- a/chart/operator/templates/controller-manager-metrics-monitor.yaml +++ b/chart/operator/templates/controller-manager-metrics-monitor.yaml @@ -5,9 +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 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 }} diff --git a/chart/operator/templates/deployment.yaml b/chart/operator/templates/deployment.yaml index 8765c843..b7d4fc13 100644 --- a/chart/operator/templates/deployment.yaml +++ b/chart/operator/templates/deployment.yaml @@ -3,17 +3,17 @@ kind: ServiceAccount metadata: name: {{ include "chart.fullname" . }}-controller-manager labels: - app.kubernetes.io/component: rbac {{- 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 control-plane: controller-manager {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: controller-manager spec: replicas: {{ .Values.controllerManager.replicas }} selector: @@ -24,8 +24,8 @@ spec: metadata: labels: control-plane: controller-manager - app.kubernetes.io/component: rbac - {{- 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 19de5223..a5e0c666 100644 --- a/chart/operator/templates/grafana-k8sgpt-dashboard.yaml +++ b/chart/operator/templates/grafana-k8sgpt-dashboard.yaml @@ -6,8 +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 - {{- 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: @@ -19,8 +19,8 @@ apiVersion: grafana.integreatly.org/v1beta1 kind: GrafanaDashboard metadata: labels: - app.kubernetes.io/component: grafana-dashboard - {{- 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 9fc56dc7..26d27022 100644 --- a/chart/operator/templates/k8sgpt-cluster-role-binding.yaml +++ b/chart/operator/templates/k8sgpt-cluster-role-binding.yaml @@ -3,8 +3,8 @@ kind: ClusterRoleBinding metadata: name: {{ include "chart.fullname" . }}-k8sgpt labels: - app.kubernetes.io/component: rbac {{- 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 e418ff98..90dafafd 100644 --- a/chart/operator/templates/k8sgpt-cluster-role.yaml +++ b/chart/operator/templates/k8sgpt-cluster-role.yaml @@ -3,8 +3,8 @@ kind: ClusterRole metadata: name: {{ include "chart.fullname" . }}-k8sgpt labels: - app.kubernetes.io/component: rbac {{- 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 a334bd49..119cf9d8 100644 --- a/chart/operator/templates/k8sgpt-sa.yaml +++ b/chart/operator/templates/k8sgpt-sa.yaml @@ -4,8 +4,8 @@ kind: ServiceAccount metadata: name: {{ default "k8sgpt" .Values.serviceAccount.name }} labels: - app.kubernetes.io/component: rbac {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: rbac {{- if .Values.serviceAccount.annotations }} annotations: {{ toYaml .Values.serviceAccount.annotations | nindent 4 }} {{- end }} diff --git a/chart/operator/templates/leader-election-rbac.yaml b/chart/operator/templates/leader-election-rbac.yaml index fbf38503..98e620cd 100644 --- a/chart/operator/templates/leader-election-rbac.yaml +++ b/chart/operator/templates/leader-election-rbac.yaml @@ -3,8 +3,8 @@ kind: Role metadata: name: {{ include "chart.fullname" . }}-leader-election-role labels: - app.kubernetes.io/component: rbac {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: rbac rules: - apiGroups: - "" @@ -43,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 diff --git a/chart/operator/templates/manager-rbac.yaml b/chart/operator/templates/manager-rbac.yaml index b10574e7..c5c1c902 100644 --- a/chart/operator/templates/manager-rbac.yaml +++ b/chart/operator/templates/manager-rbac.yaml @@ -3,8 +3,8 @@ kind: ClusterRole metadata: name: {{ include "chart.fullname" . }}-manager-role labels: - app.kubernetes.io/component: manager-rbac {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: manager-rbac rules: - apiGroups: - '*' @@ -68,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 2e107369..89921e30 100644 --- a/chart/operator/templates/metrics-reader-rbac.yaml +++ b/chart/operator/templates/metrics-reader-rbac.yaml @@ -3,8 +3,8 @@ kind: ClusterRole metadata: name: {{ include "chart.fullname" . }}-metrics-reader labels: - app.kubernetes.io/component: kube-rbac-proxy {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: metrics-reader rules: - nonResourceURLs: - /metrics diff --git a/chart/operator/templates/metrics-service.yaml b/chart/operator/templates/metrics-service.yaml index d562234f..50072a19 100644 --- a/chart/operator/templates/metrics-service.yaml +++ b/chart/operator/templates/metrics-service.yaml @@ -3,9 +3,9 @@ kind: Service metadata: name: {{ include "chart.fullname" . | trunc 20}}-controller-manager-metrics-service labels: - app.kubernetes.io/component: kube-rbac-proxy control-plane: controller-manager {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: metrics-reader spec: type: {{ .Values.metricsService.type }} selector: diff --git a/chart/operator/templates/proxy-rbac.yaml b/chart/operator/templates/proxy-rbac.yaml index ff18b5ce..f7827be3 100644 --- a/chart/operator/templates/proxy-rbac.yaml +++ b/chart/operator/templates/proxy-rbac.yaml @@ -3,8 +3,8 @@ kind: ClusterRole metadata: name: {{ include "chart.fullname" . }}-proxy-role labels: - app.kubernetes.io/component: kube-rbac-proxy {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: kube-rbac-proxy rules: - apiGroups: - authentication.k8s.io @@ -24,8 +24,8 @@ kind: ClusterRoleBinding metadata: name: {{ include "chart.fullname" . }}-proxy-rolebinding labels: - app.kubernetes.io/component: kube-rbac-proxy {{- include "chart.labels" . | nindent 4 }} + app.kubernetes.io/component: kube-rbac-proxy roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/chart/operator/templates/result-crd.yaml b/chart/operator/templates/result-crd.yaml index f5e17d30..0f799b86 100644 --- a/chart/operator/templates/result-crd.yaml +++ b/chart/operator/templates/result-crd.yaml @@ -5,8 +5,7 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.14.0 labels: - app.kubernetes.io/component: crd - {{- include "chart.labels" . | nindent 4 }} + {{- include "chart.labels" . | nindent 4 }} spec: group: core.k8sgpt.ai names: From 0407dae064789da8bf8654a836e75c7bfd81b3e5 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Thu, 12 Dec 2024 16:08:26 +0100 Subject: [PATCH 4/4] feat(helm): support for additional labels Signed-off-by: Nicolas Lamirault --- chart/operator/templates/_helpers.tpl | 3 +++ chart/operator/values.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/chart/operator/templates/_helpers.tpl b/chart/operator/templates/_helpers.tpl index f3c8b1cd..f1838eec 100644 --- a/chart/operator/templates/_helpers.tpl +++ b/chart/operator/templates/_helpers.tpl @@ -41,6 +41,9 @@ 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/values.yaml b/chart/operator/values.yaml index 92eab95f..b0a64cd6 100644 --- a/chart/operator/values.yaml +++ b/chart/operator/values.yaml @@ -3,6 +3,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: {}