From df6cfbcfd0ded2d1dca52d2f9f6fb8ba9e505018 Mon Sep 17 00:00:00 2001 From: Andres Felipe Giraldo Date: Mon, 1 Sep 2025 14:25:32 -0500 Subject: [PATCH] feat: add mfe-k8s-volume-mounts patch --- README.rst | 44 ++++++++++++++----- ...1842_andres.giraldo_volume_mounts_patch.md | 1 + tutormfe/patches/k8s-deployments | 3 ++ 3 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 changelog.d/20250901_141842_andres.giraldo_volume_mounts_patch.md diff --git a/README.rst b/README.rst index 3ccf9b55..11144a81 100644 --- a/README.rst +++ b/README.rst @@ -517,21 +517,33 @@ Then add your static files using volume patches. For local deployments, use the ) ) -For Kubernetes deployments, use the ``mfe-k8s-volumes`` patch: +For Kubernetes deployments, use the ``mfe-k8s-volumes`` patch to define the volumes you need, and mount them using the ``mfe-k8s-volume-mounts`` patch: + +For example, to mount a ConfigMap at ``/usr/share/caddy/myfiles`` so it’s served at ``/myfiles/*``: .. code-block:: python - hooks.Filters.ENV_PATCHES.add_item( - ( - "mfe-k8s-volumes", - """ - # Add your custom volume definition here. This can be any valid Kubernetes volume type. - - name: myfiles-volume - configMap: - name: myfiles-configmap - ... - """ - ) + from tutor import hooks + + hooks.Filters.ENV_PATCHES.add_items( + [ + ( + "mfe-k8s-volumes", + """ + - name: myfiles-volume + configMap: + name: myfiles-configmap + """ + ), + ( + "mfe-k8s-volume-mounts", + """ + - name: myfiles-volume + mountPath: /usr/share/caddy/myfiles + readOnly: true + """ + ), + ] ) Your static files will be accessible at ``http(s)://{{ MFE_HOST }}/myfiles/``. @@ -847,6 +859,14 @@ Add volumes to the mfe deployment in Kubernetes. File changed: ``k8s/deployments.yml`` +mfe-k8s-volume-mounts +~~~~~~~~~~~~~~~~~~~~~ + +Add volume mounts to the ``mfe`` container in the Kubernetes deployment. Use this together with ``mfe-k8s-volumes`` to attach and mount custom volumes (e.g., ConfigMaps, PVCs) inside the container. + +File changed: ``k8s/deployments.yml`` + + caddyfile-mfe-proxy ~~~~~~~~~~~~~~~~~~~ diff --git a/changelog.d/20250901_141842_andres.giraldo_volume_mounts_patch.md b/changelog.d/20250901_141842_andres.giraldo_volume_mounts_patch.md new file mode 100644 index 00000000..2e78645e --- /dev/null +++ b/changelog.d/20250901_141842_andres.giraldo_volume_mounts_patch.md @@ -0,0 +1 @@ +- [Feature] Add `mfe-k8s-volume-mounts` patch to mount volumes in the MFE Kubernetes Deployment, complementing `mfe-k8s-volumes`. (by @andres.giraldo) diff --git a/tutormfe/patches/k8s-deployments b/tutormfe/patches/k8s-deployments index 9cec6fe6..d160cf2d 100644 --- a/tutormfe/patches/k8s-deployments +++ b/tutormfe/patches/k8s-deployments @@ -22,6 +22,9 @@ spec: volumeMounts: - mountPath: /etc/caddy/ name: config + {%- if MFE_HOST_EXTRA_FILES %} + {{ patch("mfe-k8s-volume-mounts") | indent(12) }} + {%- endif %} volumes: - name: config configMap: