Writing data from within Kubernetes Pod to host

5/14/2018

I have a Kubernetes redis Pod, which I need to backup/restore its data through dump.rdb. When restore, I put dump.rdb under /data and launch the pod with this config:

containers:
  - name: redis
    volumeMounts:
      - mountPath: /data/
        name: data-volume
volumes:
- name: data-volume
  hostPath:
    path: /data/
    type: Directory

It can see the dump.rdb from host's /data dir, but when Redis saves any changes in the Pod, it only updated the /data dir within the Pod not the host. My goal is to be able to backup the dump.rdb on the host, so I need the dump.rdb on the host to get updated too. What am I missing here?

-- Joe
kubernetes
redis

1 Answer

5/15/2018

Const`s question helps to find the solution for Joe.

Joe missed the place where the file was stored.

My suggestion: try to use NFS volume for storing and restoring backups, it may be easier than using the hostPath

-- Nick Rak
Source: StackOverflow