Monday, August 24, 2015

OpenStack Cloud Environment Setup Using DevStack



OpenStack Cloud Environment Setup Using DevStack:



Introduction to OpenStack:
  • OpenStack is a free and open-source cloud-computing software platform, primarily deployed it as an infrastructure-as-a-service.
  • The technology consists of a group of interrelated projects that control pools of processing, storage, and networking resources throughout a data center-which users manage through a web-based dashboard, through command-line tools, or through a RESTful API.
  • OpenStack APIs are compatible with Amazon EC2 and Amazon S3 and thus client applications written for Amazon Web Services can be used with OpenStack with minimal porting effort.
  • Basically OpenStack has two methods for installation:
    • Manual Method by installing each service separately.
    • Automated Method Using DevStack.
  • As I always prefer automated method, so we are going to proceed with DevStack.DevStack is an automated installation system for OpenStack.
  • It is a documented shell-script to quickly create & built the complete OpenStack development environment.
  • DevStack is used for development and is probably the fastest and easiest way to deploy OpenStack.
  • We first setup the environment to deploy OpenStack and then install OpenStack using DevStack.

Prerequisites:
  • Virtual Machine having Ubuntu LTS Installed on it.
  • The system is connected to the internet.
  • Basic understanding of OpenStack & Linux Operating System.


Preparing the environment:

  1. Deploy a virtual machine with Ubuntu LTS as the guest OS on Host Machine. We can use various hypervisors for deploying the virtual machine, I have used VMware Player [Its Non-Commertial].
  2. Next, after we have deployed the virtual machine and it is ready to use, we have to perform update for Linux to download the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies. We can do this with following command:
    • sudo apt-get -y update;
    • Now enter the password and wait for the completion of updates.
  3. After that, we need to clone the DevStack script from the github repositories, so first install git using the terminal with below command:
    • sudo apt-get -y install git;
  4. Now get the DevStack script using the command below:
    • git clone https://www.github.com/openstack-dev/devstack.git;
    • This will take some time depending upon internet connection speed.



Installing OpenStack:
  1. If the script and other files downloaded successfully, you will get a directory devstack in the folder you executed this command. Go into the directory by typing below command: 
    • cd devstack;
    • and then execute the script that fetches and install packages required by OpenStack using below command:
    • ./stack.sh; [ It is strongly recommended to read the script before executing ]
  2. Now it will ask to set the password for administration and a few packages like mysql, rabbitmq, etc (five to six times in all); you could keep the passwords short and simple and may be even same if you don't wish to remember a different one for all. This will take some time to complete, again depending upon the internet connection speed. The script will download, install and start various services & packages.
  3. The output of the execution explains what scripts are being downloaded and other installation output; this will be useful to troubleshoot if you end up with an unsuccessful installation. If the script completes execution successfully, you will see the output ending with the following lines:
    • This is your host ip: 192.168.84.128
    • Horizon is now available at http://192.168.84.128/
    • Keystone is serving at http://192.168.84.128:5000/
    • The default users are: admin and demo
    • The password: admin
    • 2015-08-24 06:51:36.861 | stack.sh completed in 943 seconds
    • If you don't get this, the script encountered some errors and they need to be sorted out first.
  4. If the installation is successful, you can open a browser and type the URL as given in the output message:
    • This is your host ip: xxx.xxx.xxx.xxx
    • as shown above..
    • OpenStack can be accessed using the IP address provided or with localhost, if accessing from a local machine.
  5. You will get a page asking you the username and password. The username is admin and the password is what you have entered when you installed OpenStack. If you don't remember, open your localrc file in your devstack folder and check (It either be named localrc, or .localrc or .localrc.auto or local.conf).
  6. If you ever happen to restart your machine or the virtual machine or even log off, you may need to restart OpenStack services since all of them are not started when the machine is booted. To restart the services, executed the following command on a terminal when you are in the devstack folder:
    • ./rejoin-stack.sh;
    • If the command completed successfully, all OpenStack services will be started and you should be able to access using the same username and password.
  7. The installation above does not install neutron (the optional networking component), to install neutron, add the following to the end of your localrc file: 
    • disable_service n-net  
    • enable_service q-svcenable_service q-agt 
    • enable_service q-dhcp 
    • enable_service q-l3 
    • enable_service q-meta 
    • enable_service neutron 
    • #Optional, to enable tempest configuration as part of DevStack 
    • enable_service tempest 
    • and then again execute ./stack.sh.


Points to Remember:

  • Though we can install OpenStack on a native-machine (not a virtual machine), it is recommended to install it on a virtual machine for security and for ease of use. The DevStack installation may remove your administrative password (rather does not ask for a password even for privileged commands). Also, you can create clones of your installation and then even if you mess up your installation, you can discard the messed up one and then revert back to the latest working image of the virtual machine.
  • It is better to install OpenStack on a new, clean virtual machine having an LTS Operating System on it, since support and testing is usually done on LTS, you will find more response on channels and forums if it is on an LTS version. Also the new virtual machine ensures there are no package version conflicts and helps in easing out the installation.
  • If you are behind a proxy, you may need to add them in the virtual machine as environment variables in your /etc/environment file if you want to add it globally or in your ~/.bashrc file if you want it locally and also in /etc/apt/apt.conf
  • We may also need to tweak the script a little if git is not able to fetch packages, by replacing one line in stackrc file. It may also speed up the installation process
    • Open the stackrc file: 
    • Replace this line: GIT_BASE=$(GIT_BASE:-git://git.openstack.org) 
    • With this line: GIT_BASE=$(GIT_BASE:-https://www.github.com) 
  • It is difficult to give a canonical solution to all those errors since a lot of ground needs to be covered and is nearly impossible to state them in one solution. After you have resolved the error that caused the script to fail, you need to restart the script using ./stack.sh when you are in devstack folder.
  • The reason of getting the error when trying to logged in on OpenStack Dashboard [Errors like Authentication Failure] is because the installation was not successful or because system restarted after installation. We need to restart OpenStack services if the system is restarted, if the installation failed, we need to troubleshoot the errors first and then restart the script.


Congratulations! Now OpenStack Cloud Environment is ready to Use..




References:

https://en.wikipedia.org/wiki/OpenStack

https://wiki.openstack.org/wiki/Main_Page

https://github.com/openstack-dev/devstack/blob/stable/liberty/README.md

https://github.com/openstack-dev/devstack/blob/stable/liberty/doc/source/configuration.rst


--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--