Adapt labels to kubernetes standard

This commit is contained in:
Jonatan Redondo 2025-01-22 16:46:51 +01:00
parent 0a90103fcd
commit 67d5240c77
9 changed files with 23 additions and 21 deletions

View File

@ -41,6 +41,9 @@ helm.sh/chart: {{ include "cadvisor.chart" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }} {{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.commonLabels }}
{{ toYaml .Values.commonLabels }}
{{- end }}
{{- end -}} {{- end -}}
{{/* {{/*

View File

@ -4,6 +4,8 @@ kind: ClusterRole
metadata: metadata:
name: {{ template "cadvisor.name" . }} name: {{ template "cadvisor.name" . }}
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
labels:
{{- include "cadvisor.labels" . | nindent 4}}
rules: rules:
- apiGroups: ['policy'] - apiGroups: ['policy']
resources: ['podsecuritypolicies'] resources: ['podsecuritypolicies']

View File

@ -4,6 +4,8 @@ kind: ClusterRoleBinding
metadata: metadata:
name: {{ template "cadvisor.name" . }} name: {{ template "cadvisor.name" . }}
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
labels:
{{- include "cadvisor.labels" . | nindent 4}}
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: ClusterRole kind: ClusterRole

View File

@ -8,20 +8,15 @@ metadata:
{{ toYaml . | indent 4 }} {{ toYaml . | indent 4 }}
{{- end }} {{- end }}
labels: labels:
app: {{ template "cadvisor.name" . }} {{- include "cadvisor.labels" . | nindent 4}}
chart: {{ template "cadvisor.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec: spec:
selector: selector:
matchLabels: matchLabels:
app: {{ template "cadvisor.name" . }} {{- include "cadvisor.selectorLabels" . | nindent 6 }}
release: {{ .Release.Name }}
template: template:
metadata: metadata:
labels: labels:
app: {{ template "cadvisor.name" . }} {{- include "cadvisor.selectorLabels" . | nindent 8 }}
release: {{ .Release.Name }}
{{- range $key, $value := .Values.podLabels }} {{- range $key, $value := .Values.podLabels }}
{{ $key }}: {{ $value | quote }} {{ $key }}: {{ $value | quote }}
{{- end }} {{- end }}
@ -30,17 +25,17 @@ spec:
{{ $key }}: {{ $value | quote }} {{ $key }}: {{ $value | quote }}
{{- end }} {{- end }}
spec: spec:
{{ if .Values.priorityClassName }} {{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }} priorityClassName: {{ .Values.priorityClassName }}
{{- end }} {{- end }}
{{ if .Values.image.pullSecrets }} {{- if .Values.image.pullSecrets }}
imagePullSecrets: imagePullSecrets:
{{- range .Values.image.pullSecrets }} {{- range .Values.image.pullSecrets }}
- name: {{ . }} - name: {{ . }}
{{- end }} {{- end }}
{{- end }} {{- end }}
serviceAccountName: {{ template "cadvisor.serviceAccountName" . }} serviceAccountName: {{ template "cadvisor.serviceAccountName" . }}
{{ if .Values.hostNetwork }} {{- if .Values.hostNetwork }}
hostNetwork: true hostNetwork: true
{{- end }} {{- end }}
containers: containers:
@ -57,7 +52,7 @@ spec:
mountPath: {{ default .path .mount }} mountPath: {{ default .path .mount }}
readOnly: {{ list nil true | has .readOnly }} readOnly: {{ list nil true | has .readOnly }}
{{- end }} {{- end }}
{{ if .Values.podSecurityContext.create }} {{- if .Values.podSecurityContext.create }}
securityContext: securityContext:
privileged: {{ .Values.podSecurityContext.privileged }} privileged: {{ .Values.podSecurityContext.privileged }}
{{- end }} {{- end }}

View File

@ -4,6 +4,8 @@ kind: PodSecurityPolicy
metadata: metadata:
name: {{ template "cadvisor.name" . }} name: {{ template "cadvisor.name" . }}
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
labels:
{{- include "cadvisor.labels" . | nindent 4}}
spec: spec:
seLinux: seLinux:
rule: RunAsAny rule: RunAsAny

View File

@ -4,10 +4,7 @@ metadata:
name: {{ template "cadvisor.name" . }} name: {{ template "cadvisor.name" . }}
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
labels: labels:
app: {{ template "cadvisor.name" . }} {{- include "cadvisor.labels" . | nindent 4}}
chart: {{ template "cadvisor.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec: spec:
ports: ports:
- name: http - name: http
@ -15,5 +12,5 @@ spec:
targetPort: {{ .Values.container.port }} targetPort: {{ .Values.container.port }}
protocol: TCP protocol: TCP
selector: selector:
app: {{ template "cadvisor.name" . }} {{- include "cadvisor.selectorLabels" . | nindent 4 }}
type: ClusterIP type: ClusterIP

View File

@ -4,4 +4,6 @@ kind: ServiceAccount
metadata: metadata:
name: {{ template "cadvisor.serviceAccountName" . }} name: {{ template "cadvisor.serviceAccountName" . }}
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
labels:
{{- include "cadvisor.labels" . | nindent 4 }}
{{- end -}} {{- end -}}

View File

@ -5,10 +5,7 @@ metadata:
name: {{ template "cadvisor.name" . }} name: {{ template "cadvisor.name" . }}
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
labels: labels:
app: {{ template "cadvisor.name" . }} {{- include "cadvisor.labels" . | nindent 4}}
chart: {{ template "cadvisor.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec: spec:
selector: selector:
matchLabels: matchLabels:
@ -30,3 +27,4 @@ spec:
{{- toYaml .Values.metrics.metricRelabelings | nindent 8 }} {{- toYaml .Values.metrics.metricRelabelings | nindent 8 }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View File

@ -49,6 +49,7 @@ resources: {}
podAnnotations: {} podAnnotations: {}
podLabels: {} podLabels: {}
commonLabels: {}
daemonsetAnnotations: daemonsetAnnotations:
seccomp.security.alpha.kubernetes.io/pod: 'docker/default' seccomp.security.alpha.kubernetes.io/pod: 'docker/default'