From b475d06eca92d044e2b7ee49d6c36d8269b5a8ba Mon Sep 17 00:00:00 2001 From: jesse goodier <31039225+jessegoodier@users.noreply.github.com> Date: Thu, 9 Nov 2023 17:56:22 -0500 Subject: [PATCH] network costs label consistency --- cost-analyzer/templates/_helpers.tpl | 18 ++++++++++++++++++ ...nalyzer-network-costs-service-template.yaml | 11 +++++------ .../cost-analyzer-network-costs-template.yaml | 6 +++--- cost-analyzer/values.yaml | 4 +--- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/cost-analyzer/templates/_helpers.tpl b/cost-analyzer/templates/_helpers.tpl index a03e62de8..459818933 100755 --- a/cost-analyzer/templates/_helpers.tpl +++ b/cost-analyzer/templates/_helpers.tpl @@ -242,6 +242,24 @@ app: aggregator {{ include "etlUtils.selectorLabels" . }} {{- end -}} +{{/* +Create the networkcosts common labels. Note that because this is a daemonset, we don't want app.kubernetes.io/instance: to take the release name, which allows the scrape config to be static. +*/}} +{{- define "networkcosts.commonLabels" -}} +app.kubernetes.io/instance: kubecost +app.kubernetes.io/name: network-costs +helm.sh/chart: {{ include "cost-analyzer.chart" . }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +app: kubecost-network-costs +{{- end -}} +{{- define "networkcosts.selectorLabels" -}} +app.kubernetes.io/instance: kubecost +app.kubernetes.io/name: network-costs +{{- end }} + +{{/* +{{- end -}} + {{/* Create the selector labels. */}} diff --git a/cost-analyzer/templates/cost-analyzer-network-costs-service-template.yaml b/cost-analyzer/templates/cost-analyzer-network-costs-service-template.yaml index fda8ccafa..0ac70718d 100644 --- a/cost-analyzer/templates/cost-analyzer-network-costs-service-template.yaml +++ b/cost-analyzer/templates/cost-analyzer-network-costs-service-template.yaml @@ -16,11 +16,10 @@ metadata: {{- end }} {{- end }} labels: - {{ unset (include "cost-analyzer.commonLabels" . | fromYaml) "app" | toYaml | nindent 4 }} - app: {{ template "cost-analyzer.networkCostsName" . }} -{{- if .Values.networkCosts.service.labels }} -{{ toYaml .Values.networkCosts.service.labels | indent 4 }} -{{- end }} + {{- include "networkcosts.commonLabels" . | nindent 4 }} + {{- if .Values.networkCosts.service.labels }} + {{ toYaml .Values.networkCosts.service.labels | nindent 4 }} + {{- end }} spec: clusterIP: None ports: @@ -29,7 +28,7 @@ spec: protocol: TCP targetPort: {{ .Values.networkCosts.port | default 3001 }} selector: - app: {{ template "cost-analyzer.networkCostsName" . }} + {{- include "networkcosts.selectorLabels" . | nindent 4 }} type: ClusterIP {{- end }} {{- end }} diff --git a/cost-analyzer/templates/cost-analyzer-network-costs-template.yaml b/cost-analyzer/templates/cost-analyzer-network-costs-template.yaml index cdf2a7299..8e0f1ba1c 100644 --- a/cost-analyzer/templates/cost-analyzer-network-costs-template.yaml +++ b/cost-analyzer/templates/cost-analyzer-network-costs-template.yaml @@ -6,7 +6,7 @@ metadata: name: {{ template "cost-analyzer.networkCostsName" . }} namespace: {{ .Release.Namespace }} labels: - app: {{ template "cost-analyzer.networkCostsName" . }} + {{- include "networkcosts.commonLabels" . | nindent 4 }} {{- if .Values.networkCosts.additionalLabels }} {{- toYaml .Values.networkCosts.additionalLabels | nindent 4 }} {{- end }} @@ -17,7 +17,7 @@ spec: {{- end }} selector: matchLabels: - app: {{ template "cost-analyzer.networkCostsName" . }} + {{- include "networkcosts.selectorLabels" . | nindent 6 }} template: metadata: {{- with .Values.networkCosts.annotations }} @@ -25,7 +25,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - app: {{ template "cost-analyzer.networkCostsName" . }} + {{- include "networkcosts.commonLabels" . | nindent 8 }} {{- if .Values.networkCosts.additionalLabels }} {{- toYaml .Values.networkCosts.additionalLabels | nindent 8 }} {{- end }} diff --git a/cost-analyzer/values.yaml b/cost-analyzer/values.yaml index 9eb215b4c..7973fda0a 100644 --- a/cost-analyzer/values.yaml +++ b/cost-analyzer/values.yaml @@ -895,9 +895,7 @@ networkCosts: enabled: false additionalLabels: {} # match the default extraScrapeConfig - additionalLabels: - app.kubernetes.io/instance: kubecost - app.kubernetes.io/name: network-costs + additionalLabels: {} nodeSelector: {} annotations: {} healthCheckProbes: {}