我正在尝试挂载位于/ mnt / rstudio中的名为rstudio的目录。但是,当我尝试使用永久卷进行挂载时,会显示目录,但不会显示rstudio中的文件。这是我的部署文件
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
我的pv和pvc文件如下
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
/ mnt / rstudio里面有很多文件。
[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
但是在Pod启动并运行之后,目录显示为空。知道为什么吗?预先感谢!
答案 0 :(得分:2)
LGTM。如果我将图像与nginx
交换,则会得到文件。我会检查两件事:
rstudio
图片是否使用该路径?文件夹启动时可能正在处理该文件夹。尝试挂载到其他路径,看看是否可以看到文件。此外,请确保在主机路径所在的节点上启动Pod。我假设testserver.local
和test-server
是相同的。
HTH
答案 1 :(得分:0)
PVC是否使用您创建的PV?用
检查kubectl get pvc
尝试在标签上添加标签,并使用matchLabels
选择器以确保PVC实际上消耗了刚创建的PV:
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