I’m trying to mount 2 volumeMounts in the same container in kubernates but it seems that with volume 2 the nginx service does not start
This is the yaml I use
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
– name: myfrontend
image: nginx
volumeMounts:
– mountPath: “/var/www/html”
name: mypd
– mountPath: “/etc/nginx/conf.d”
name: mypd
volumes:
– name: mypd
persistentVolumeClaim:
claimName: nginx-pvc
pv and pvc are already present without problems.
If deploy the above manifest the pod start but if, inside the pod, execute a netstat -ntlp the result is this
root@nginx:/etc/nginx/conf.d# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
root@nginx:/etc/nginx/conf.d#
If deploy the same manifest but wiht only one volumeMounts al works fine
`apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: myfrontend
image: nginx
volumeMounts:
- mountPath: "/var/www/html"
name: mypd
volumes:
- name: mypd
persistentVolumeClaim:
claimName: nginx-pvc`
root@nginx:/# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1/nginx: master pro
tcp6 0 0 :::80 :::* LISTEN 1/nginx: master pro
Do I have to create a PVC for each volumeMounts?
Thanks in advance to everyone
A volume mount here doesn’t seem like it’s the right approach. How does content get into the
nginx-pvc
persistent volume? Would it be more maintainable to build a custom image that contains the assets you need to serve, and delete this volume mount entirely?Thanks for your answer. I would need, I am still inexperienced in this field, to upload custom sites to nginx, so I need to upload the necessary files from the kubernates master to the shared share that is mapped to nginx. At the moment I was thinking of mounting /etc/nginx/conf.d to load the configuration files of the various hosts files, and /usr/share/nginx/html to load the website files. Did I take the wrong approach? Thank you