Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bossjones/69dbefa409d9c0fabf3a7506da81156e to your computer and use it in GitHub Desktop.
Save bossjones/69dbefa409d9c0fabf3a7506da81156e to your computer and use it in GitHub Desktop.
Getting the VMware vSphere Provider Working In Kubernetes

Configuring the vSphere Cloud Provider

[Global]
        user = "[email protected]"
        password = "MYSUPERSECRETPASSWORD"
        server = "MYVCENTERSERVER.MYDOMAIN.com"
        port = "443" #Optional
        insecure-flag = "1" #set to 1 if the vCenter uses a self-signed cert
        datacenter = "MYDATACENTER"
        datastore = "MYDATASTORE" #Datastore to use for provisioning volumes using storage classes/dynamic provisioning
        working-dir = "Kubernetes"
        vm-name = "kubemaster" #Optional
[Disk]
    scsicontrollertype = pvscsi
  • Add the following lines to /etc/kubernetes/manifests/kube-apiserver.yaml on the Master server under the spec > containers > command section
    - --cloud-provider=vsphere
    - --cloud-config=/etc/kubernetes/pki/vsphere.conf
  • Add the following lines to /etc/kubernetes/manifests/kube-controller-manager.yaml on the Master server under the spec > containers > command section
    - --cloud-provider=vsphere
    - --cloud-config=/etc/kubernetes/pki/vsphere.conf
  • Reload the systemctl config and restart the kubelet service
sudo systemctl daemon-reload
sudo systemctl restart kubelet.service

Testing

  • Create a StorageClass for our new vsphere volume
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: thin-disk
provisioner: kubernetes.io/vsphere-volume
parameters:
    diskformat: thin
  • Create a test persistent volume claim. If everything was successful, you should see this created in VMWAre
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: test-disk
  annotations:
    volume.beta.kubernetes.io/storage-class: thin-disk
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment