05/24/2023, 3:05 PM
Dear community members, We are new to Rancher and to RKE2. We want to setup a RKE2 cluster in our airgapped VMware vSphere environment without the use of Rancher (used for bootstrapping). This works, but after the installation of the rke2 kubernetes cluster, I want to automatically install the vsphere cloud provider. According to the documentation this should be possible using this configuration: Contents of /etc/rancher/rke2/config.yaml: token: SECRET tls-san: - write-kubeconfig-mode: "0644" cloud-provider-name: rancher-vsphere cloud-provider-config: /etc/rancher/rke2/vsphere.conf Contents of /etc/rancher/rke2/vsphere.conf: [Global] datacenters = "tkgi" insecure-flag = "1" user = "ADuser@my.domain.local" password = "PASSWORD" server = "" port = "443" cluster-id = "testclusterid0001" [VirtualCenter ""] user = "ADuser@my.domain.local" port = "443" password = "PASSWORD" datacenters = "rke2" I get the following errors after systemctl start rke2-server.service and waiting a while. We use rke2 version 1.24.13+rke2r1. kubectl logs pod/rancher-vsphere-cpi-cloud-controller-manager-bgqd7 -n kube-system ... E0523 14:25:29.727585 1 config_yaml.go:136] vsphere.conf does not have the VirtualCenter IP address specified E0523 14:25:29.727593 1 config_yaml.go:214] validateConfig failed: vsphere.conf does not have the VirtualCenter IP address specified W0523 14:25:29.727598 1 config.go:69] ReadCPIConfigYAML failed: vsphere.conf does not have the VirtualCenter IP address specified E0523 14:25:29.727615 1 config.go:73] ReadConfigINI failed: 31️⃣ expected section header F0523 14:25:29.727625 1 main.go:265] Cloud provider could not be initialized: could not init cloud provider "vsphere": 31️⃣ expected section header ... This is caused by a ConfigMap that doesn't have the correct contents: kubectl describe ConfigMap/vsphere-cloud-config -n kube-system Name: vsphere-cloud-config Namespace: kube-system Labels: component=rancher-vsphere-cpi-cloud-controller-manager vsphere-cpi-infra=config Annotations: rancher-vsphere-cpi kube-system Data ==== vsphere.yaml: ---- # Global properties in this section will be used for all specified vCenters unless overriden in VirtualCenter section. global: secretName: "vsphere-cpi-creds" secretNamespace: "kube-system" port: 443 insecureFlag: true # vcenter section vcenter: "": server: "" datacenters: - "" Also the vsphere-cpi-creds secret is not correct. kubectl get all -n kube-system ... NAME READY STATUS RESTARTS AGE pod/etcd-rancher04-01 1/1 Running 0 14m pod/helm-install-rancher-vsphere-cpi-tj8sl 0/1 Completed 0 14m pod/helm-install-rancher-vsphere-csi-h9j9m 0/1 CrashLoopBackOff 7 (4m3s ago) 14m pod/helm-install-rke2-canal-zhf4w 0/1 Completed 0 14m pod/helm-install-rke2-coredns-mvcbj 0/1 Completed 0 14m pod/helm-install-rke2-ingress-nginx-tlsdk 0/1 Pending 0 14m pod/helm-install-rke2-metrics-server-r7dx8 0/1 Pending 0 14m pod/kube-apiserver-rancher04-01 1/1 Running 0 14m pod/kube-controller-manager-rancher04-01 1/1 Running 0 14m pod/kube-proxy-rancher04-01 1/1 Running 0 14m pod/kube-scheduler-rancher04-01 1/1 Running 0 14m pod/rancher-vsphere-cpi-cloud-controller-manager-5g946 0/1 ImagePullBackOff 0 14m pod/rke2-canal-pfhx7 2/2 Running 0 14m pod/rke2-coredns-rke2-coredns-7f75564ff4-fnxlw 0/1 Pending 0 14m pod/rke2-coredns-rke2-coredns-autoscaler-84d67b7c48-72dtj 0/1 Pending 0 14m ... My question is how to get this working. I think the /etc/rancher/rke2/vsphere.conf file should be used by the rke2 service to generate a Helm chart with the correct values, but this fails somehow.


05/24/2023, 8:30 PM
Hey - So we use vSphere to host all our RKE2 clusters. I'll be very honest and say that we've had a much easier time using the upstream VMWare controller installation docs, rather than the Rancher ones. I'd suggest giving it a try. The docs are on the VM website and very clear, concise, and easy to update when needed.


05/25/2023, 12:48 PM
Ok, that is an option, but not so nice from an automation perspective. Thanks, I will look into it. A related question is: how to automatically install the CPI and CSI when developers create a cluster using Rancher?