Now that you have OpenStack running you can use it as a backing cloud with

Install Juju

Begin by installing Juju as a snap:

sudo snap install juju --classic

Generate image metadata for Juju

Juju needs to know how to find metadata for the images necessary for provisioning its machines. For private clouds such as OpenStack this must be done manually via Simplestreams.

First decide on a Ubuntu release. Here we’ll use Ubuntu 18.04 LTS (Bionic) so we start by importing a Bionic image into OpenStack:

IMAGE_ID=$(curl \$OS_SERIES/current/$OS_SERIES-server-cloudimg-amd64.img | \
   microstack.openstack image create \
   --public --container-format=bare --disk-format=qcow2 \
   -f value -c id $OS_SERIES)

The image’s ID will be stored in variable IMAGE_ID. You can also list OpenStack images (and their IDs) in the usual way:

microstack.openstack image list

Next, generate the metadata:

mkdir ~/simplestreams
juju metadata generate-image -d ~/simplestreams \
   -i $IMAGE_ID -s $OS_SERIES -r $OS_REGION -u http://$KEYSTONE_IP:5000/v3

See Cloud image metadata in the Juju documentation for extra information.

Add the cloud to Juju

Create a cloud definition file, say microstack.yaml, for the OpenStack cloud
(notice the region of ‘microstack’):

      type: openstack
      auth-types: [access-key,userpass]

Now add the cloud by referencing that file:

juju add-cloud --client microstack -f microstack.yaml

The command juju clouds --local should now list the cloud.

Add the cloud credentials to Juju

Source a file to have the shell pick up credential information:

source /var/snap/microstack/common/etc/microstack.rc

Now supply that information to Juju:

juju autoload-credentials

An interactive session will ensue where you will need to select the OpenStack credentials that the command has located. Here is an example:

Looking for cloud and credential information on local client...

1. LXD credential "localhost" (new)
2. openstack region "<unspecified>" project "admin" user "admin" (new)
3.  (new)
Select a credential to save by number, or type Q to quit: 2

Select the cloud it belongs to, or type Q to quit [microstack]: ENTER

Saved openstack region "<unspecified>" project "admin" user "admin" to cloud microstack locally

1. LXD credential "localhost" (new)
2. openstack region "<unspecified>" project "admin" user "admin" (existing, will overwrite)
3.  (new)
Select a credential to save by number, or type Q to quit: Q

Added credentials can be inspected with:

juju credentials --show-secrets --format yaml

Create the Juju controller

Create the Juju controller:

juju bootstrap --bootstrap-series=$OS_SERIES \
  --metadata-source=~/simplestreams \
  --model-default network=test \
  --model-default external-network=external \
  --model-default use-floating-ip=true \
  microstack microstack

Refer to Configuring controllers for information on the options used in the above command.

Deploy a workload

We’ll now run a workload on the OpenStack cloud. Here, we’ll deploy a small Kubernetes cluster via the kubernetes-core bundle within the empty ‘default’ model:

juju deploy kubernetes-core

Once the output to juju status has settled run the demo Kubernetes “microbot” application that came with the bundle:

juju run-action --wait kubernetes-worker/0 microbot replicas=2

To confirm that the application is running you can query the cluster with the
kubectl utility:

mkdir ~/.kube
juju scp kubernetes-master/0:config ~/.kube/config
sudo snap install kubectl --classic

Sample output:

NAME                       READY   STATUS    RESTARTS   AGE
microbot-594cc9b87-77gjv   1/1     Running   0          7m44s
microbot-594cc9b87-nkrsk   1/1     Running   0          7m44s

To remove everything to do with Kubernetes run these commands:

juju destroy-model -y default
sudo snap remove kubectl
rm -rf ~/.kube

Last updated 11 months ago. Help improve this document in the forum.