I’m try to get my local development environment converted from docker-compose
to a flavour of lightweight Kubernetes, since our production environments are all Kubernetes (like). With the help of Kompose I could convert my settings. The part however I struggle with is the conversion of Docker volumes to a local developer machine Volume and Volume claim. Most examples I found cover drivers for S3 or NFS, which isn’t what my development laptop offers.
So when I have in my docker-compose.yml
a setting like this, what’s the local development equivalent in k8s?
version: "3.6"
services:
my_test:
image: "myregistry.com/my_test"
container_name: "demo"
hostname: "demo.acme.local"
stop_grace_period: 120s
cap_add:
- SYS_PTRACE
ports:
- 80:80
volumes:
- my_vol:/local/my_app
volumes:
my_vol:
name: "/local/containers/my_app"
external: false
I’m "only" looking for the volume part. The rest seems clear.
Help is appreciated
2
Answers
Yes you can use the host path or you can use the emptydir that’s on you
Probably hostpath would be a better option.
If you are planning to use the minikube you can also check out the PV and PVC option which is mostly for the persistence storage in Kubernetes.
Hostpath : https://kubernetes.io/docs/concepts/storage/volumes/#hostpath-configuration-example
emptydir : https://kubernetes.io/docs/concepts/storage/volumes/#emptydir
Both solutions (
hostpath
andemptydir
) you found looks good.Here you have documentations to both ones:
To the required
path
property, you can also specify atype
for ahostPath
volume.EmptyDir
volume is initially empty. All containers in the pod have permissions in theemptyDir
volume to read and write the same files, despite possibility of diffrent localisations of that volume (it can be mounted at the same or different paths in each container).In case the Pod is removed from a node for any reason, the data in the
emptyDir
is deleted permanently.