From e20a1ae9d656fa95c240a3b1f821c88d07625e31 Mon Sep 17 00:00:00 2001 From: Peter Ciang Date: Fri, 18 Feb 2022 18:36:36 +0100 Subject: [PATCH] [stable/net-exporter] Flexible resource name, labels and selector to fit our use case (#285) * Minor: flexible resource name, labels and selector * Minor: bump net-exporter's chart version --- stable/net-exporter/Chart.yaml | 2 +- stable/net-exporter/README.md | 4 +++- stable/net-exporter/templates/_helpers.tpl | 10 ++++++++-- stable/net-exporter/templates/daemonset.yaml | 6 +++--- stable/net-exporter/templates/rbac.yaml | 10 +++++----- stable/net-exporter/templates/service-account.yaml | 2 +- stable/net-exporter/templates/service.yaml | 2 +- stable/net-exporter/values.yaml | 5 +++++ 8 files changed, 27 insertions(+), 14 deletions(-) diff --git a/stable/net-exporter/Chart.yaml b/stable/net-exporter/Chart.yaml index f710a6b9..397bd390 100644 --- a/stable/net-exporter/Chart.yaml +++ b/stable/net-exporter/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: "v1" name: net-exporter description: "Helm chart for net-exporter." home: "https://github.com/giantswarm/net-exporter" -version: "1.10.3" +version: "1.10.4" appVersion: "1.10.3" annotations: config.giantswarm.io/version: 1.x.x diff --git a/stable/net-exporter/README.md b/stable/net-exporter/README.md index 96ce7a11..f5a18912 100644 --- a/stable/net-exporter/README.md +++ b/stable/net-exporter/README.md @@ -1,6 +1,6 @@ # net-exporter -![Version: 1.10.3](https://img.shields.io/badge/Version-1.10.3-informational?style=flat-square) ![AppVersion: 1.10.3](https://img.shields.io/badge/AppVersion-1.10.3-informational?style=flat-square) +![Version: 1.10.4](https://img.shields.io/badge/Version-1.10.4-informational?style=flat-square) ![AppVersion: 1.10.3](https://img.shields.io/badge/AppVersion-1.10.3-informational?style=flat-square) Helm chart for net-exporter. @@ -45,6 +45,7 @@ helm install my-release deliveryhero/net-exporter -f values.yaml | NetExporter.DNSCheck.TCP.Disabled | bool | `false` | | | NetExporter.Hosts | string | `""` | | | NetExporter.NTPServers | string | `""` | | +| additionalLabels | object | `{}` | | | controlPlaneSubnets | list | `[]` | | | daemonset.priorityClassName | string | `"system-node-critical"` | | | dns.label | string | `"coredns"` | | @@ -60,6 +61,7 @@ helm install my-release deliveryhero/net-exporter -f values.yaml | kubectl.image.tag | string | `"1.18.8"` | | | name | string | `"net-exporter"` | | | port | int | `8000` | | +| selector.app | string | `"net-exporter"` | | | serviceType | string | `"managed"` | | | timeout | string | `"5s"` | | | userID | int | `1000` | | diff --git a/stable/net-exporter/templates/_helpers.tpl b/stable/net-exporter/templates/_helpers.tpl index 73123532..337a0246 100644 --- a/stable/net-exporter/templates/_helpers.tpl +++ b/stable/net-exporter/templates/_helpers.tpl @@ -9,18 +9,24 @@ Create chart name and version as used by the chart label. Common labels */}} {{- define "labels.common" -}} -{{ include "labels.selector" . }} +{{- include "labels.selector" . -}} app.kubernetes.io/managed-by: {{ .Release.Service | quote }} app.kubernetes.io/name: {{ .Values.name | quote }} app.kubernetes.io/instance: {{ .Release.Name | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} giantswarm.io/service-type: "{{ .Values.serviceType }}" helm.sh/chart: {{ include "chart" . | quote }} +{{- if hasKey .Values "additionalLabels" }} +{{- range $key, $value := .Values.additionalLabels }} +{{ $key }}: {{ $value | quote }} +{{- end }} +{{- end }} {{- end -}} {{/* Selector labels */}} {{- define "labels.selector" -}} -app: {{ .Values.name | quote }} +{{- range $key, $value := .Values.selector }}{{ $key }}: {{ $value | quote }} +{{ end }} {{- end -}} diff --git a/stable/net-exporter/templates/daemonset.yaml b/stable/net-exporter/templates/daemonset.yaml index bc537317..225e4e68 100644 --- a/stable/net-exporter/templates/daemonset.yaml +++ b/stable/net-exporter/templates/daemonset.yaml @@ -1,7 +1,7 @@ kind: DaemonSet apiVersion: apps/v1 metadata: - name: net-exporter + name: {{ .Values.name }} namespace: {{ .Release.Namespace }} labels: {{- include "labels.common" . | nindent 4 }} @@ -38,7 +38,7 @@ spec: ## In the TC, net-exporter runs on kube-system and so this is fine priorityClassName: {{ .Values.daemonset.priorityClassName }} containers: - - name: net-exporter + - name: {{ .Values.name }} image: "{{ .Values.image.registry }}/{{ .Values.image.name }}:{{ .Values.image.tag }}" args: - "-namespace={{ .Release.Namespace }}" @@ -73,7 +73,7 @@ spec: memory: 75Mi limits: memory: 150Mi - serviceAccountName: net-exporter + serviceAccountName: {{ .Values.name }} securityContext: runAsUser: {{ .Values.userID }} runAsGroup: {{ .Values.groupID }} diff --git a/stable/net-exporter/templates/rbac.yaml b/stable/net-exporter/templates/rbac.yaml index e409f5b5..37abb80c 100644 --- a/stable/net-exporter/templates/rbac.yaml +++ b/stable/net-exporter/templates/rbac.yaml @@ -1,7 +1,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: net-exporter + name: {{ .Values.name }} labels: {{- include "labels.common" . | nindent 4 }} rules: @@ -11,7 +11,7 @@ rules: - services - endpoints resourceNames: - - net-exporter + - {{ .Values.name }} - {{ .Values.dns.service }} verbs: - get @@ -44,14 +44,14 @@ rules: kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: net-exporter + name: {{ .Values.name }} labels: {{- include "labels.common" . | nindent 4 }} subjects: - kind: ServiceAccount - name: net-exporter + name: {{ .Values.name }} namespace: {{ .Release.Namespace }} roleRef: kind: ClusterRole - name: net-exporter + name: {{ .Values.name }} apiGroup: rbac.authorization.k8s.io diff --git a/stable/net-exporter/templates/service-account.yaml b/stable/net-exporter/templates/service-account.yaml index beb0ef1a..41fca987 100644 --- a/stable/net-exporter/templates/service-account.yaml +++ b/stable/net-exporter/templates/service-account.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: net-exporter + name: {{ .Values.name }} namespace: {{ .Release.Namespace }} labels: {{- include "labels.common" . | nindent 4 }} diff --git a/stable/net-exporter/templates/service.yaml b/stable/net-exporter/templates/service.yaml index 6d730b4b..f05e4441 100644 --- a/stable/net-exporter/templates/service.yaml +++ b/stable/net-exporter/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: net-exporter + name: {{ .Values.name }} namespace: {{ .Release.Namespace }} labels: {{- include "labels.common" . | nindent 4 }} diff --git a/stable/net-exporter/values.yaml b/stable/net-exporter/values.yaml index a76fc2d6..25a1a6dc 100644 --- a/stable/net-exporter/values.yaml +++ b/stable/net-exporter/values.yaml @@ -38,3 +38,8 @@ NetExporter: DNSCheck: TCP: Disabled: false + +selector: + app: net-exporter + +additionalLabels: {}