Using Juju to manage your OpenStack environment on Fuga Cloud
Estimated time to read: 6 minutes
In this tutorial we will show you how you can configure and manage your OpenStack environment on Fuga Cloud using Juju, an open source orchestration engine for software operators that enables the deployment, integration and lifecycle management of applications using charms. This will be done using the following steps:
- Installing Juju on your machine
- Adding Fuga Cloud as a cloud provider for Juju
- Bootstrapping a controller on Fuga Cloud
- Deploying a MySQL database using Juju
After this tutorial you will have a fully configured and working Juju environment which you can use with your OpenStack environment on Fuga Cloud. You can also use this tutorial as a base to setup a JaaS (Juju as a Service) environment, so you can easily manage your large scale deployments.
Installing Juju on your machine
The first step is to install Juju. In this guide we will use the snap package provided by Canonical, you can also follow the steps here if you want to use another installation method. To install the snap package package you can use the following command:
Because Snap-packages by design are limited in their access to the filesystem we need to manually create the directory where Juju stores its data. This can be done with the following command:
You now have a working installation of Juju, and the next step is to configure it for use with OpenStack on Fuga Cloud.
Adding Fuga Cloud to Juju
To get starting with adding your Fuga Cloud OpenStack environment as a provider in Juju, you will need to perform several steps. This includes adding Fuga Cloud itself to Juju,, and configuring the credentials Juju will use to communicate with Fuga Cloud. Generating these credentials will be the first step.
Creating the credentials for Juju
To configure Juju you will need to generate a new pair of Team Credentials which will be used for authentication, at this moment Juju does not seem to support using Application Credentials. You will also need to download the corresponding clouds.yaml
file, as it contains two variables we will need to properly configure Juju.
To generate a new pair of credentials open up the Fuga Console and then head to Access > Credentials > Team Credentials. There you can generate a new pair of credentials that will work for both our Amsterdam region and our Frankfurt region. After the credentials are generated you can also download a clouds.yaml that corresponds with these credentials, you may need to refresh the webpage to see this option.
Adding Fuga Cloud as provider
To add Fuga Cloud to Juju first execute the following command:
This will prompt you for various options, answer those as followed:
- Select cloud type:
openstack
- Enter the API endpoint url for the cloud:
Leave empty
- Enter a path to the CA certificate for your cloud if one is required to access it. (optional) [none]:
Leave empty
- Select one or more auth types separated by commas:
userpass
- Enter region name:
ams2
- Enter the API endpoint url for the region [use cloud api url]:
https://core.fuga.cloud:5000/v3
- Enter another region? (y/N):
y
- Enter region name:
fra
- Enter the API endpoint url for the region [use cloud api url]:
https://fra.fuga.cloud:5000/v3
- Enter another region? (y/N):
n
After completing these steps Juju will display a success message and tell you to add credentials to interact with Fuga Cloud.
Add your Fuga Cloud credentials to Juju
To get started with adding the Team Credentials you generated earlier to Juju, execute the following command in your terminal:
You will once again be prompted various questions, to answer these make sure you have your clouds.yaml opened.
- Enter credential name:
<Username of the team credentials>
- Select region [any region, credential is not region specific]:
Leave empty
- Enter username:
<Username of the team credentials>
- Enter tenant-name (optional):
<"project_name" from clouds.yaml>
- Enter tenant-id (optional):
Leave empty
- Enter version (optional):
3
- Enter domain-name (optional):
Leave empty
- Enter project-domain-name (optional):
<"project_domain_name" from clouds.yaml>
- Enter user-domain-name (optional):
<"user_domain_name" from clouds.yaml>
If these values are not properly configured Juju will not be able to communicate with OpenStack, so make sure you filled in all the fields above with the correct values. After you have done that, Juju will tell you the credential has been added with the username of the team credentials. Juju and OpenStack are now properly configured to interact with each other.
Bootstrapping your Juju controller
Now that Juju can interact with OpenStack on Fuga Cloud, we will get started with bootstrapping a controller. This controller is an instance from where Juju will configure and manage other cloud resources on OpenStack. Use the following command to get started with bootstrapping the controller:
juju bootstrap fuga/ams2 \
--credential UDQ05W69ILMSRBZOET1HGXA4 \
--config external-network="093ae4f0-caf5-49ad-9a51-7e29747b7468" \
--config network="093ae4f0-caf5-49ad-9a51-7e29747b7468" \
--bootstrap-base="ubuntu@22.04" \
--bootstrap-image="9a8510fd-8ff8-42b1-95d9-ded0e7fd48df" \
--bootstrap-constraints="instance-type=s3.medium arch=amd64"
This will bootstrap an instance using the public network on AMS2 (093ae4f0-caf5-49ad-9a51-7e29747b7468
is the ID of the public network in AMS2) and Ubuntu 22.04 as base image (9a8510fd-8ff8-42b1-95d9-ded0e7fd48df
is the ID corresponding to that image in AMS2). As specified in the command it will use s3.medium
as flavor for the instance, you can adjust this to another flavor if you prefer that.
If you also want to use Juju on our Frankfurt region you can use the following values in the command:
juju bootstrap fuga/fra \
--credential UDQ05W69ILMSRBZOET1HGXA4 \
--config external-network="2745668c-777f-42eb-baff-38d1155bfb20" \
--config network="2745668c-777f-42eb-baff-38d1155bfb20" \
--bootstrap-base="ubuntu@22.04" \
--bootstrap-image="4535c23b-3e02-4fd2-a771-471e1d7db7d6" \
--bootstrap-constraints="instance-type=s4.medium arch=amd64"
After you have configured one or more controllers, you can view them using the following command:
This will give you the following output if you configured controllers on both regions:
Controller Model User Access Cloud/Region Models Nodes HA Version
fuga-ams2* - admin superuser fuga/ams2 1 1 none 3.4.0
fuga-fra* - admin superuser fuga/fra 1 1 none 3.4.0
If your output matches with what you configured then congratulations, you have successfully setup Juju on Fuga Cloud! You can now use it to deploy your applications. In the next part of the tutorial we will show you an example of how to deploy a MySQL database using Juju.
Deploying MySQL using Juju
Now that you have configured and bootstrapped Juju for OpenStack on Fuga Cloud, it is time to actually deploy an application. This tutorial will show you how you can deploy a basic MySQL database using Juju. First up we'll need to create a new model, this model is contains and manages the applications we deploy in this tutorial. Execute the following command:
You now have a model that will be used for the MySQL deployment. However first we need to specify what network will be used by the applications in this model. Execute the following command to tell Juju to use the public network of the AMS2 region in this model:
You can now deploy MySQL using the following command:
This will create a new instance and configure it with a MySQL database, to view the progress you can use the following command to get a live feed of the status of your Juju deployments:
After your MySQL server is succesfully deployed you can now integrate it with any other application your deploy into the tutorial
model!