I have a simple web app that uses volume
/persistent volume claim
to serve static data from there. Pods got scheduled only on the first worker node where volume resides.
How to deal with the shared
volume between nodes in case I want to scale pods and have them allocated across all the available nodes?
- name: app-nginx
image: nginx:1.20.0
command: ["/usr/sbin/nginx", "-g", "daemon off;"]
volumeMounts:
- name: static-volume
mountPath: "/opt/static"
volumes:
- name: static-volume
persistentVolumeClaim:
claimName: pvc-static
One option is to use NFS
and not physically allocate volume on an EC2 instance.
Another way is to duplicate static files for each pod (populate them into proper directory with init container) but that requires extra time and is not feasible for a lot a static data.
What's the proper way to deal with such a case within Kubernetes? Is there a way to declare deployment which will be using logically same volume but physically different instances located on the different nodes?