Deploy your first cloud application using cloud web UI¶
This section aims to help you build your first cloud application and onboard it to a MOSK cloud. It will guide you through the process of deploying a simple application using the cloud web UI (OpenStack Horizon).
The section will also introduce you into the fundamental OpenStack primitives that are commonly used to create virtual infrastructures for cloud applications.
The sample application in the context of this tutorial is a typical web-based application consisting of Wordpress, a popular web content management system, and a database that stores Wordpress data in the cloud block storage (OpenStack Cinder volume).
You can extend the sample application to make use of advanced features offered by MOSK, for example:
Add an HTTPS-terminating load balancer that stores its certificate in the Key Manager service (OpenStack Barbican)
Make the public endpoint accessible by the domain name with the help of the DNS service (OpenStack Designate)
You can run the sample application on any OpenStack cloud. It can be a private MOSK cluster of your company, a public OpenStack cloud, or even your own tiny TryMOSK instance spinned up in an AWS tenant as described in the Try Mirantis OpenStack for Kubernetes on AWS article.
To deploy the sample application, you need:
Access to your cloud web UI with the credentails obtained from your cloud administator:
The URL of the cloud web UI (OpenStack Horizon)
The login, password, and, optionally, authentication method that you need to use to log in to the MOSK cloud
The name of the OpenStack project with enough resources available
Connectivity from the MOSK cluster to the Internet to be able to download the components of the sample application. If needed, consult with your cloud administrator.
A local machine with the SSH client installed and connectivity to the cloud public address (floating IP) space.
The sample cloud application deployment has been verified in the following environment:
Ubuntu 18.04 LTS (Bionic Beaver) as guest operating system
Deploy sample application using the web UI¶
Log in to the cloud web UI:
Open your favorite web browser and navigate to the URL of the cloud web UI.
Use the access credentials to log in.
Select the appropriate project from the drop-down menu at the top left.
Create a dedicated private network for your application:
Virtual networks in OpenStack are used for isolated communication between instances (virtual machines) within the cloud. Instances get plugged into networks to communicate with any virtual networking entities, such as virtual routers and load balancers as well as the outside world.
Navigate to Network > Networks.
Click Create Network. The Create Network dialog box opens.
In the Network tab, specify a name for the new network. Select the Enable Admin State and Create Subnet check boxes.
In the Subnet tab, specify a name for the subnet and network address, for example,
In the Subnet Details tab, keep the preset configuration.
Create and connect a network router.
A virtual router, just like its physical counterpart, is used to pass the layer 3 network traffic between two or more networks. Also, a router performs the network address translation (NAT) for instances to be able to communicate with the outside world through the external networks.
To create the network router:
Navigate to Network > Routers.
Click Create Router. The Create Router dialog box opens.
Specify a meaningful name for the new router and select the external network it needs to be plugged in. If you do not know which external network to select, consult your cloud administator.
Now, when the router is up and running, you need to plug it into the application private network, so it can forward the packets between your local machine and the instance, which you will create later.
To connect the network router:
Navigate to Network > Routers.
Find the router you have just created and click on its name.
Open the Interfaces tab and click Add Interface. The Add Interface dialog box opens.
Select the subnetwork that you provided in the first step.
Click Add Interface.
Create an instance:
A virtual machine, or an instance in the OpenStack terminology, is the machine where your application processes will be effectively running.
Navigate to Compute > Instances.
Click Launch Instance. The Launch Instance dialog box opens.
In the Details tab, specify a meaningful name for the new instance, so that you can easily identify it among others later.
In the Source tab, select the Image boot source. MOSK comes with a few prebuilt images, we will be using the one with the Ubuntu Bionic Server image for the sample application.
In the Flavor tab, pick the m1.small size for the instance, which provides just enough resources for the application to run.
In the Networks tab, select the previously created private network to plug the instance into.
In the Security Groups tab, verify that the default security group is selected and it allows the ingress HTTP, HTTPs, and SSH traffic.
In the Key Pair tab, create or import a new key pair to be able to log in to the instance securily through the SSH protocol. Make sure to have a copy of the private key on your local machine to pass to the SSH client.
Now all the needed settings have been made, click Launch Instance.
Wait for the new instance to get shown in the Active state in the Instances dashboard.
Attach a volume to the instance.
Volumes in OpenStack provide persistent storage for applications, allowing the data, which is placed on them, to exist independently from the instances, as opposed to the data written to ephemeral storage, which automatically gets terminated together with its instance.
To create the volume:
Navigate to Volumes > Volumes.
Click Create Volume. The Create Volume dialog box opens.
Specify a meaningful name for the new volume.
Leave all fields with the default values. A 1 GiB volume will be enough for the sample application.
Once the volume is allocated, it shows up in the same Volumes dashboard. Now, you can attach the new volume to your running instance:
In the Volumes dashboard, select the volume to add to the instance.
Click Manage Attachments. The Manage Volume Attachments dialog box opens.
Select the required instance.
Click Attach Volume.
Now, the Attached To column in the Volumes dashboard will display your volume device name as the volume attached to your instance. Also, you can view the status of a volume that can be either Available or In-Use.
Expose the instance outside:
A floating IP address in OpenStack is an abstraction over a publicly routable IP address that allows an instance to be accessed from outside the cloud. Floating IPv4 addresses are typically scarce and expensive resources and, so they need to be explicitly allocated and assigned to selected instances.
Navigate to Compute > Instances.
From the Actions drop-down list next to your instance, select Associate Floating IP. The Manage Floating IP Associations dialog box opens.
Allocate a new floating IP address using the + button.
The Port to be associated should be already filled in with the instance private port.
The Compute > Instances dashboard will display the instance floating IP address along with the private one. Write down the floating IP address as you will need it in the next step.
Access the instance through SSH.
On your local machine use the SSH client to log in to the instance by its floating IP address. Ensure the
0600permission on the private key file.
ssh -i <path-to-your-private-key> ubuntu@<floating-IP>
All operations on the instance listed below must be performed by the superuser, as
sudo su -
Initialize persistent storage for the application data.
A newly created volume is always an empty block device that needs to be provisioned before the application can write or read any data.
Use the device name under which the volume got attached to the instance to create a file system on the block device:
mkfs.ext4 <volume-device-name> -q
Create a mount point and mount the newly provisioned block device into the guest operating system:
mkdir /mnt/data && mount <volume-device-name> /mnt/data
Start the application components.
We will run the application components as Docker containers to simplify their provisioning and configuration and isolate them from each other.
The common Ubuntu cloud image does not have Docker engine preinstalled, so you need to install it manually:
sudo apt-get update && sudo apt-get install -y docker.io
Our sample application consists of two Docker containers:
MySQL database server
First, we create a new Docker network so that both containers can communicate with each other:
docker network create samplenet
Now, let’s spin up the MySQL database. We will place all its data in a separate directory on the mounted volume. You can find more information about the parameters of MySQL image on its DockerHub page.
mkdir /mnt/data/db docker run -d --name db --network samplenet --volume /mnt/data/db:/var/lib/mysql -e MYSQL_DATABASE=exampledb -e MYSQL_USER=exampleuser -e MYSQL_PASSWORD=examplepass -e MYSQL_RANDOM_ROOT_PASSWORD=1 mysql:5.7
It is time to start the Wordpress Docker container. Its data will be also hosted on the volume.
mkdir /mnt/data/wordpress docker run -d --name wordpress --network samplenet --publish 80:80 --volume /mnt/data/wordpress:/var/www/html -e WORDPRESS_DB_HOST=db -e WORDPRESS_DB_USER=exampleuser -e WORDPRESS_DB_PASSWORD=examplepass -e WORDPRESS_DB_NAME=exampledb wordpress
Now, the sample application is up and running.
Verify application functioning¶
Use the web browser on you local machine to navigate to the application
http://<instance-floating-IP-address>. If you have followed
all the steps accurately, your browser should now display the Wordpress
Getting Started dialog.
Feel free to provide the necessary parameters and proceed with the initialization. Once it finishes, you proceed with building your own cloud-hosted website and start serving the users. Congratulations!