光伏发电具有 EKS 集群的 PVC

发布于 2025-01-15 19:32:00 字数 1226 浏览 5 评论 0原文

kubectl apply -f pvc.yaml 下面的 yaml 文件后,我可以在已创建的容器内找到挂载路径 /var/local/pvctest 。但是,工作节点中的主机路径 /var/local/pvctest 未创建。

我是光伏发电的新手非常感谢使用 EKS 的 PVC 以及解决此问题的任何帮助!

kind: Deployment
apiVersion: apps/v1
metadata:
  name: pvctest
  labels:
    alias: pvctest
spec:
  selector:
    matchLabels:
      alias: pvctest
  replicas: 1
  template:
    metadata:
      labels:
        alias: pvctest
    spec:
      containers:
      - name: pvctest
        image: neo4j
        ports:
        - containerPort: 7474
        - containerPort: 7687
        volumeMounts:
        - name: testpv
          mountPath: /var/local/pvctest
      volumes:
      - name: testpv
        persistentVolumeClaim:
          claimName: pvctest-claim
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: pvtest
  labels:
    type: local
spec:
  persistentVolumeReclaimPolicy: Retain
  capacity:
    storage: 3Gi
  accessModes:
  - ReadWriteOnce
  hostPath:
    path: /var/local/pvctest
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pvctest-claim
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi

                  

After kubectl apply -f pvc.yaml the below yaml file, I can able to find the mount path /var/local/pvctest inside the container that has been created. But, the host path /var/local/pvctest in the worker node is not created.

I'm new to PV & PVC with EKS and any help to fix this issue is much appreciated!

kind: Deployment
apiVersion: apps/v1
metadata:
  name: pvctest
  labels:
    alias: pvctest
spec:
  selector:
    matchLabels:
      alias: pvctest
  replicas: 1
  template:
    metadata:
      labels:
        alias: pvctest
    spec:
      containers:
      - name: pvctest
        image: neo4j
        ports:
        - containerPort: 7474
        - containerPort: 7687
        volumeMounts:
        - name: testpv
          mountPath: /var/local/pvctest
      volumes:
      - name: testpv
        persistentVolumeClaim:
          claimName: pvctest-claim
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: pvtest
  labels:
    type: local
spec:
  persistentVolumeReclaimPolicy: Retain
  capacity:
    storage: 3Gi
  accessModes:
  - ReadWriteOnce
  hostPath:
    path: /var/local/pvctest
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pvctest-claim
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi

                  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉殇 2025-01-22 19:32:01

具有 hostPath 的 PersistentVolume 需要预先创建主机上的目录。如果您希望自动为您创建目录:

...
containers:
- name: pvctest
  image: neo4j
  ...
  volumeMounts:
  - name: testpv
    mountPath: /var/local/pvctest
volumes:
- name: testpv
  hostPath:
    path: /data
    type: DirectoryOrCreate

PV/PVC 实际上对于 hostPath 是可选的。

PersistentVolume with hostPath requires the directory on the host to be pre-created. If you want the directory to be created automatically for you:

...
containers:
- name: pvctest
  image: neo4j
  ...
  volumeMounts:
  - name: testpv
    mountPath: /var/local/pvctest
volumes:
- name: testpv
  hostPath:
    path: /data
    type: DirectoryOrCreate

PV/PVC is actually optonal for hostPath.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文