Using VMware vSphere with Juju


#1

In order to use a vSphere cloud you will need to have an existing vSphere installation which supports VMware’s Hardware Version 8 or better. The vSphere installation will also need access to a DNS for Juju to function.

Adding a vSphere cloud

Use the add-cloud command to interactively add your vSphere cloud to Juju’s list of clouds. You will need to supply a name you wish to call your cloud, the IP address of the vSphere server, and a region name.

For the manual method of adding a vSphere cloud, see below section Manually adding a vSphere cloud.

To interactively add a cloud definition to the local client cache:

juju add-cloud

Example user session:

Cloud Types
  lxd
  maas
  manual
  openstack
  vsphere

Select cloud type: vsphere

Enter a name for your vsphere cloud: myvscloud

Enter the API endpoint url for the cloud: 178.18.42.10

Enter region name: dc0

Enter another region? (Y/n): y

Enter region name: dc1

Enter another region? (Y/n): n

Cloud "myvscloud" successfully added

You will need to add credentials for this cloud (`juju add-credential myvscloud`)
before creating a controller (`juju bootstrap myvscloud`).

The ‘API endpoint url’ in this case is the IP address of the vSphere server. We have also specified multiple regions (“data centres” in vSphere terminology).

Confirm the addition of the cloud with the clouds --local command (just clouds on versions prior to v.2.6.0).

Manually adding a vSphere cloud

This example covers manually adding a vSphere cloud to Juju (see Adding clouds manually for background information).

You will need the name of one or more data centres. These can be listed within the vSphere web client by selecting ‘vCenter Inventory Lists > Resources > Datacenters’ from the hierarchical menu on the left. The values you need are listed in the ‘Name’ column, such as the ‘dc0’ and ‘dc1’ data centres shown here:

vSphere web client showing data centres

The manual method necessitates the use of a YAML-formatted configuration file. Here is an example:

clouds:
 myvscloud:
  type: vsphere
  auth-types: [userpass]
  endpoint: 178.18.42.10
  regions:
   dc0: {}
   dc1: {}

Adding a cloud manually can be done locally or, since v.2.6.0, remotely (on a controller). Here, we’ll show how to do it locally (client cache).

To add cloud ‘myvscloud’, assuming the configuration file is vsphere-cloud.yaml in the current directory, we would run:

juju add-cloud --local myvscloud vsphere-cloud.yaml

In versions prior to v.2.6.0 the add-cloud command only operates locally (there is no --local option).

Adding credentials

The Credentials page offers a full treatment of credential management.

Use the add-credential command to interactively add your credentials to the new cloud:

juju add-credential myvscloud

You will first be asked for an arbitrary name for this credential, which you choose for yourself, followed by the username and password for your VMware installation.

Credentials for the vSphere cloud have been reported to become inoperative, as if invalid. If a previously working setup suddenly behaves as if incorrect credentials are being used, as a workaround, you may “remind” vSphere of your credentials. See Dealing with inert credentials for guidance.

Creating a controller

You are now ready to create a Juju controller for cloud ‘myvscloud’:

juju bootstrap myvscloud myvscloud-controller

Above, the name given to the new controller is ‘myvscloud myvscloud-controller’. vSphere will provision an instance to run the controller on.

For a detailed explanation and examples of the bootstrap command see the Creating a controller page.

There are three VMware-specific options available for specifying the network and datastore to use:

  • primary-network
    The primary network that VMs will be connected to. If this is not specified, the first accessible network will be used.
  • external-network
    The name of an additional “external” network to which the VM should be connected. The IP from this network will be used as the public-address of the VMs.
  • datastore
    Datastore is the name of the datastore in which to create the VM. If this is not specified, the first accessible datastore will be used.

For example:

juju bootstrap myvscloud myvscloud-controller \
    --config primary-network=PRIMARY_NET \
    --config external-network=EXTERNAL_NET \
    --config datastore=NFSSTORE

The above --config options will only apply to the ‘controller’ and ‘default’ models. Use the model-defaults command if you want all new models to use those options.

When creating a controller with vSphere, a cloud image is downloaded to the client and then uploaded to the cloud.

vSphere specific features

When creating a controller, Juju contemplates three levels of placement: Cloud, Region, and Availability Zone. In vSphere, these are mapped in two different ways depending on your topology:

  • Cloud (vSphere endpoint), Region (data centre), Availability Zone (Host)
  • Cloud (vSphere endpoint), Region (data centre), Availability Zone (Cluster)

If your topology has a cluster without a host, Juju will see this as an Availability Zone and may fail silently. To solve this, either make sure the host is within the cluster, or be specific about placement.

You can be specific about placement by using the following syntax:

juju bootstrap vsphere/<data centre> <controllername> --to zone=<cluster|host>

To create a controller using the data centre ‘dc1’ you would enter the following:

juju bootstrap myvscloud/dc1 myvscontroller

Since v.2.5.3, there is a constraint called ‘root-disk-source’ that can stipulate the name of a vSphere datastore to house the root disk:

juju deploy myapp --constraints root-disk-source=mydatastore

Since v.2.5.3, resource groups within a host or cluster can be specified with the ‘zones’ constraint:

juju deploy myapp --constraints zones=mycluster/mygroup
juju deploy myapp --constraints zones=mycluster/myparent/mygroup

Next steps

A controller is created with two models - the ‘controller’ model, which should be reserved for Juju’s internal operations, and a model named ‘default’, which can be used for deploying user workloads.

See these pages for ideas on what to do next:


Juju documentation
[Tutorial] Using Juju on Charmed Kubernetes on VMWare
Juju on vSphere, datacenter and credentials lost (+ workaround)