From 68d24ce30482adb35d1f015be2783dde2666512b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Thu, 8 Jan 2026 13:22:42 +0100 Subject: [PATCH 1/4] postgres-exporter: support extra volume mounts --- charts/matrix-stack/source/postgres.json | 6 +++ charts/matrix-stack/source/postgres.yaml.j2 | 1 + charts/matrix-stack/values.schema.json | 54 +++++++++++++++++++++ charts/matrix-stack/values.yaml | 7 +++ tests/manifests/__init__.py | 1 - tests/manifests/test_volumes_mounts.py | 5 +- 6 files changed, 72 insertions(+), 2 deletions(-) diff --git a/charts/matrix-stack/source/postgres.json b/charts/matrix-stack/source/postgres.json index 1d05140b..7bcf3430 100644 --- a/charts/matrix-stack/source/postgres.json +++ b/charts/matrix-stack/source/postgres.json @@ -24,6 +24,12 @@ "resources": { "$ref": "file://common/resources.json" }, + "extraVolumes": { + "$ref": "file://common/extraVolumes.json" + }, + "extraVolumeMounts": { + "$ref": "file://common/extraVolumeMounts.json" + }, "livenessProbe": { "$ref": "file://common/probe.json" }, diff --git a/charts/matrix-stack/source/postgres.yaml.j2 b/charts/matrix-stack/source/postgres.yaml.j2 index 152dcef5..ea24f76b 100644 --- a/charts/matrix-stack/source/postgres.yaml.j2 +++ b/charts/matrix-stack/source/postgres.yaml.j2 @@ -9,6 +9,7 @@ enabled: true postgresExporter: {{- sub_schema_values.image(registry='docker.io', repository='prometheuscommunity/postgres-exporter', tag='v0.18.1') | indent(2) }} {{- sub_schema_values.resources(requests_memory='10Mi', requests_cpu='10m', limits_memory='500Mi')| indent(2) }} + {{- sub_schema_values.extraVolumesAndMounts("PostgresExporter") | indent(2) }} {{- sub_schema_values.containersSecurityContext() | indent(2) }} {{- sub_schema_values.extraEnv() | indent(2) }} {{- sub_schema_values.probe("liveness", periodSeconds=6, timeoutSeconds=2) | indent(2) }} diff --git a/charts/matrix-stack/values.schema.json b/charts/matrix-stack/values.schema.json index d50dda39..b6b3141a 100644 --- a/charts/matrix-stack/values.schema.json +++ b/charts/matrix-stack/values.schema.json @@ -6190,6 +6190,60 @@ "type": "object", "additionalProperties": false }, + "extraVolumes": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name" + ], + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + } + } + }, + "extraVolumeMounts": { + "type": "array", + "items": { + "required": [ + "name", + "mountPath" + ], + "type": "object", + "description": "VolumeMount describes a mounting of a Volume within a container.", + "properties": { + "readOnly": { + "type": "boolean", + "description": "Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false." + }, + "mountPath": { + "type": [ + "string", + "null" + ], + "description": "Path within the container at which the volume should be mounted. Must not contain ':'." + }, + "subPath": { + "type": [ + "string", + "null" + ], + "description": "Path within the volume from which the container's volume should be mounted. Defaults to \"\" (volume's root)." + }, + "name": { + "type": [ + "string", + "null" + ], + "description": "This must match the Name of a Volume." + } + }, + "additionalProperties": false + } + }, "livenessProbe": { "type": "object", "properties": { diff --git a/charts/matrix-stack/values.yaml b/charts/matrix-stack/values.yaml index 6cffe9e6..d3d3afd8 100644 --- a/charts/matrix-stack/values.yaml +++ b/charts/matrix-stack/values.yaml @@ -2341,6 +2341,13 @@ postgres: ## Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ limits: memory: 500Mi + # Extra volumes to mount in PostgresExporter, as a yaml array + # This supports helm templating + extraVolumes: [] + + # Extra volumes to mount in PostgresExporter, as a yaml array + extraVolumeMounts: [] + ## A subset of SecurityContext. ContainersSecurityContext holds pod-level security attributes and common container settings containersSecurityContext: ## Controls whether a process can gain more privileges than its parent process. diff --git a/tests/manifests/__init__.py b/tests/manifests/__init__.py index 6b2756d0..12466df8 100644 --- a/tests/manifests/__init__.py +++ b/tests/manifests/__init__.py @@ -241,7 +241,6 @@ class SidecarDetails(DeployableDetails): PropertyType.PodSecurityContext: ValuesFilePath.not_supported(), PropertyType.ServiceAccount: ValuesFilePath.not_supported(), PropertyType.Volumes: ValuesFilePath.not_supported(), - PropertyType.VolumeMounts: ValuesFilePath.not_supported(), PropertyType.Tolerations: ValuesFilePath.not_supported(), PropertyType.TopologySpreadConstraints: ValuesFilePath.not_supported(), } diff --git a/tests/manifests/test_volumes_mounts.py b/tests/manifests/test_volumes_mounts.py index 9ea58eb2..53ea211d 100644 --- a/tests/manifests/test_volumes_mounts.py +++ b/tests/manifests/test_volumes_mounts.py @@ -174,7 +174,10 @@ async def test_extra_volume_mounts(values, make_templates): for template in await make_templates(values): if template["kind"] in ["Deployment", "StatefulSet", "Job"]: for container in workload_spec_containers(template["spec"]["template"]["spec"]): - volumes_mounts = deepfreeze(container.get("volumeMounts", [])) + assert "volumeMounts" in container, ( + f"Pod container {template_id(template)}/{container['name']} does not have volumeMounts" + ) + volumes_mounts = deepfreeze(container["volumeMounts"]) deployable_details = template_to_deployable_details(template) container_details = deployable_details.deployable_details_for_container(container["name"]) if container_details.has_mount_context: From 06bcf5f939747c831b54ad492b59b944180452b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Thu, 8 Jan 2026 13:27:13 +0100 Subject: [PATCH 2/4] refactor extraVolumeAndMounts into 2 distinct macros - Sidecar only have extraVolumeMounts - We need to split the jinja macro in 2 distinct macros to support this --- .../matrix-stack/source/common/sub_schema_values.yaml.j2 | 4 +++- charts/matrix-stack/source/deployment-markers.yaml.j2 | 3 ++- charts/matrix-stack/source/element-admin.yaml.j2 | 3 ++- charts/matrix-stack/source/element-web.yaml.j2 | 3 ++- charts/matrix-stack/source/haproxy.yaml.j2 | 3 ++- charts/matrix-stack/source/init-secrets.yaml.j2 | 3 ++- charts/matrix-stack/source/matrix-rtc.yaml.j2 | 6 ++++-- .../source/matrixAuthenticationService.yaml.j2 | 6 ++++-- charts/matrix-stack/source/postgres.yaml.j2 | 5 +++-- charts/matrix-stack/source/synapse.yaml.j2 | 6 ++++-- charts/matrix-stack/values.yaml | 9 +++------ 11 files changed, 31 insertions(+), 20 deletions(-) diff --git a/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 b/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 index 940e6bf9..c0f73955 100644 --- a/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 +++ b/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 @@ -439,7 +439,7 @@ networking: {{ key }}: {} {% endmacro %} -{% macro extraVolumesAndMounts(component, with_context=False) %} +{% macro extraVolumes(component, with_context=False) %} # Extra volumes to mount in {{ component }}, as a yaml array # This supports helm templating {%- if with_context %} @@ -448,7 +448,9 @@ networking: # Defaults to "both". {%- endif %} extraVolumes: [] +{% endmacro %} +{% macro extraVolumeMounts(component, with_context=False) %} # Extra volumes to mount in {{ component }}, as a yaml array {%- if with_context %} # For each extra volume mount, specify `mountContext` to `hook`, `runtime` or `both` to specify diff --git a/charts/matrix-stack/source/deployment-markers.yaml.j2 b/charts/matrix-stack/source/deployment-markers.yaml.j2 index 02f8dbb9..4c2d09ce 100644 --- a/charts/matrix-stack/source/deployment-markers.yaml.j2 +++ b/charts/matrix-stack/source/deployment-markers.yaml.j2 @@ -15,7 +15,8 @@ rbac: {{- sub_schema_values.workloadAnnotations() -}} {{- sub_schema_values.containersSecurityContext() -}} {{- sub_schema_values.extraEnv() -}} -{{- sub_schema_values.extraVolumesAndMounts("Deployment Markers") }} +{{- sub_schema_values.extraVolumes("Deployment Markers") }} +{{- sub_schema_values.extraVolumeMounts("Deployment Markers") }} {{- sub_schema_values.nodeSelector() -}} {{- sub_schema_values.podSecurityContext(user_id='10010', group_id='10010') -}} {{- sub_schema_values.resources(requests_memory='50Mi', requests_cpu='50m', limits_memory='200Mi') -}} diff --git a/charts/matrix-stack/source/element-admin.yaml.j2 b/charts/matrix-stack/source/element-admin.yaml.j2 index 6994ebfe..1a1fe7e9 100644 --- a/charts/matrix-stack/source/element-admin.yaml.j2 +++ b/charts/matrix-stack/source/element-admin.yaml.j2 @@ -17,7 +17,8 @@ replicas: 1 {{- sub_schema_values.labels() -}} {{- sub_schema_values.workloadAnnotations() -}} {{- sub_schema_values.extraEnv() -}} -{{- sub_schema_values.extraVolumesAndMounts("Element Admin") }} +{{- sub_schema_values.extraVolumes("Element Admin") }} +{{- sub_schema_values.extraVolumeMounts("Element Admin") }} {{- sub_schema_values.containersSecurityContext() -}} {{- sub_schema_values.nodeSelector() -}} {{- sub_schema_values.podSecurityContext(user_id='10104', group_id='10104') -}} diff --git a/charts/matrix-stack/source/element-web.yaml.j2 b/charts/matrix-stack/source/element-web.yaml.j2 index 889375af..4e08dbc5 100644 --- a/charts/matrix-stack/source/element-web.yaml.j2 +++ b/charts/matrix-stack/source/element-web.yaml.j2 @@ -17,7 +17,8 @@ enabled: true ## Most settings are configurable but some settings are owned by the chart and can't be overwritten additional: {} -{{- sub_schema_values.extraVolumesAndMounts("ElementWeb") }} +{{- sub_schema_values.extraVolumes("Element Web") }} +{{- sub_schema_values.extraVolumeMounts("Element Web") }} # Number of Element Web replicas to start up replicas: 1 diff --git a/charts/matrix-stack/source/haproxy.yaml.j2 b/charts/matrix-stack/source/haproxy.yaml.j2 index 454aeea7..3f0e03ff 100644 --- a/charts/matrix-stack/source/haproxy.yaml.j2 +++ b/charts/matrix-stack/source/haproxy.yaml.j2 @@ -13,7 +13,8 @@ replicas: 1 {{- sub_schema_values.workloadAnnotations() }} {{- sub_schema_values.containersSecurityContext() }} {{- sub_schema_values.extraEnv() }} -{{- sub_schema_values.extraVolumesAndMounts("HAProxy") }} +{{- sub_schema_values.extraVolumes("HAProxy") }} +{{- sub_schema_values.extraVolumeMounts("HAProxy") }} {{- sub_schema_values.nodeSelector() }} {{- sub_schema_values.podSecurityContext(user_id='10001', group_id='10001') }} {{- sub_schema_values.resources(requests_memory='100Mi', requests_cpu='100m', limits_memory='200Mi') }} diff --git a/charts/matrix-stack/source/init-secrets.yaml.j2 b/charts/matrix-stack/source/init-secrets.yaml.j2 index 8e298978..416578c4 100644 --- a/charts/matrix-stack/source/init-secrets.yaml.j2 +++ b/charts/matrix-stack/source/init-secrets.yaml.j2 @@ -15,7 +15,8 @@ rbac: {{- sub_schema_values.workloadAnnotations() -}} {{- sub_schema_values.containersSecurityContext() -}} {{- sub_schema_values.extraEnv() -}} -{{- sub_schema_values.extraVolumesAndMounts("Init Secrets") }} +{{- sub_schema_values.extraVolumes("Init Secrets") }} +{{- sub_schema_values.extraVolumeMounts("Init Secrets") }} {{- sub_schema_values.nodeSelector() -}} {{- sub_schema_values.podSecurityContext(user_id='10010', group_id='10010') -}} {{- sub_schema_values.resources(requests_memory='50Mi', requests_cpu='50m', limits_memory='200Mi') -}} diff --git a/charts/matrix-stack/source/matrix-rtc.yaml.j2 b/charts/matrix-stack/source/matrix-rtc.yaml.j2 index 6276f927..e4b41c25 100644 --- a/charts/matrix-stack/source/matrix-rtc.yaml.j2 +++ b/charts/matrix-stack/source/matrix-rtc.yaml.j2 @@ -30,7 +30,8 @@ replicas: 1 {{- sub_schema_values.containersSecurityContext() }} {{- sub_schema_values.hostAliases() }} {{- sub_schema_values.extraEnv() }} -{{- sub_schema_values.extraVolumesAndMounts("Matrix RTC") }} +{{- sub_schema_values.extraVolumes("Matrix RTC") }} +{{- sub_schema_values.extraVolumeMounts("Matrix RTC") }} {{- sub_schema_values.nodeSelector() }} {{- sub_schema_values.podSecurityContext(user_id='10033', group_id='10033') }} {{- sub_schema_values.resources(requests_memory='20Mi', requests_cpu='50m', limits_memory='20Mi') }} @@ -76,7 +77,8 @@ sfu: {{- sub_schema_values.image(registry='docker.io', repository='livekit/livekit-server', tag='v1.9.1') | indent(2) }} {{- sub_schema_values.extraEnv() | indent(2) }} -{{- sub_schema_values.extraVolumesAndMounts("Matrix RTC SFU") | indent(2) }} +{{- sub_schema_values.extraVolumes("Matrix RTC SFU") | indent(2) }} +{{- sub_schema_values.extraVolumeMounts("Matrix RTC SFU") | indent(2) }} {{- sub_schema_values.labels() | indent(2) }} {{- sub_schema_values.workloadAnnotations() | indent(2) }} {{- sub_schema_values.containersSecurityContext() | indent(2) }} diff --git a/charts/matrix-stack/source/matrixAuthenticationService.yaml.j2 b/charts/matrix-stack/source/matrixAuthenticationService.yaml.j2 index 827bdc92..809676c3 100644 --- a/charts/matrix-stack/source/matrixAuthenticationService.yaml.j2 +++ b/charts/matrix-stack/source/matrixAuthenticationService.yaml.j2 @@ -39,7 +39,8 @@ privateKeys: {{ sub_schema_values.workloadAnnotations() }} {{ sub_schema_values.serviceMonitors() }} {{ sub_schema_values.extraEnv() }} -{{ sub_schema_values.extraVolumesAndMounts("Matrix Authentication Service") }} +{{ sub_schema_values.extraVolumes("Matrix Authentication Service") }} +{{ sub_schema_values.extraVolumeMounts("Matrix Authentication Service") }} {{ sub_schema_values.probe("liveness") }} {{ sub_schema_values.probe("readiness") }} {{ sub_schema_values.probe("startup", failureThreshold=4) }} @@ -70,7 +71,8 @@ syn2mas: {{- sub_schema_values.resources(requests_memory='50Mi', requests_cpu='50m', limits_memory='350Mi') | indent(2) -}} {{- sub_schema_values.serviceAccount() | indent(2) -}} {{- sub_schema_values.extraEnv() | indent(2) -}} - {{- sub_schema_values.extraVolumesAndMounts("Syn2Mas") | indent(2) -}} + {{- sub_schema_values.extraVolumes("Syn2Mas") | indent(2) -}} + {{- sub_schema_values.extraVolumeMounts("Syn2Mas") | indent(2) -}} {{- sub_schema_values.tolerations() | indent(2) }} {{- sub_schema_values.topologySpreadConstraints() | indent(2) }} diff --git a/charts/matrix-stack/source/postgres.yaml.j2 b/charts/matrix-stack/source/postgres.yaml.j2 index ea24f76b..5b631125 100644 --- a/charts/matrix-stack/source/postgres.yaml.j2 +++ b/charts/matrix-stack/source/postgres.yaml.j2 @@ -9,7 +9,7 @@ enabled: true postgresExporter: {{- sub_schema_values.image(registry='docker.io', repository='prometheuscommunity/postgres-exporter', tag='v0.18.1') | indent(2) }} {{- sub_schema_values.resources(requests_memory='10Mi', requests_cpu='10m', limits_memory='500Mi')| indent(2) }} - {{- sub_schema_values.extraVolumesAndMounts("PostgresExporter") | indent(2) }} + {{- sub_schema_values.extraVolumeMounts("PostgresExporter") | indent(2) }} {{- sub_schema_values.containersSecurityContext() | indent(2) }} {{- sub_schema_values.extraEnv() | indent(2) }} {{- sub_schema_values.probe("liveness", periodSeconds=6, timeoutSeconds=2) | indent(2) }} @@ -25,7 +25,8 @@ essPasswords: {{- sub_schema_values.persistentVolumeClaim("storage") }} {{- sub_schema_values.image(registry='docker.io', repository='postgres', tag='17-alpine') }} {{- sub_schema_values.extraEnv() }} -{{- sub_schema_values.extraVolumesAndMounts("Postgres") }} +{{- sub_schema_values.extraVolumes("Postgres") }} +{{- sub_schema_values.extraVolumeMounts("Postgres") }} {{- sub_schema_values.labels() }} {{- sub_schema_values.workloadAnnotations() }} {{- sub_schema_values.containersSecurityContext() }} diff --git a/charts/matrix-stack/source/synapse.yaml.j2 b/charts/matrix-stack/source/synapse.yaml.j2 index bcebb6bc..0e309486 100644 --- a/charts/matrix-stack/source/synapse.yaml.j2 +++ b/charts/matrix-stack/source/synapse.yaml.j2 @@ -86,7 +86,8 @@ logging: ## synapse.util.caches.lrucache: WARNING levelOverrides: {} {{- sub_schema_values.image(registry='oci.element.io', repository='synapse', tag='v1.144.0-ess.2') }} -{{- sub_schema_values.extraVolumesAndMounts("Synapse", with_context=true) }} +{{- sub_schema_values.extraVolumes("Synapse", with_context=true) }} +{{- sub_schema_values.extraVolumeMounts("Synapse", with_context=true) }} {{- sub_schema_values.ingress() }} {{- sub_schema_values.labels() }} {{- sub_schema_values.workloadAnnotations() }} @@ -113,7 +114,8 @@ redis: {{- sub_schema_values.workloadAnnotations() | indent(2) }} {{- sub_schema_values.containersSecurityContext() | indent(2) }} {{- sub_schema_values.extraEnv() | indent(2) }} -{{- sub_schema_values.extraVolumesAndMounts("Redis") | indent(2) }} +{{- sub_schema_values.extraVolumes("Redis") | indent(2) }} +{{- sub_schema_values.extraVolumeMounts("Redis") | indent(2) }} {{- sub_schema_values.nodeSelector() | indent(2) }} {{- sub_schema_values.podSecurityContext(user_id='10002', group_id='10002') | indent(2) }} {{- sub_schema_values.resources(requests_memory='50Mi', requests_cpu='50m', limits_memory='50Mi') | indent(2) }} diff --git a/charts/matrix-stack/values.yaml b/charts/matrix-stack/values.yaml index d3d3afd8..dd5d5c05 100644 --- a/charts/matrix-stack/values.yaml +++ b/charts/matrix-stack/values.yaml @@ -1246,11 +1246,11 @@ elementWeb: ## Full details on available configuration options can be found at https://github.com/element-hq/element-web/blob/develop/docs/config.md ## Most settings are configurable but some settings are owned by the chart and can't be overwritten additional: {} - # Extra volumes to mount in ElementWeb, as a yaml array + # Extra volumes to mount in Element Web, as a yaml array # This supports helm templating extraVolumes: [] - # Extra volumes to mount in ElementWeb, as a yaml array + # Extra volumes to mount in Element Web, as a yaml array extraVolumeMounts: [] @@ -2055,6 +2055,7 @@ matrixAuthenticationService: # This supports helm templating extraVolumes: [] + # Extra volumes to mount in Matrix Authentication Service, as a yaml array extraVolumeMounts: [] @@ -2341,10 +2342,6 @@ postgres: ## Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ limits: memory: 500Mi - # Extra volumes to mount in PostgresExporter, as a yaml array - # This supports helm templating - extraVolumes: [] - # Extra volumes to mount in PostgresExporter, as a yaml array extraVolumeMounts: [] From fe16657c7561a340e98cae90c9a380ade7c2ab9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Thu, 8 Jan 2026 13:46:01 +0100 Subject: [PATCH 3/4] test extra volumes: Assert that volumes are present for all workloads --- tests/manifests/test_volumes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/manifests/test_volumes.py b/tests/manifests/test_volumes.py index 38cd994d..355ee9a6 100644 --- a/tests/manifests/test_volumes.py +++ b/tests/manifests/test_volumes.py @@ -129,6 +129,9 @@ async def test_extra_volumes(values, make_templates, release_name): for template in await make_templates(values): if template["kind"] in ["Deployment", "StatefulSet", "Job"]: + assert "volumes" in template["spec"]["template"]["spec"], ( + f"Pod volumes unexpectedly absent for {template_id(template)}" + ) pod_volumes = deepfreeze(template["spec"]["template"]["spec"]["volumes"]) deployable_details = template_to_deployable_details(template) if deployable_details.has_mount_context: From 58331419a3315d45f003cc232b33c1649e0bd74a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Thu, 8 Jan 2026 13:54:34 +0100 Subject: [PATCH 4/4] add newsfragments --- newsfragments/965.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/965.added.md diff --git a/newsfragments/965.added.md b/newsfragments/965.added.md new file mode 100644 index 00000000..aa5f8a40 --- /dev/null +++ b/newsfragments/965.added.md @@ -0,0 +1 @@ +Add support for `extraVolumes` and `extraVolumeMounts` in components values.