diff --git a/charts/feature-cluster-metrics/templates/_helpers_modules.tpl b/charts/feature-cluster-metrics/templates/_helpers_modules.tpl index 428d4b6a7d..a069e7ab09 100644 --- a/charts/feature-cluster-metrics/templates/_helpers_modules.tpl +++ b/charts/feature-cluster-metrics/templates/_helpers_modules.tpl @@ -3,7 +3,7 @@ {{- define "alloyModules.load" }} {{- if eq .Values.global.alloyModules.source "configMap" }} {{- $pathParts := regexSplit "/" .path -1 }} -{{- $configMapName := printf "%s-alloy-module-%s" $.Release.Name (index $pathParts 1) }} +{{- $configMapName := printf "%s-alloy-module-%s" (include "helper.global_fullname" .) (index $pathParts 1) }} {{- $moduleFile := (slice $pathParts 2) | join "_" }} remote.kubernetes.configmap {{ .name | quote }} { name = {{ $configMapName | quote }} diff --git a/charts/feature-integrations/templates/_helpers_modules.tpl b/charts/feature-integrations/templates/_helpers_modules.tpl index 5bc09df93b..81b3425dab 100644 --- a/charts/feature-integrations/templates/_helpers_modules.tpl +++ b/charts/feature-integrations/templates/_helpers_modules.tpl @@ -3,7 +3,7 @@ {{- define "alloyModules.load" }} {{- if eq .Values.global.alloyModules.source "configMap" }} {{- $pathParts := regexSplit "/" .path -1 }} -{{- $configMapName := printf "%s-alloy-module-%s" $.Release.Name (index $pathParts 1) }} +{{- $configMapName := printf "%s-alloy-module-%s" (include "helper.global_fullname" .) (index $pathParts 1) }} {{- $moduleFile := (slice $pathParts 2) | join "_" }} remote.kubernetes.configmap {{ .name | quote }} { name = {{ $configMapName | quote }} diff --git a/charts/k8s-monitoring/templates/_helpers.tpl b/charts/k8s-monitoring/templates/_helpers.tpl index 3437dfba6b..d1d75c8975 100644 --- a/charts/k8s-monitoring/templates/_helpers.tpl +++ b/charts/k8s-monitoring/templates/_helpers.tpl @@ -19,6 +19,20 @@ {{- end }} {{- end }} +{{/* Used to override Alloy modules configmap name prefix including its reference */}} +{{- define "helper.global_fullname" -}} +{{- if .Values.global.fullnameOverride }} +{{- .Values.global.fullnameOverride | trunc 63 | trimSuffix "-" | lower }} +{{- else }} +{{- $name := default .Chart.Name .Values.global.nameOverride | lower }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" | lower }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" | lower }} +{{- end }} +{{- end }} +{{- end }} + {{- define "english_list" }} {{- if eq (len .) 0 }} {{- else if eq (len .) 1 }} diff --git a/charts/k8s-monitoring/templates/alloy-modules-configmaps.yaml b/charts/k8s-monitoring/templates/alloy-modules-configmaps.yaml index 7acbdc8ef1..1b4f30fa56 100644 --- a/charts/k8s-monitoring/templates/alloy-modules-configmaps.yaml +++ b/charts/k8s-monitoring/templates/alloy-modules-configmaps.yaml @@ -6,7 +6,7 @@ {{- end }} {{- range $module := uniq $modules }} {{- $pathParts := regexSplit "/" $module -1 }} - {{- $configMapName := printf "%s-alloy-module-%s" $.Release.Name (index $pathParts 1) }} + {{- $configMapName := printf "%s-alloy-module-%s" (include "helper.global_fullname" $) (index $pathParts 1) }} {{- if not (hasKey $configMaps $configMapName) }} {{- $configMaps = $configMaps | merge (dict $configMapName (list $module)) }} {{- else }} diff --git a/charts/k8s-monitoring/templates/features/_feature_cluster_metrics.tpl b/charts/k8s-monitoring/templates/features/_feature_cluster_metrics.tpl index cca21e5863..fee2920f9c 100644 --- a/charts/k8s-monitoring/templates/features/_feature_cluster_metrics.tpl +++ b/charts/k8s-monitoring/templates/features/_feature_cluster_metrics.tpl @@ -10,7 +10,7 @@ {{- if .Values.clusterMetrics.enabled -}} {{- $destinations := include "features.clusterMetrics.destinations" . | fromYamlArray }} // Feature: Cluster Metrics -{{- include "feature.clusterMetrics.module" (dict "Values" $.Values.clusterMetrics "Files" $.Subcharts.clusterMetrics.Files "Release" $.Release) }} +{{- include "feature.clusterMetrics.module" (dict "Values" $.Values.clusterMetrics "Files" $.Subcharts.clusterMetrics.Files "Release" $.Release "Chart" $.Chart) }} cluster_metrics "feature" { metrics_destinations = [ {{ include "destinations.alloy.targets" (dict "destinations" $.Values.destinations "names" $destinations "type" "metrics" "ecosystem" "prometheus") | indent 4 | trim }} diff --git a/charts/k8s-monitoring/templates/features/_feature_integrations.tpl b/charts/k8s-monitoring/templates/features/_feature_integrations.tpl index 9fa0c99f85..966b5b4e9c 100644 --- a/charts/k8s-monitoring/templates/features/_feature_integrations.tpl +++ b/charts/k8s-monitoring/templates/features/_feature_integrations.tpl @@ -12,7 +12,7 @@ {{- end }} {{- define "features.integrations.metrics.include" }} -{{- $values := dict "Chart" $.Subcharts.integrations.Chart "Values" .Values.integrations "Files" $.Subcharts.integrations.Files "Release" $.Release }} +{{- $values := dict "Chart" $.Subcharts.integrations.Chart "Values" .Values.integrations "Files" $.Subcharts.integrations.Files "Release" $.Release "Chart" $.Chart }} {{- $destinations := include "features.integrations.destinations" . | fromYamlArray }} {{- $integrations := include "feature.integrations.configured.metrics" $values | fromYamlArray }} {{- range $integrationType := $integrations }} diff --git a/charts/k8s-monitoring/values.schema.json b/charts/k8s-monitoring/values.schema.json index 52b0836664..95d3d8b4bb 100644 --- a/charts/k8s-monitoring/values.schema.json +++ b/charts/k8s-monitoring/values.schema.json @@ -959,6 +959,9 @@ } } }, + "fullnameOverride": { + "type": "string" + }, "maxCacheSize": { "type": "integer" },