vSphere

Kubespray can be deployed with vSphere as Cloud provider. This feature supports:

  • Volumes
  • Persistent Volumes
  • Storage Classes and provisioning of volumes
  • vSphere Storage Policy Based Management for Containers orchestrated by Kubernetes

Out-of-tree vSphere cloud provider

Prerequisites

You need at first to configure your vSphere environment by following the official documentation.

After this step you should have:

  • vSphere upgraded to 6.7 U3 or later
  • VM hardware upgraded to version 15 or higher
  • UUID activated for each VM where Kubernetes will be deployed

Kubespray configuration

First in inventory/sample/group_vars/all.yml you must set the cloud provider to external and external_cloud_provider to external_cloud_provider.

  1. cloud_provider: "external"
  2. external_cloud_provider: "vsphere"

Then, inventory/sample/group_vars/vsphere.yml, you need to declare your vCenter credentials and enable the vSphere CSI following the description below.

VariableRequiredTypeChoicesDefaultComment
external_vsphere_vcenter_ipTRUEstringIP/URL of the vCenter
external_vsphere_vcenter_portTRUEstring“443”Port of the vCenter API
external_vsphere_insecureTRUEstring“true”, “false”“true”set to “true” if the host above uses a self-signed cert
external_vsphere_userTRUEstringUser name for vCenter with required privileges
external_vsphere_passwordTRUEstringPassword for vCenter
external_vsphere_datacenterTRUEstringDatacenter name to use
external_vsphere_kubernetes_cluster_idTRUEstring“kubernetes-cluster-id”Kubernetes cluster ID to use
vsphere_csi_enabledTRUEbooleanfalseEnable vSphere CSI

Example configuration:

  1. external_vsphere_vcenter_ip: "myvcenter.domain.com"
  2. external_vsphere_vcenter_port: "443"
  3. external_vsphere_insecure: "true"
  4. external_vsphere_user: "administrator@vsphere.local"
  5. external_vsphere_password: "K8s_admin"
  6. external_vsphere_datacenter: "DATACENTER_name"
  7. external_vsphere_kubernetes_cluster_id: "kubernetes-cluster-id"
  8. vsphere_csi_enabled: true

For a more fine-grained CSI setup, refer to the vsphere-csi documentation.

Deployment

Once the configuration is set, you can execute the playbook again to apply the new configuration:

  1. cd kubespray
  2. ansible-playbook -i inventory/sample/hosts.ini -b -v cluster.yml

You’ll find some useful examples here to test your configuration.

In-tree vSphere cloud provider (deprecated)

Prerequisites (deprecated)

You need at first to configure your vSphere environment by following the official documentation.

After this step you should have:

  • UUID activated for each VM where Kubernetes will be deployed
  • A vSphere account with required privileges

If you intend to leverage the zone and region node labeling, create a tag category for both the zone and region in vCenter. The tags can then be applied at the host, cluster, datacenter, or folder level, and the cloud provider will walk the hierarchy to extract and apply the labels to the Kubernetes nodes.

Kubespray configuration (deprecated)

First you must define the cloud provider in inventory/sample/group_vars/all.yml and set it to vsphere.

  1. cloud_provider: vsphere

Then, in the same file, you need to declare your vCenter credentials following the description below.

VariableRequiredTypeChoicesDefaultComment
vsphere_vcenter_ipTRUEstringIP/URL of the vCenter
vsphere_vcenter_portTRUEintegerPort of the vCenter API. Commonly 443
vsphere_insecureTRUEinteger1, 0set to 1 if the host above uses a self-signed cert
vsphere_userTRUEstringUser name for vCenter with required privileges
vsphere_passwordTRUEstringPassword for vCenter
vsphere_datacenterTRUEstringDatacenter name to use
vsphere_datastoreTRUEstringDatastore name to use
vsphere_working_dirTRUEstringWorking directory from the view “VMs and template” in the vCenter where VM are placed
vsphere_scsi_controller_typeTRUEstringbuslogic, pvscsi, parallelpvscsiSCSI controller name. Commonly “pvscsi”.
vsphere_vm_uuidFALSEstringVM Instance UUID of virtual machine that host K8s master. Can be retrieved from instanceUuid property in VmConfigInfo, or as vc.uuid in VMX file or in /sys/class/dmi/id/product_serial (Optional, only used for Kubernetes <= 1.9.2)
vsphere_public_networkFALSEstringBlankName of the network the VMs are joined to
vsphere_resource_poolFALSEstringBlankName of the Resource pool where the VMs are located (Optional, only used for Kubernetes >= 1.9.2)
vsphere_zone_categoryFALSEstringName of the tag category used to set the failure-domain.beta.kubernetes.io/zone label on nodes (Optional, only used for Kubernetes >= 1.12.0)
vsphere_region_categoryFALSEstringName of the tag category used to set the failure-domain.beta.kubernetes.io/region label on nodes (Optional, only used for Kubernetes >= 1.12.0)

Example configuration:

  1. vsphere_vcenter_ip: "myvcenter.domain.com"
  2. vsphere_vcenter_port: 443
  3. vsphere_insecure: 1
  4. vsphere_user: "k8s@vsphere.local"
  5. vsphere_password: "K8s_admin"
  6. vsphere_datacenter: "DATACENTER_name"
  7. vsphere_datastore: "DATASTORE_name"
  8. vsphere_working_dir: "Docker_hosts"
  9. vsphere_scsi_controller_type: "pvscsi"
  10. vsphere_resource_pool: "K8s-Pool"

Deployment (deprecated)

Once the configuration is set, you can execute the playbook again to apply the new configuration:

  1. cd kubespray
  2. ansible-playbook -i inventory/sample/hosts.ini -b -v cluster.yml

You’ll find some useful examples here to test your configuration.