How to customise mongodb in the deployment.yaml config?

Hi guys,

I’m going to build tutor in minikube in my macbook.

When I run the tutor k8s launch the mongodb crash and redis crash because PVC and docker have not same PID.

I want to change the deployment file to fix it?

# env/k8s/deployments.yml    
spec:
      securityContext:
        runAsUser: 999
        runAsGroup: 999
        fsGroup: 999
        fsGroupChangePolicy: "OnRootMismatch" -> "Always"
      containers:

Could you please guy me how to change that configuration then next time when I deploy new code to k8s that will be auto update the default configutation.

Thank you so much.

You should write a Tutor plugin that provides an override to the Kubernetes configuration.

Tutor uses Kustomize and provides a patch k8s-override that performs an strategic merge to the kubernetes manifests. You can read a little about how they work, but the gist of it would be to create a plugin that has the k8s-override patch with a partial definition of the resource you want to change.

from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item(
    (
        "k8s-override",
"""
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mydeployment
spec:
  template:
    spec:
      # ... Fields I want to override
"""
    )
)
1 Like

Thank you so much.