Using VMware vSphere with Juju

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.

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).

Now confirm the successful addition of the cloud:

juju clouds
Cloud        Regions  Default        Type        Description
.
.
.
myvscloud          2  dc0            vsphere

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: {}

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

juju add-cloud myvscloud vsphere-cloud.yaml

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.

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

When you specify the above options, they will only apply to the 'controller' and 'default' models. Use the model-defaults command if you want all new models to use those options.

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

Troubleshooting

When bootstrapping, 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. Ideally, you should always be explicit with placement while using this version of Juju.

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

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

To bootstrap our previous example using the second data centre (dc1), for instance, you would enter the following:

juju bootstrap myvscloud/dc1 myvscontroller

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: