总结 我已经使用 kubespray 在几个 vcenter 虚拟机上配置了 kubernetes,并且一切都运行良好。但是,我在将 Vsphere 设置为云提供商并动态配置持久卷时遇到了麻烦。我已尝试按照本指南将 Vsphere 设置为提供程序。所有的 pod 似乎都启动了:
vsphere-cloud-controller-manager-5h8vr 1/1 Running 0 77m
vsphere-csi-controller-0 5/5 Running 0 52m
vsphere-csi-node-9gcn5 3/3 Running 0 23m
vsphere-csi-node-lcmvn 3/3 Running 0 23m
vsphere-csi-node-pgbcj 3/3 Running 0 23m
vsphere-csi-node-rvx4m 3/3 Running 0 23m
但是,如果我描述 pvc,我会收到此错误:
Warning ProvisioningFailed 64s (x30 over 52m) persistentvolume-controller Failed to provision volume with StorageClass "fast": Cloud provider not initialized properly
我能找到的唯一错误来自 vsphere-csi-nodes:
k logs vsphere-csi-node-pgbcj -c vsphere-csi-node
I0709 18:03:55.515251 1 service.go:88] configured: csi.vsphere.vmware.com with map[mode:node]
time="2020-07-09T18:03:55Z" level=info msg="identity service registered"
time="2020-07-09T18:03:55Z" level=info msg="node service registered"
time="2020-07-09T18:03:55Z" level=info msg=serving endpoint="unix:///csi/csi.sock"
I0709 18:03:57.645866 1 config.go:261] GetCnsconfig called with cfgPath: /etc/cloud/csi-vsphere.conf
I0709 18:03:57.645925 1 config.go:265] Could not stat /etc/cloud/csi-vsphere.conf, reading config params from env
E0709 18:03:57.645968 1 config.go:202] No Virtual Center hosts defined
E0709 18:03:57.645983 1 config.go:269] Failed to get config params from env. Err: No Virtual Center hosts defined
I0709 18:03:57.645995 1 node.go:471] Config file not provided to node daemonset. Assuming non-topology aware cluster.
纵观“秘密”,似乎所有信息都被正确传播了。
先决条件到位
- VM 硬件版本 >15
- 在所有虚拟机上启用 UUID
- 球体 >6.7
环境
- 单大师
- 三节点
- 主机操作系统:Debian 10.04 64bit
- Kubespray:最新
- Kubernetes:1.18.5
- VM“硬件版本”:17
- 埃西 7
- 中心 7
- CNI编织
配置文件
group_vars/all.yml
cloud_provider: "external"
external_cloud_provider: "vsphere"
vsphere.conf
# Vsphere provider
external_vsphere_vcenter_ip: "serveriphere"
external_vsphere_vcenter_port: "443"
external_vsphere_insecure: "true"
external_vsphere_user: "localadminaccout@vsphere.local"
external_vsphere_password: "indestructiblepasswordhere"
external_vsphere_datacenter: "LAB"
external_vsphere_kubernetes_cluster_id: "k8"
vsphere_cloud_controller_image_tag: "latest"
vsphere_syncer_image_tag: "v1.0.2"
vsphere_csi_attacher_image_tag: "v1.1.1"
vsphere_csi_controller: "v1.0.2"
vsphere_csi_liveness_prove_image_tag: "v1.1.0"
vsphere_csi_provisioner_image_tag: "v1.2.2"
vsphere_csi_node_driver_registrar_image_tag: "v1.1.0"
vsphere_csi_driver_image_tag: "v1.0.2"
vsphere_csi_controller_replicas: 1
vsphere_csi_enabled: true
存储类
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast
provisioner: kubernetes.io/vsphere-volume
parameters:
datastore: LAB
diskformat: thin
fsttype: ext4
持久卷声明
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: test
namespace: kube-system
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
storageClassName: fast