我在vSphere基础架构中创建了storageclass和持久卷声明。但是,当我使用kubectl describe pvc pvc-name 命令检查持久卷声明时出现错误:
[root@kube-master-01 ~]# kubectl describe pvc jenkins-claim -n kube-jenkins
Name: jenkins-claim
Namespace: kube-jenkins
StorageClass: fast
Status: Pending
Volume:
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{"volume.beta.kubernetes.io/storage-class":"fast"},"name":"jen...
volume.beta.kubernetes.io/storage-class: fast
volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/vsphere-volume
Finalizers: [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode: Filesystem
Mounted By: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning ProvisioningFailed 2m42s (x701 over 26h) persistentvolume-controller Failed to provision volume with StorageClass "fast": Cloud provider not initialized properly
使用的 storageclass.yml 和persistentvolumeclaim.yml如下:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast
provisioner: kubernetes.io/vsphere-volume
parameters:
datastore: VSANDatastore
diskformat: thin
fstype: xfs
persistentvolumeclaim.yml:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: jenkins-claim
annotations:
volume.beta.kubernetes.io/storage-class: fast
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5G
此问题在VMware vSphere环境中经常发生。