rancher / rke2

https://docs.rke2.io/
Apache License 2.0
1.52k stars 265 forks source link

Add vSphere csi/cpi support for v1.30 #6334

Closed rancher-max closed 3 weeks ago

rancher-max commented 2 months ago

Currently, our vsphere support only goes up to v1.29, and v1.30 fails. We should be able to update support for v1.30 now that it is available.

brandond commented 2 months ago

ref:

ShylajaDevadiga commented 3 weeks ago

Validated using rc v1.31.0-rc1+rke2r1

Environment Details

Ubuntu VM on vSphere7

Configs

write-kubeconfig-mode: 644
cloud-provider-name: "rancher-vsphere"

Pod and pvc yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: claim1
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: vsphere-csi-sc
  resources:
    requests:
      storage: 1Gi
---
apiVersion: "v1"
kind: "Pod"
metadata:
  name: "basic"
  labels:
    name: "basic"
spec:
  nodeSelector:
    kubernetes.io/os: linux
  containers:
    - name: "basic"
      image: ranchertest/mytestcontainer:unprivileged
      ports:
        - containerPort: 8080
          name: "basic"
      volumeMounts:
        - mountPath: "/data"
          name: "pvol"
  volumes:
    - name: "pvol"
      persistentVolumeClaim:
        claimName: "claim1"

Validation steps

1 Create VM 2 Copy config and vsphere-values yaml

sudo mkdir -p /etc/rancher/rke2 && sudo cp config.yaml /etc/rancher/rke2/config.yaml
sudo mkdir -p /var/lib/rancher/rke2/server/manifests && \
sudo cp vsphere-values.yaml /var/lib/rancher/rke2/server/manifests/vsphere-values.yaml
  1. Install rke2
  2. Deploy pvc and pod yaml
  3. Verify pvc is created and attached to vSphere instance
  4. Verify cluster is up and version of csi and cpi charts is correct

Validation results

$ rke2 -v
rke2 version v1.31.0-rc1+rke2r1 (3acd10e9389fa930860896ca6ed925a15dff61a3)
go version go1.22.5 X:boringcrypto

$ kubectl get nodes
NAME                STATUS   ROLES                       AGE    VERSION
sdevadiga-vsphere   Ready    control-plane,etcd,master   148m   v1.31.0+rke2r1

$ kubectl get pods -A
NAMESPACE     NAME                                                    READY   STATUS      RESTARTS       AGE
default       basic                                                   1/1     Running     0              139m
kube-system   etcd-sdevadiga-vsphere                                  1/1     Running     0              148m
kube-system   helm-install-rancher-vsphere-cpi-sb5pw                  0/1     Completed   0              148m
kube-system   helm-install-rancher-vsphere-csi-78pgp                  0/1     Completed   0              148m
kube-system   helm-install-rke2-canal-7w854                           0/1     Completed   0              148m
kube-system   helm-install-rke2-coredns-rjckw                         0/1     Completed   0              148m
kube-system   helm-install-rke2-ingress-nginx-2bqjg                   0/1     Completed   0              148m
kube-system   helm-install-rke2-metrics-server-2tmx8                  0/1     Completed   0              148m
kube-system   helm-install-rke2-snapshot-controller-8q56l             0/1     Completed   0              148m
kube-system   helm-install-rke2-snapshot-controller-crd-dkl4g         0/1     Completed   0              148m
kube-system   helm-install-rke2-snapshot-validation-webhook-h4rx6     0/1     Completed   0              148m
kube-system   kube-apiserver-sdevadiga-vsphere                        1/1     Running     0              148m
kube-system   kube-controller-manager-sdevadiga-vsphere               1/1     Running     0              148m
kube-system   kube-proxy-sdevadiga-vsphere                            1/1     Running     0              148m
kube-system   kube-scheduler-sdevadiga-vsphere                        1/1     Running     0              148m
kube-system   rancher-vsphere-cpi-cloud-controller-manager-l679w      1/1     Running     0              148m
kube-system   rke2-canal-7lfg4                                        2/2     Running     0              148m
kube-system   rke2-coredns-rke2-coredns-787bc4b7b7-6zwf4              1/1     Running     0              148m
kube-system   rke2-coredns-rke2-coredns-autoscaler-6dc69d7b97-mdl4v   1/1     Running     0              148m
kube-system   rke2-ingress-nginx-controller-7hhnn                     1/1     Running     0              147m
kube-system   rke2-metrics-server-6d99b6d454-mcrzx                    1/1     Running     0              148m
kube-system   rke2-snapshot-controller-658d97fccc-s2brr               1/1     Running     0              147m
kube-system   rke2-snapshot-validation-webhook-784bcc6c8-6n752        1/1     Running     0              147m
kube-system   vsphere-csi-controller-7c764b76f5-2m6pz                 5/5     Running     0              148m
kube-system   vsphere-csi-controller-7c764b76f5-d2xzf                 5/5     Running     0              148m
kube-system   vsphere-csi-controller-7c764b76f5-t6clh                 5/5     Running     0              148m
kube-system   vsphere-csi-node-7bwkl                                  3/3     Running     2 (147m ago)   148m
$ kubectl get pod,pvc,pv
NAME        READY   STATUS    RESTARTS   AGE
pod/basic   1/1     Running   0          140m

NAME                           STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS     VOLUMEATTRIBUTESCLASS   AGE
persistentvolumeclaim/claim1   Bound    pvc-93e8887f-08ea-4ea3-aac0-0ad45c6117fd   1Gi        RWO            vsphere-csi-sc   <unset>                 140m

NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM            STORAGECLASS     VOLUMEATTRIBUTESCLASS   REASON   AGE
persistentvolume/pvc-93e8887f-08ea-4ea3-aac0-0ad45c6117fd   1Gi        RWO            Delete           Bound    default/claim1   vsphere-csi-sc   <unset>                          140m
$ helm list -A |grep rancher
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /etc/rancher/rke2/rke2.yaml
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /etc/rancher/rke2/rke2.yaml
rancher-vsphere-cpi                 kube-system 1           2024-08-30 19:25:30.621886421 +0000 UTC deployed    rancher-vsphere-cpi-1.9.000                 1.31.0        
rancher-vsphere-csi                 kube-system 1           2024-08-30 19:25:30.519380755 +0000 UTC deployed    rancher-vsphere-csi-3.3.1-rancher100        3.3.1-rancher1
image