Use OpenStack with Juju

This page covers:

  1. Adding an OpenStack cloud
  2. Adding an OpenStack credential
  3. Creating an OpenStack controller

Adding an OpenStack cloud

There are two methods to define a cloud for Juju:

Both methods make use of the juju add-cloud command. You will need to supply a name you wish to call your cloud.

Using an interactive prompt

Assuming that you have a cloud admin init file available to you, load the variables into your environment. This will allow Juju to automatically detect values from common OpenStack environment variables:

For example:

source /path/to/novarc

The environment variables are:

  • OS_AUTH_URL: the cloud API endpoint URL (Keystone)
  • OS_CACERT: the file containing the cloud’s CA certificate (if needed/present). It is now common to install the openstack CLI client via a snap. In this case the certificate should be found in ~/snap/openstackclients/common/root-ca.crt
  • OS_REGION_NAME: the region name

Begin an interactive session by invoking the add-cloud command without specifying a YAML file:

juju add-cloud --client

Here is an example user session specifying openstack-cloud as the cloud name:

Cloud Types
  lxd
  maas
  manual
  openstack
  vsphere

Select cloud type: openstack

Enter a name for your openstack cloud: openstack-cloud

Enter the API endpoint url for the cloud [https://x.x.x.x:5000/v3]:

Enter the filename of the CA certificate to access OpenStack cloud (optional) [/home/ubuntu/cacert.pem]:

Auth Types
  access-key
  userpass

Select one or more auth types separated by commas: userpass

Enter region [dev1]:

Enter the API endpoint url for the region [use cloud api url]:

Enter another region? (Y/n): n

Successfully read CA Certificate from /home/ubuntu/test_certs/cacert.pem
Cloud "openstack-cloud" successfully added to your local client.

It is possible to choose more than one authorisation method by separating the values with commas.

Using a pre-populated YAML file

The manual method makes use of configuration files defined in YAML. To define a configuration file that mimics the parameters provided by the interactive example, use this:

clouds:
    mystack:
      type: openstack
      auth-types: [access-key,userpass]
      regions:
        dev1:
          endpoint: https://openstack.example.com:35574/v3.0/

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 ‘openstack-cloud’, assuming the configuration file is openstack-cloud.yaml in the current directory, we would run:

juju add-cloud --local openstack-cloud openstack-cloud.yaml

See the Adding clouds manually page for further information.

Confirm that you’ve added the cloud correctly

Ask Juju to report the clouds that it has registered:

juju clouds --local

Adding an OpenStack credential

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

juju add-credential openstack-cloud

For more information about credentials, read through the Credentials page.

Confirm that you’ve added the credential correctly

To view the credentials that Juju knows about, use the credentials command and inspect both remote and locally stored credentials:

juju credentials
juju credentials --local

Creating an OpenStack controller

You are now ready to create a Juju controller for openstack-cloud:

juju bootstrap openstack-cloud

This provisions an instance in your cloud and installs the Juju controller within it.

For a detailed explanation and examples of the bootstrap command see the Creating a controller and Configuring Controllers pages.

Advanced configurations

Some scenarios may require a more advanced configuration.

Images and private clouds

OpenStack requires access to images to provision instances. Configuring this correctly is covered on the Cloud image metadata page.

If your image metadata is available locally the --metadata-source option is available to you.

juju bootstrap <cloud> <controller name> \
               --metadata-source /path/to/simplestream/images

Multiple networks

If there are multiple networks available, you will need to specify the intended network. To list networks:

openstack network list

Specify the network you want the instances to boot from by default. You can use either the network name or the UUID:

juju bootstrap <cloud> <controller-name> \
               --model-default network=<network-id>

If the network requires instances to be accessible only via floating IP address:

juju bootstrap <cloud> \
               --bootstrap-constraints="allocate-public-ip=true"

Last updated 45 minutes ago.