kubernetes / kubernetes/minikube
how to persist data for postgres and mounted hostpath volume
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 32.1k
- Forks
- 5.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 97
Description
Steps to reproduce the issue:
minikube start --driver=virtualbox --network-plugin=cni --memory=5120 --kubernetes-version=v1.18.3 --container-runtime=docker- kubernetes postgres pod manifest: https://gist.github.rcac.purdue.edu/anonymous/06a838ab2af44d6347c54b0f6f5b7a44
version: v1
kind: Pod
metadata:
name: pg-pod
labels:
name: postgres
spec:
containers:
- name: postgres
image: postgres:12.3
imagePullPolicy: IfNotPresent
ports:
- name: pg-port
containerPort: 5432
env:
- name: POSTGRES_PASSWORD
value: admin
- name: PGDATA
- value: /data/k8s
volumeMounts:
- name: pg-vol
mountPath: /var/lib/postgresql/data
securityContext:
runAsUser: 0
runAsGroup: 0
volumes:
- name: pg-vol
hostPath:
path: /Users/<path-to>/database/data
restartPolicy: Never
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
kubectl apply -f postgres-pod.yaml
I am trying to persist the data to the host machine and not the minikube vm. The above manifest works and no errors are reported but the data files are not persisted to the host machine, but they are in the minikube vm.
I have been fidgeting with the security context and the above configuration doesn't throw ‘permission denied’ errors. How to pass through the data files onto the host machine?
host machine <---> minikube vm <---> pod/container
My understanding is that /Users should reflect in both minikube vm and host machine [https://minikube.sigs.k8s.io/docs/handbook/mount/]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided postgres-pod.yaml manifest, the minikube start command, and the linked minikube mount documentation. Reproduce the hostPath behavior and compare the host, minikube VM, and pod paths; the issue is done when the persistence behavior and required configuration are clearly documented or corrected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, kubernetes, postgres
- Domain
- databases, infrastructure
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100