From efa75cab33a6ce1ea4cd8c84213fd9e12cd0abc4 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Sun, 3 Sep 2023 15:11:27 +0200 Subject: [PATCH 1/2] Update: Refactoring labels Signed-off-by: Nicolas Lamirault --- .../templates/_helpers.tpl | 24 +++++++++++++++++++ .../templates/clusterrole.yaml | 5 +--- .../templates/clusterrolebinding.yaml | 5 +--- .../templates/custom-config-configmap.yaml | 5 +--- .../templates/daemonset.yaml | 11 +++------ .../templates/prometheusrule.yaml | 5 +--- .../templates/psp-clusterrole.yaml | 5 +--- .../templates/psp-clusterrolebinding.yaml | 5 +--- .../node-problem-detector/templates/psp.yaml | 5 +--- .../templates/service.yaml | 5 +--- .../templates/serviceaccount.yaml | 5 +--- .../templates/servicemonitor.yaml | 5 +--- stable/node-problem-detector/values.yaml | 3 +++ 13 files changed, 40 insertions(+), 48 deletions(-) diff --git a/stable/node-problem-detector/templates/_helpers.tpl b/stable/node-problem-detector/templates/_helpers.tpl index 985352da..4659e0b7 100644 --- a/stable/node-problem-detector/templates/_helpers.tpl +++ b/stable/node-problem-detector/templates/_helpers.tpl @@ -32,6 +32,30 @@ Create chart name and version as used by the chart label. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Common labels +*/}} +{{- define "node-problem-detector.labels" -}} +helm.sh/chart: {{ include "node-problem-detector.chart" . }} +{{ include "node-problem-detector.selectorLabels" . }} +app.kubernetes.io/component: detector +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- if .Values.additionalLabels }} +{{ toYaml .Values.additionalLabels }} +{{- end }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "node-problem-detector.selectorLabels" -}} +app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + {{/* Create the name of the service account to use */}} {{- define "node-problem-detector.serviceAccountName" -}} {{- if .Values.serviceAccount.create -}} diff --git a/stable/node-problem-detector/templates/clusterrole.yaml b/stable/node-problem-detector/templates/clusterrole.yaml index a2b0d4d0..31f4632b 100644 --- a/stable/node-problem-detector/templates/clusterrole.yaml +++ b/stable/node-problem-detector/templates/clusterrole.yaml @@ -4,10 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: {{ template "node-problem-detector.fullname" . }} labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - helm.sh/chart: {{ include "node-problem-detector.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "node-problem-detector.labels" . | nindent 4 }} rules: - apiGroups: - "" diff --git a/stable/node-problem-detector/templates/clusterrolebinding.yaml b/stable/node-problem-detector/templates/clusterrolebinding.yaml index 725b05ee..a8b78250 100644 --- a/stable/node-problem-detector/templates/clusterrolebinding.yaml +++ b/stable/node-problem-detector/templates/clusterrolebinding.yaml @@ -4,10 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: {{ template "node-problem-detector.fullname" . }} labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - helm.sh/chart: {{ include "node-problem-detector.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "node-problem-detector.labels" . | nindent 4 }} subjects: - kind: ServiceAccount name: {{ template "node-problem-detector.serviceAccountName" . }} diff --git a/stable/node-problem-detector/templates/custom-config-configmap.yaml b/stable/node-problem-detector/templates/custom-config-configmap.yaml index f0863289..e9f16bbc 100644 --- a/stable/node-problem-detector/templates/custom-config-configmap.yaml +++ b/stable/node-problem-detector/templates/custom-config-configmap.yaml @@ -5,8 +5,5 @@ kind: ConfigMap metadata: name: {{ include "node-problem-detector.customConfig" . }} labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - helm.sh/chart: {{ include "node-problem-detector.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "node-problem-detector.labels" . | nindent 4 }} namespace: {{ .Release.Namespace }} diff --git a/stable/node-problem-detector/templates/daemonset.yaml b/stable/node-problem-detector/templates/daemonset.yaml index df13537b..086d0241 100644 --- a/stable/node-problem-detector/templates/daemonset.yaml +++ b/stable/node-problem-detector/templates/daemonset.yaml @@ -3,10 +3,7 @@ kind: DaemonSet metadata: name: {{ include "node-problem-detector.fullname" . }} labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - helm.sh/chart: {{ include "node-problem-detector.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "node-problem-detector.labels" . | nindent 4 }} {{- range $key, $val := .Values.labels }} {{ $key }}: {{ $val | quote }} {{- end}} @@ -20,14 +17,12 @@ spec: {{- end}} selector: matchLabels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} + {{- include "node-problem-detector.selectorLabels" . | nindent 6 }} app: {{ include "node-problem-detector.name" . }} template: metadata: labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} + {{- include "node-problem-detector.labels" . | nindent 8 }} app: {{ include "node-problem-detector.name" . }} {{- range $key, $val := .Values.labels }} {{ $key }}: {{ $val | quote }} diff --git a/stable/node-problem-detector/templates/prometheusrule.yaml b/stable/node-problem-detector/templates/prometheusrule.yaml index b0f0944f..9710b748 100644 --- a/stable/node-problem-detector/templates/prometheusrule.yaml +++ b/stable/node-problem-detector/templates/prometheusrule.yaml @@ -4,10 +4,7 @@ kind: PrometheusRule metadata: name: {{ template "node-problem-detector.fullname" . }} labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - helm.sh/chart: {{ include "node-problem-detector.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "node-problem-detector.labels" . | nindent 4 }} {{- if .Values.metrics.prometheusRule.additionalLabels }} {{- toYaml .Values.metrics.prometheusRule.additionalLabels | nindent 4 }} {{- end }} diff --git a/stable/node-problem-detector/templates/psp-clusterrole.yaml b/stable/node-problem-detector/templates/psp-clusterrole.yaml index de868177..8c316502 100644 --- a/stable/node-problem-detector/templates/psp-clusterrole.yaml +++ b/stable/node-problem-detector/templates/psp-clusterrole.yaml @@ -4,10 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: {{ template "node-problem-detector.fullname" . }}-psp labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - helm.sh/chart: {{ include "node-problem-detector.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "node-problem-detector.labels" . | nindent 4 }} rules: - apiGroups: ['extensions'] resources: ['podsecuritypolicies'] diff --git a/stable/node-problem-detector/templates/psp-clusterrolebinding.yaml b/stable/node-problem-detector/templates/psp-clusterrolebinding.yaml index 80cd8778..4866b5ac 100644 --- a/stable/node-problem-detector/templates/psp-clusterrolebinding.yaml +++ b/stable/node-problem-detector/templates/psp-clusterrolebinding.yaml @@ -4,10 +4,7 @@ kind: ClusterRoleBinding metadata: name: {{ template "node-problem-detector.fullname" . }}-psp labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - helm.sh/chart: {{ include "node-problem-detector.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "node-problem-detector.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/stable/node-problem-detector/templates/psp.yaml b/stable/node-problem-detector/templates/psp.yaml index e7d01579..759ea1c6 100644 --- a/stable/node-problem-detector/templates/psp.yaml +++ b/stable/node-problem-detector/templates/psp.yaml @@ -4,10 +4,7 @@ kind: PodSecurityPolicy metadata: name: {{ template "node-problem-detector.fullname" . }} labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - helm.sh/chart: {{ include "node-problem-detector.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "node-problem-detector.labels" . | nindent 4 }} spec: privileged: true allowPrivilegeEscalation: true diff --git a/stable/node-problem-detector/templates/service.yaml b/stable/node-problem-detector/templates/service.yaml index 45e6fab6..b89c62ee 100644 --- a/stable/node-problem-detector/templates/service.yaml +++ b/stable/node-problem-detector/templates/service.yaml @@ -4,10 +4,7 @@ kind: Service metadata: name: {{ template "node-problem-detector.fullname" . }} labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - helm.sh/chart: {{ include "node-problem-detector.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "node-problem-detector.labels" . | nindent 4 }} app: {{ include "node-problem-detector.name" . }} annotations: {{- if .Values.metrics.annotations }} diff --git a/stable/node-problem-detector/templates/serviceaccount.yaml b/stable/node-problem-detector/templates/serviceaccount.yaml index 10564e4a..289a7d12 100644 --- a/stable/node-problem-detector/templates/serviceaccount.yaml +++ b/stable/node-problem-detector/templates/serviceaccount.yaml @@ -4,9 +4,6 @@ kind: ServiceAccount metadata: name: {{ template "node-problem-detector.serviceAccountName" . }} labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - helm.sh/chart: {{ include "node-problem-detector.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "node-problem-detector.labels" . | nindent 4 }} namespace: {{ .Release.Namespace }} {{- end -}} diff --git a/stable/node-problem-detector/templates/servicemonitor.yaml b/stable/node-problem-detector/templates/servicemonitor.yaml index 377cc65c..f48bd2f8 100644 --- a/stable/node-problem-detector/templates/servicemonitor.yaml +++ b/stable/node-problem-detector/templates/servicemonitor.yaml @@ -4,10 +4,7 @@ kind: ServiceMonitor metadata: name: {{ template "node-problem-detector.fullname" . }} labels: - app.kubernetes.io/name: {{ include "node-problem-detector.name" . }} - helm.sh/chart: {{ include "node-problem-detector.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- include "node-problem-detector.labels" . | nindent 4 }} {{- if .Values.metrics.serviceMonitor.additionalLabels }} {{- toYaml .Values.metrics.serviceMonitor.additionalLabels | nindent 4 }} {{- end }} diff --git a/stable/node-problem-detector/values.yaml b/stable/node-problem-detector/values.yaml index a1110614..22cff11e 100644 --- a/stable/node-problem-detector/values.yaml +++ b/stable/node-problem-detector/values.yaml @@ -85,6 +85,9 @@ priorityClassName: system-node-critical securityContext: privileged: true +# -- Labels to be added to all other resources. +additionalLabels: {} + resources: {} annotations: {} From 2c37600712a6d9c041f572fd2ac071941e6b19b0 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Sun, 3 Sep 2023 15:12:49 +0200 Subject: [PATCH 2/2] Update: documentation Signed-off-by: Nicolas Lamirault --- stable/node-problem-detector/README.md | 42 +++++--------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/stable/node-problem-detector/README.md b/stable/node-problem-detector/README.md index ab3add0d..06a7acd8 100644 --- a/stable/node-problem-detector/README.md +++ b/stable/node-problem-detector/README.md @@ -6,37 +6,11 @@ This chart installs a [node-problem-detector](https://github.com/kubernetes/node **Homepage:** -## How to install this chart - -Add Delivery Hero public chart repo: - -```console -helm repo add deliveryhero https://charts.deliveryhero.io/ -``` - -A simple install with default values: - -```console -helm install deliveryhero/node-problem-detector -``` - -To install the chart with the release name `my-release`: - -```console -helm install my-release deliveryhero/node-problem-detector -``` - -To install with some set values: - -```console -helm install my-release deliveryhero/node-problem-detector --set values_key1=value1 --set values_key2=value2 -``` - -To install with custom values file: +## Maintainers -```console -helm install my-release deliveryhero/node-problem-detector -f values.yaml -``` +| Name | Email | Url | +| ---- | ------ | --- | +| max-rocket-internet | | | ## Source Code @@ -47,6 +21,7 @@ helm install my-release deliveryhero/node-problem-detector -f values.yaml | Key | Type | Default | Description | |-----|------|---------|-------------| +| additionalLabels | object | `{}` | Labels to be added to all other resources. | | affinity | object | `{}` | | | annotations | object | `{}` | | | env | string | `nil` | | @@ -95,8 +70,5 @@ helm install my-release deliveryhero/node-problem-detector -f values.yaml | updateStrategy | string | `"RollingUpdate"` | Manage the daemonset update strategy | | volume.localtime.type | string | `"FileOrCreate"` | | -## Maintainers - -| Name | Email | Url | -| ---- | ------ | --- | -| max-rocket-internet | | | +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)