diff --git a/CHANGELOG.md b/CHANGELOG.md index ac1e78e7d89..20c271beeb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Every user-facing change should have an entry in this changelog. Please respect --> ## Unreleased +- [Improvement] Make it possible to override k8s resources in plugins using `k8s-override` patch. (by @foadlind) ## v13.3.1 (2022-06-06) diff --git a/docs/k8s.rst b/docs/k8s.rst index e8508e45784..fe61309c764 100644 --- a/docs/k8s.rst +++ b/docs/k8s.rst @@ -140,3 +140,27 @@ Updating docker images Kubernetes does not provide a single command for updating docker images out of the box. A `commonly used trick `__ is to modify an innocuous label on all resources:: kubectl patch -k "$(tutor config printroot)/env" --patch "{\"spec\": {\"template\": {\"metadata\": {\"labels\": {\"date\": \"`date +'%Y%m%d-%H%M%S'`\"}}}}}" + +Customizing Kubernetes resources +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Plugins can customize any Kubernetes resource in Tutor by overriding the definition of the resource with a ``k8s-override`` patch. For example, to change the volume size for MongoDB from ``5Gi`` to ``10Gi``, add the following to the plugin: + +:: + + # myplugin/tutormyplugin/patches/k8s-override + + apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: mongodb + labels: + app.kubernetes.io/component: volume + app.kubernetes.io/name: mongodb + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + diff --git a/docs/reference/patches.rst b/docs/reference/patches.rst index 3dc104a4aea..6b9f23e1682 100644 --- a/docs/reference/patches.rst +++ b/docs/reference/patches.rst @@ -125,6 +125,13 @@ File: ``kustomization.yml`` File: ``kustomization.yml`` +.. patch:: kustomization-patches-strategic-merge + +``kustomization-patches-strategic-merge`` +========================================= + +File: ``kustomization.yml`` + .. patch:: kustomization-resources ``kustomization-resources`` diff --git a/tutor/templates/k8s/override.yml b/tutor/templates/k8s/override.yml new file mode 100644 index 00000000000..5c105154f61 --- /dev/null +++ b/tutor/templates/k8s/override.yml @@ -0,0 +1 @@ +{{ patch("k8s-override") }} diff --git a/tutor/templates/kustomization.yml b/tutor/templates/kustomization.yml index a5a2815299e..1bfb6373a51 100644 --- a/tutor/templates/kustomization.yml +++ b/tutor/templates/kustomization.yml @@ -59,4 +59,8 @@ configMapGenerator: app.kubernetes.io/name: redis {{ patch("kustomization-configmapgenerator") }} +patchesStrategicMerge: +- k8s/override.yml +{{ patch("kustomization-patches-strategic-merge") }} + {{ patch("kustomization") }}