Configure Mutagen to sync host files with a container, inside Kubernetes?

10/13/2021

How should Mutagen be configured, to synchronise local-host source code files with a Docker volume, onto a Kubernetes cluster?

I used to mount my project directory onto a container, using hostPath:

kind: Deployment
spec:
  volumes:
    - name: "myapp-src"
      hostPath:
        path: "path/to/project/files/on/localhost"
        type: "Directory"
  ...
  containers:
    - name: myapp
      volumeMounts: 
        - name: "myapp-src"
          mountPath: "/app/"

but this has permission and symlinks problems, that I need to solve using Mutagen.\ At the moment, it works correctly when relying on docker-compose (run via mutagen project start -f path/to/mutagen.yml):

sync:
  defaults:
    symlink:
      mode: ignore
    permissions:
      defaultFileMode: 0664
      defaultDirectoryMode: 0775
  myapp-src:
    alpha: "../../"
    beta: "docker://myapp-mutagen/myapp-src"
    mode: "two-way-safe"

But it isn't clear to me how to configure the K8S Deployment, in order to use Mutagen for keeping the myapp-src volume in sync with localhost?

-- Kamafeather
docker
docker-compose
docker-volume
kubernetes
mutagen

0 Answers