Skip to content

Commit 20b6af4

Browse files
authored
feat: add mfe-k8s-volume-mounts patch (#267)
1 parent b4a783a commit 20b6af4

3 files changed

Lines changed: 36 additions & 12 deletions

File tree

README.rst

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -517,21 +517,33 @@ Then add your static files using volume patches. For local deployments, use the
517517
)
518518
)
519519
520-
For Kubernetes deployments, use the ``mfe-k8s-volumes`` patch:
520+
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:
521+
522+
For example, to mount a ConfigMap at ``/usr/share/caddy/myfiles`` so it’s served at ``/myfiles/*``:
521523
522524
.. code-block:: python
523525
524-
hooks.Filters.ENV_PATCHES.add_item(
525-
(
526-
"mfe-k8s-volumes",
527-
"""
528-
# Add your custom volume definition here. This can be any valid Kubernetes volume type.
529-
- name: myfiles-volume
530-
configMap:
531-
name: myfiles-configmap
532-
...
533-
"""
534-
)
526+
from tutor import hooks
527+
528+
hooks.Filters.ENV_PATCHES.add_items(
529+
[
530+
(
531+
"mfe-k8s-volumes",
532+
"""
533+
- name: myfiles-volume
534+
configMap:
535+
name: myfiles-configmap
536+
"""
537+
),
538+
(
539+
"mfe-k8s-volume-mounts",
540+
"""
541+
- name: myfiles-volume
542+
mountPath: /usr/share/caddy/myfiles
543+
readOnly: true
544+
"""
545+
),
546+
]
535547
)
536548
537549
Your static files will be accessible at ``http(s)://{{ MFE_HOST }}/myfiles/``.
@@ -847,6 +859,14 @@ Add volumes to the mfe deployment in Kubernetes.
847859
File changed: ``k8s/deployments.yml``
848860
849861
862+
mfe-k8s-volume-mounts
863+
~~~~~~~~~~~~~~~~~~~~~
864+
865+
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.
866+
867+
File changed: ``k8s/deployments.yml``
868+
869+
850870
caddyfile-mfe-proxy
851871
~~~~~~~~~~~~~~~~~~~
852872
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [Feature] Add `mfe-k8s-volume-mounts` patch to mount volumes in the MFE Kubernetes Deployment, complementing `mfe-k8s-volumes`. (by @andres.giraldo)

tutormfe/patches/k8s-deployments

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ spec:
2222
volumeMounts:
2323
- mountPath: /etc/caddy/
2424
name: config
25+
{%- if MFE_HOST_EXTRA_FILES %}
26+
{{ patch("mfe-k8s-volume-mounts") | indent(12) }}
27+
{%- endif %}
2528
volumes:
2629
- name: config
2730
configMap:

0 commit comments

Comments
 (0)