Skip to content

Commit

Permalink
network costs label consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegoodier committed Nov 9, 2023
1 parent 85eadda commit b475d06
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
18 changes: 18 additions & 0 deletions cost-analyzer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -17,15 +17,15 @@ spec:
{{- end }}
selector:
matchLabels:
app: {{ template "cost-analyzer.networkCostsName" . }}
{{- include "networkcosts.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.networkCosts.annotations }}
annotations:
{{- 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 }}
Expand Down
4 changes: 1 addition & 3 deletions cost-analyzer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down

0 comments on commit b475d06

Please sign in to comment.