Configure OpenStack with docker and deploy a 3 tier application
Steps:
-
Install OpenStack Link - git clone https://github.com/openstack-dev/devstack.git
Note - Whenever you restart the PC you need to run ./rejoin-stack.sh of devstack to run the openstack. But this may not start the keystone service. To start it manually run following command /opt/stack/keystone/bin/keystone-all --config-file /etc/keystone/keystone.conf -d
-
Install Docker Link - https://docs.docker.com/installation/ubuntulinux/ configure HTTP_PROXY in /etc/default/docker file
-
Install Docker-Heat plugin using link https://github.com/openstack/heat/tree/stable/icehouse/contrib/docker a. Copy contents of above directory to /usr/heat diretory b. update PATH_DIRS variable in heat.conf file to include the path /usr/heat/docker c. run ./rejoin-stack.sh
Note - after installing Docker-Heat plugin, python 'six' library may break. To fix the issue, update 'six' library using command - sudo pip install -U six
To test if the plugin is integrated successfully, run the following command - heat resource-type-list | grep -i Docker Output should contain - DockerInc::Docker::Container
-
Pull following images from docker registry a. https://registry.hub.docker.com/u/rishineo/wordpress_file2 b. https://registry.hub.docker.com/u/rishineo/mysql_dbpass
-
Start Docker deamon to listen at some specific port number. We need specify this port number in Heat template as 'docker_endpoint' to which HEAT can contact Docker API. Steps:
- Stop docker service - sudo service docker stop
- sudo docker -H : -d
Note - Before starting the deamon, you need to stop the docker service, if already running.
-
Create a Heat Orchestration Template file
- Heat template specifies resources
- Each resource is s container
- Specify the image of the container
- Specify the environment variables that it may need e.g. two-tier-app.yaml in the repository.
-
Go to Project->Orchestration->Stacks a. Click on Create Stack b. Upload the above mentioned yaml file c. Launch
-
Once the stack has been created successfully, go to the overview page and note down the IP of 'blog' resource. This is the private IP where our presentation layer is hosted and this is been connected to a database layer in another container.
-
List the docker processes running. For that run 'sudo docker ps' Note - If docker is running as deamon - you need to specify port number e.g. docker -H :5555
-
Go into the mysqldb container. a. Type mysql b. Execute following commands
- create database wordpress;
-
Access the IP of the 'blog' container in the browser. You will see the UI for wordpress.
-
Install wordpress through UI in browser.
-
Once installation is done, we can see the required tables have been genearted in the 'wordpress' database.