带有pvc的local类型的StorageClass,但在kubernetes中给出错误 [英] StorageClass of type local with a pvc but gives an error in kubernetes
问题描述
我想使用安装在路径/mnts/drive上的节点上的本地卷. 所以我创建了一个存储类(如本地存储类的文档中所示), 并创建了一个使用该体积的PVC和一个简单的吊舱.
i want to use local volume that is mounted on my node on path: /mnts/drive. so i created a storageclass (as shown in documentation for local storageclass), and created a PVC and a simple pod which uses that volume.
所以这些是使用的配置:
so these are the configurations used:
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: local-fast
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysampleclaim
spec:
storageClassName: local-fast
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
---
apiVersion: v1
kind: Pod
metadata:
name: mysamplepod
spec:
containers:
- name: frontend
image: nginx:1.13
volumeMounts:
- mountPath: "/var/www/html"
name: myvolume
volumes:
- name: myvolume
persistentVolumeClaim:
claimName: mysampleclaim
当我尝试创建此yaml文件时出现错误,不知道我缺少了什么:
and when i try to create this yaml file gives me an error, don't know what i am missing:
Unable to mount volumes for pod "mysamplepod_default(169efc06-3141-11e8-8e58-02d4a61b9de4)": timeout expired list of unattached/unmounted volumes=[myvolume]
推荐答案
如果要使用安装在/mnts/drive
路径上的节点上的本地卷,只需使用
If you want to use local volume that is mounted on the node on /mnts/drive
path, you just need to use hostPath volume in your pod:
hostPath卷从主机节点的主机的文件或目录挂载文件或目录 文件系统放入您的Pod.
A hostPath volume mounts a file or directory from the host node’s filesystem into your pod.
最后的pod.yaml
是:
apiVersion: v1
kind: Pod
metadata:
name: mysamplepod
spec:
containers:
- name: frontend
image: nginx:1.13
volumeMounts:
- mountPath: "/var/www/html"
name: myvolume
volumes:
- name: myvolume
hostPath:
# directory location on host
path: /mnts/drive
这篇关于带有pvc的local类型的StorageClass,但在kubernetes中给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!