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

feat(helm): clean Kubernetes labels #555

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions chart/operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

{{/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -29,4 +27,5 @@ spec:
selector:
matchLabels:
control-plane: controller-manager
{{- include "chart.selectorLabels" . | nindent 6 }}
{{ end -}}
17 changes: 7 additions & 10 deletions chart/operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 4 additions & 8 deletions chart/operator/templates/grafana-k8sgpt-dashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions chart/operator/templates/k8sgpt-cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: {{ include "chart.fullname" . }}-k8sgpt
labels:
{{- include "chart.labels" . | nindent 4 }}
app.kubernetes.io/component: rbac
rules:
- apiGroups:
- '*'
Expand Down
5 changes: 1 addition & 4 deletions chart/operator/templates/k8sgpt-sa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

10 changes: 3 additions & 7 deletions chart/operator/templates/leader-election-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- ""
Expand Down Expand Up @@ -45,15 +43,13 @@ 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
name: '{{ include "chart.fullname" . }}-leader-election-role'
subjects:
- kind: ServiceAccount
name: '{{ include "chart.fullname" . }}-controller-manager'
namespace: '{{ .Release.Namespace }}'
namespace: '{{ .Release.Namespace }}'
9 changes: 4 additions & 5 deletions chart/operator/templates/manager-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- '*'
Expand Down Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions chart/operator/templates/metrics-reader-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- get
10 changes: 4 additions & 6 deletions chart/operator/templates/metrics-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
{{- .Values.metricsService.ports | toYaml | nindent 2 -}}
10 changes: 3 additions & 7 deletions chart/operator/templates/proxy-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,15 +24,13 @@ 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
name: '{{ include "chart.fullname" . }}-proxy-role'
subjects:
- kind: ServiceAccount
name: '{{ include "chart.fullname" . }}-controller-manager'
namespace: '{{ .Release.Namespace }}'
namespace: '{{ .Release.Namespace }}'
3 changes: 3 additions & 0 deletions chart/operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
Loading