I am trying to mount a directory called rstudio which is residing in /mnt/rstudio. But when I try to mount using persistent volume, the directory is showing up but not the files inside rstudio. Here's my deployment file
<!-- language: yaml -->apiVersion: apps/v1
kind: Deployment
metadata:
name: rsp-deployment
spec:
selector:
matchLabels:
app: rsp
replicas: 1
strategy: {}
template:
metadata:
labels:
app: rsp
spec:
nodeSelector:
kubernetes.io/hostname: testserver.local
volumes:
- name: rsp-persistent-storage
persistentVolumeClaim:
claimName: pv-claim-rsp
containers:
- env:
- name: RSP_LICENSE
value: MY LICENSE
image: rstudio/rstudio-server-pro:latest
name: rstudio-server-pro
ports:
- containerPort: 8787
- containerPort: 5559
volumeMounts:
- name: rsp-persistent-storage
mountPath: /tmp/rstudio
resources: {}
securityContext:
privileged: true
restartPolicy: Always
status: {}
---
kind: Service
apiVersion: v1
metadata:
name: rstudio-server-pro
spec:
selector:
app: rsp
ports:
- protocol: TCP
name: "8787"
port: 8787
targetPort: 8787
type: NodePort
And my pv and pvc files are as follows
<!-- language: yaml -->apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-volume-rsp
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/rstudio"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-claim-rsp
spec:
accessModes:
- ReadWriteOnce
storageClassName: ""
resources:
requests:
storage: 5Gi
Inside my /mnt/rstudio there are these much files.
[root@test-server rstudio]# ls
launcher.conf launcher-mounts launcher.pub rserver.conf
launcher.kubernetes.conf launcher-mounts_working logging.conf rsession.conf
launcher.kubernetes.profiles.conf launcher.pem notifications.conf r-versions
But after the pod is up and running, the directory is showing empty. Any idea why? Thanks in advance!
Does you PVC make use of the PV you created? Check it with
kubectl get pvc
Try adding a label to the pv and use a matchLabels
selector to make sure the PVC actually consumes the PV you just created:
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-volume-rsp
labels:
name: pv-volume-rsp # Added
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/rstudio"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-claim-rsp
spec:
accessModes:
- ReadWriteOnce
storageClassName: ""
resources:
requests:
storage: 5Gi
selector:
matchLabels:
name: pv-volume-rsp # Added
LGTM. I am getting files if I swap the image with nginx
. I would check two things:
1. Permissions: Check what permissions the files have. You may have to update your permissions or UID to access the files.
2. Does rstudio
image use that path? It may be processing that folder when it starts. Try mounting to a different path and see if you can see the files.
Also, make sure you are launching the pod on the node where the host path exists. I am assuming testserver.local
and test-server
are the same.
HTH