diff --git a/charts/k8s-monitoring/docs/examples/remote-config/output.yaml b/charts/k8s-monitoring/docs/examples/remote-config/output.yaml index e20c57bdc..2974d7166 100644 --- a/charts/k8s-monitoring/docs/examples/remote-config/output.yaml +++ b/charts/k8s-monitoring/docs/examples/remote-config/output.yaml @@ -15,6 +15,17 @@ metadata: app.kubernetes.io/part-of: alloy app.kubernetes.io/component: rbac --- +# Source: k8s-monitoring/templates/remote_config_secret.yaml +apiVersion: v1 +kind: Secret +metadata: + name: "alloy-metrics-remote-cfg-ko-k8s-monitoring" + namespace: "default" +type: Opaque +data: + username: "bXktcmVtb3RlLWNmZy11c2Vy" + password: "bXktcmVtb3RlLWNmZy1wYXNzd29yZA==" +--- # Source: k8s-monitoring/templates/alloy-config.yaml apiVersion: v1 kind: ConfigMap diff --git a/charts/k8s-monitoring/templates/remote_config_secret.yaml b/charts/k8s-monitoring/templates/remote_config_secret.yaml new file mode 100644 index 000000000..5ed0d2766 --- /dev/null +++ b/charts/k8s-monitoring/templates/remote_config_secret.yaml @@ -0,0 +1,24 @@ +{{- range $collector := (include "collectors.list.enabled" .) | fromYamlArray }} +{{- $remoteConfigValues := merge ((index $.Values $collector).remoteConfig) (dict "type" "remoteConfig" "name" (printf "%s-remote-cfg" $collector)) }} +{{- with $remoteConfigValues }} +{{- if .enabled }} +{{- if eq (include "secrets.shouldCreateKubernetesSecret" . ) "true" }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "secrets.kubernetesSecretName" (deepCopy $ | merge (dict "object" .)) | quote }} + namespace: {{ include "secrets.kubernetesSecretNamespace" (deepCopy $ | merge (dict "object" .)) | quote }} +type: Opaque +data: +{{- $secrets := include "secrets.list.remoteConfig" . | fromYamlArray }} +{{- range $secret := $secrets }} + {{- $value := include "secrets.getSecretValue" (dict "object" $remoteConfigValues "key" $secret) -}} + {{- if $value }} + {{ include "secrets.getSecretKey" (dict "object" $remoteConfigValues "key" $secret) }}: {{ $value | b64enc | quote }} + {{- end }} +{{- end }} +{{- end -}} +{{- end -}} +{{- end -}} +{{- end -}} diff --git a/charts/k8s-monitoring/values.schema.json b/charts/k8s-monitoring/values.schema.json index 5708f2ffc..47d66b334 100644 --- a/charts/k8s-monitoring/values.schema.json +++ b/charts/k8s-monitoring/values.schema.json @@ -147,7 +147,7 @@ "type": "object", "properties": { "create": { - "type": "null" + "type": "boolean" }, "embed": { "type": "boolean" @@ -337,7 +337,7 @@ "type": "object", "properties": { "create": { - "type": "null" + "type": "boolean" }, "embed": { "type": "boolean" @@ -503,7 +503,7 @@ "type": "object", "properties": { "create": { - "type": "null" + "type": "boolean" }, "embed": { "type": "boolean" @@ -652,7 +652,7 @@ "type": "object", "properties": { "create": { - "type": "null" + "type": "boolean" }, "embed": { "type": "boolean" @@ -817,7 +817,7 @@ "type": "object", "properties": { "create": { - "type": "null" + "type": "boolean" }, "embed": { "type": "boolean" diff --git a/charts/k8s-monitoring/values.yaml b/charts/k8s-monitoring/values.yaml index b7060afaf..09acf4a6d 100644 --- a/charts/k8s-monitoring/values.yaml +++ b/charts/k8s-monitoring/values.yaml @@ -250,10 +250,9 @@ alloy-metrics: passwordFrom: "" secret: - # -- (bool) Whether to create a secret for the remote config server. - # @default -- `true` + # -- Whether to create a secret for the remote config server. # @section -- Collectors - Alloy Metrics - create: + create: true # -- If true, skip secret creation and embed the credentials directly into the configuration. # @section -- Collectors - Alloy Metrics embed: false @@ -376,10 +375,9 @@ alloy-singleton: passwordFrom: "" secret: - # -- (bool) Whether to create a secret for the remote config server. - # @default -- `true` + # -- Whether to create a secret for the remote config server. # @section -- Collectors - Alloy Singleton - create: + create: true # -- If true, skip secret creation and embed the credentials directly into the configuration. # @section -- Collectors - Alloy Singleton embed: false @@ -484,10 +482,9 @@ alloy-logs: passwordFrom: "" secret: - # -- (bool) Whether to create a secret for the remote config server. - # @default -- `true` + # -- Whether to create a secret for the remote config server. # @section -- Collectors - Alloy Logs - create: + create: true # -- If true, skip secret creation and embed the credentials directly into the configuration. # @section -- Collectors - Alloy Logs embed: false @@ -592,10 +589,9 @@ alloy-receiver: passwordFrom: "" secret: - # -- (bool) Whether to create a secret for the remote config server. - # @default -- `true` + # -- Whether to create a secret for the remote config server. # @section -- Collectors - Alloy Receiver - create: + create: true # -- If true, skip secret creation and embed the credentials directly into the configuration. # @section -- Collectors - Alloy Receiver embed: false @@ -693,10 +689,9 @@ alloy-profiles: passwordFrom: "" secret: - # -- (bool) Whether to create a secret for the remote config server. - # @default -- `true` + # -- Whether to create a secret for the remote config server. # @section -- Collectors - Alloy Profiles - create: + create: true # -- If true, skip secret creation and embed the credentials directly into the configuration. # @section -- Collectors - Alloy Profiles embed: false