Skip to content

Commit

Permalink
Add option for additional chart labels in values (#3676)
Browse files Browse the repository at this point in the history
* Add option for additional chart labels in values

* fix lint

* update helpers.tpl

* remove uneccessary tpl function

* update values name to chartLabels and remove unused chart labels

* Update values.yaml comments

* use - before include to chomped left for whitespaces

---------

Co-authored-by: Thomas Nguyen <[email protected]>
Co-authored-by: Chip Zoller <[email protected]>
  • Loading branch information
3 people authored Oct 2, 2024
1 parent 8bed9b7 commit 1a0f9f5
Show file tree
Hide file tree
Showing 65 changed files with 86 additions and 87 deletions.
15 changes: 3 additions & 12 deletions cost-analyzer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -467,18 +467,9 @@ Create the chart labels.
{{- define "cost-analyzer.chartLabels" -}}
helm.sh/chart: {{ include "cost-analyzer.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{- define "kubecost.chartLabels" -}}
app.kubernetes.io/name: {{ include "cost-analyzer.name" . }}
helm.sh/chart: {{ include "cost-analyzer.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{- define "kubecost.aggregator.chartLabels" -}}
app.kubernetes.io/name: {{ include "aggregator.name" . }}
helm.sh/chart: {{ include "cost-analyzer.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.chartLabels }}
{{ toYaml .Values.chartLabels }}
{{- end }}
{{- end -}}


Expand Down
4 changes: 2 additions & 2 deletions cost-analyzer/templates/aggregator-cloud-cost-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ metadata:
name: {{ template "cloudCost.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cloudCost.commonLabels" . | nindent 4 }}
{{- include "cloudCost.commonLabels" . | nindent 4 }}
{{- with .Values.global.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: 1
selector:
matchLabels:
{{ include "cloudCost.selectorLabels" . | nindent 6 }}
{{- include "cloudCost.selectorLabels" . | nindent 6 }}
strategy:
type: Recreate
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metadata:
name: {{ template "cloudCost.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cloudCost.commonLabels" . | nindent 4 }}
{{- include "cloudCost.commonLabels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
4 changes: 2 additions & 2 deletions cost-analyzer/templates/aggregator-cloud-cost-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ metadata:
name: {{ template "cloudCost.serviceName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cloudCost.commonLabels" . | nindent 4 }}
{{- include "cloudCost.commonLabels" . | nindent 4 }}
spec:
selector:
{{ include "cloudCost.selectorLabels" . | nindent 4 }}
{{- include "cloudCost.selectorLabels" . | nindent 4 }}
type: "ClusterIP"
ports:
- name: tcp-api
Expand Down
8 changes: 4 additions & 4 deletions cost-analyzer/templates/aggregator-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ metadata:
name: {{ template "aggregator.serviceName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "aggregator.commonLabels" . | nindent 4 }}
{{- if .Values.kubecostAggregator.service.labels }}
{{- include "aggregator.commonLabels" . | nindent 4 }}
{{- if .Values.kubecostAggregator.service.labels }}
{{- toYaml .Values.kubecostAggregator.service.labels | nindent 4 }}
{{- end }}
{{- end }}
spec:
selector:
{{ include "aggregator.selectorLabels" . | nindent 4 }}
{{- include "aggregator.selectorLabels" . | nindent 4 }}
type: "ClusterIP"
ports:
- name: tcp-api
Expand Down
2 changes: 1 addition & 1 deletion cost-analyzer/templates/aggregator-servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: {{ include "aggregator.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "aggregator.commonLabels" . | nindent 4 }}
{{- include "aggregator.commonLabels" . | nindent 4 }}
{{- if .Values.serviceMonitor.aggregatorMetrics.additionalLabels }}
{{ toYaml .Values.serviceMonitor.aggregatorMetrics.additionalLabels | nindent 4 }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion cost-analyzer/templates/alibaba-service-key-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
name: cloud-service-key
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
type: Opaque
stringData:
service-key.json: |-
Expand Down
2 changes: 1 addition & 1 deletion cost-analyzer/templates/aws-service-key-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
name: cloud-service-key
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
type: Opaque
stringData:
service-key.json: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: awsstore-serviceaccount
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- with .Values.awsstore.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion cost-analyzer/templates/azure-service-key-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
name: cloud-service-key
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
type: Opaque
stringData:
service-key.json: |-
Expand Down
2 changes: 1 addition & 1 deletion cost-analyzer/templates/azure-storage-config-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
name: azure-storage-config
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
type: Opaque
stringData:
azure-storage-config.json: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ kind: ConfigMap
metadata:
name: "account-mapping"
namespace: {{ .Release.Namespace }}
labels: {{ include "cost-analyzer.commonLabels" . | nindent 4 }}
labels:
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
account-map.json: '{{ toJson .Values.kubecostProductConfigs.cloudAccountMapping }}'
{{- end }}
Expand Down
3 changes: 2 additions & 1 deletion cost-analyzer/templates/cost-analyzer-alerts-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ kind: ConfigMap
metadata:
name: {{ default "alert-configs" .Values.alertConfigmapName }}
namespace: {{ .Release.Namespace }}
labels: {{ include "cost-analyzer.commonLabels" . | nindent 4 }}
labels:
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
alerts.json: '{{ toJson .Values.global.notifications.alertConfigs }}'
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: {{ default "asset-report-configs" .Values.assetReportConfigmapName }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
asset-reports.json: '{{ toJson .Values.global.assetReports.reports }}'
{{- end -}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: {{default "cloud-cost-report-configs" .Values.cloudCostReportConfigmapName }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
cloud-cost-reports.json: '{{ toJson .Values.global.cloudCostReports.reports }}'
{{- end -}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: {{ template "cost-analyzer.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand All @@ -24,7 +24,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ template "cost-analyzer.serviceAccountName" . }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
namespace: {{ .Release.Namespace }}
name: {{ template "cost-analyzer.serviceAccountName" . }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
rules:
- apiGroups:
- ''
Expand All @@ -32,7 +32,7 @@ kind: ClusterRole
metadata:
name: {{ template "cost-analyzer.serviceAccountName" . }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
rules:
- apiGroups:
- ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ template "cost-analyzer.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
{{- if .Values.global.prometheus.enabled }}
{{- if .Values.global.zone }}
Expand Down
2 changes: 1 addition & 1 deletion cost-analyzer/templates/cost-analyzer-db-pvc-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
name: {{ template "cost-analyzer.fullname" . }}-db
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- with .Values.persistentVolume.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
name: nginx-conf
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
nginx.conf: |
gzip_static on;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: {{ default "ingestion-configs" .Values.ingestionConfigmapName }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
standardDiscount: "{{ .Values.kubecostProductConfigs.standardDiscount }}"
helmConfig: "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: {{ default "metrics-config" .Values.metricsConfigmapName }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
metrics.json: '{{ toJson .Values.kubecostProductConfigs.metricsConfigs }}'
{{- end -}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
name: network-costs-config
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
config.yaml: |
{{- toYaml .Values.networkCosts.config | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: {{ template "cost-analyzer.fullname" . }}-oidc
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
{{- $root := . }}
oidc.json: |-
Expand Down
2 changes: 1 addition & 1 deletion cost-analyzer/templates/cost-analyzer-pkey-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ metadata:
name: {{ default "product-configs" .Values.productConfigmapName }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
{{- if .Values.kubecostProductConfigs.productKey.key }}
key: {{ .Values.kubecostProductConfigs.productKey.key | quote }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: {{ default "pricing-configs" .Values.pricingConfigmapName }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
{{- if .Values.kubecostProductConfigs.defaultModelPricing }}
{{- if .Values.kubecostProductConfigs.defaultModelPricing.enabled }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
name: {{ include "cost-analyzer.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- if .Values.prometheusRule.additionalLabels }}
{{ toYaml .Values.prometheusRule.additionalLabels | nindent 4 }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion cost-analyzer/templates/cost-analyzer-pvc-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
name: {{ template "cost-analyzer.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- with .Values.persistentVolume.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: {{ template "cost-analyzer.fullname" . }}-saml
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
{{- $root := . }}
saml.json: '{{ toJson .Values.saml }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: {{default "saved-report-configs" .Values.savedReportConfigmapName }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
saved-reports.json: '{{ toJson .Values.global.savedReports.reports }}'
{{- end -}}
Expand Down
3 changes: 2 additions & 1 deletion cost-analyzer/templates/cost-analyzer-server-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ kind: ConfigMap
metadata:
name: {{ default "app-configs" .Values.appConfigmapName }}
namespace: {{ .Release.Namespace }}
labels: {{ include "cost-analyzer.commonLabels" . | nindent 4 }}
labels:
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
{{- if .Values.kubecostProductConfigs.labelMappingConfigs }}
{{- if .Values.kubecostProductConfigs.labelMappingConfigs.enabled }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: {{ template "cost-analyzer.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: {{ include "cost-analyzer.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- if .Values.serviceMonitor.additionalLabels }}
{{ toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }}
{{- end }}
Expand All @@ -29,6 +29,6 @@ spec:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{ include "cost-analyzer.selectorLabels" . | nindent 6 }}
{{- include "cost-analyzer.selectorLabels" . | nindent 6 }}
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions cost-analyzer/templates/etl-utils-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ metadata:
name: {{ template "etlUtils.serviceName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "etlUtils.commonLabels" . | nindent 4 }}
{{- include "etlUtils.commonLabels" . | nindent 4 }}
spec:
selector:
{{ include "etlUtils.selectorLabels" . | nindent 4 }}
{{- include "etlUtils.selectorLabels" . | nindent 4 }}
type: "ClusterIP"
ports:
- name: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: external-grafana-config-map
namespace: {{ .Release.Namespace }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
data:
grafanaURL: {{ .Values.global.grafana.scheme | default "http" }}://{{- .Values.global.grafana.domainName }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
namespace: {{ $.Values.grafana.namespace_dashboards }}
{{- end }}
labels:
{{ include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- if $.Values.grafana.sidecar.dashboards.label }}
{{ $.Values.grafana.sidecar.dashboards.label }}: "{{ $.Values.grafana.sidecar.dashboards.labelValue }}"
{{- else }}
Expand Down
Loading

0 comments on commit 1a0f9f5

Please sign in to comment.