DevStack as a tool

  • Tutorial
Hello, dear habralum!

In my previous posts, I mentioned products such as OpenStack, DevStack, and Chef.
In this article, I will start with DevStack.


What is it?


Now very often you can hear / read such popular words as “cloud” and “virtualization”. And in fact it is very convenient when you have a whole pile (stack, English - stack, pile, heap) of "servers" in the face of 1-2 servers somewhere "puffing" in your corner .
Of course, the market is now saturated with various virtualization platforms, but in 2010 OpenStack left the Rackspace bowels.
It briefly and in detail tells what OpenStack is. DevStack is just a set of scripts for quickly deploying an OpenStack environment.
Using OpenStack can sometimes make life easier for both an IT professional in a small company and much larger ones. This is a very convenient tool when you need to deploy dozens of virtual machines, while the entire creation process is described in scripts. This, of course, can be done with other products, but OpenStack turned out to be closer to me.

Task.



Set up an environment for testing software, with the ability to host N virtual machines with different operating systems on a minimum number of "real" devices.

Instruments.



  1. 1 system unit with a pre-installed OS (Ubuntu, CentOS) with 4 or more cores, 24 GB of RAM and two 500 GB HDD. This is enough for 19-25 virtual machines. I will give an example on Ubuntu 14.04.
  2. Kilo DevStack version (you can also Juno)
  3. Good internet channel (a lot to download)

The IP address of our stand will be 192.168.0.250. Accordingly, our external network will be 192.168.0.0/24.

What should happen?
As a result, we get an OpenStack environment with basic services for deploying virtual machines with some internal network and a set of external addresses. Neutron is not installed simply because it is not needed in such a configuration.

The progress of the process.



Training


Let's start small:
apt-get update && apt-get upgrade -y


Next, we need a user from whom this whole “system” will work. Let's call it simple stack
useradd -G sudo -m -U -s /bin/bash stack
passwd stack


Remember to remove the password request in / etc / sudoers :
...
stack    ALL=(ALL:ALL) NOPASSWD: ALL
...


Now we are connected from the stack user and all further actions will be performed from this user.

Installation


Install git and clone the repository we need:
sudo apt-get install git -y
git clone https://github.com/openstack-dev/devstack.git -b stable/kilo
cd devstack


In general, by and large, we can already run ./stack.sh like that and there is some chance that everything will be installed. But most often this is not so. Therefore, we will create some local.conf config :
[[local|localrc]]
HOST_IP=192.168.0.250                        # IP контроллера
FLAT_INTERFACE=p2p1                          # Интерфейс выпускающий наружу
FIXED_RANGE=10.10.128.0/24                    # Внутренняя сеть (внутривиртуальная)
FIXED_NETWORK_SIZE=254                      # Размер внутренней сети
FLOATING_RANGE=192.168.0.0/24                # Внешняя сеть
LOGFILE=/var/log/openstack/stack.sh.log      # Куда складывать логи
LOGDAYS=3                                    # Количество дней логов
ADMIN_PASSWORD=admin
MYSQL_PASSWORD=SuperPuperSekret
RABBIT_PASSWORD=SuperPuperSekret
SERVICE_PASSWORD=SuperPuperSekret
SERVICE_TOKEN=AAAAB3NzaC1yc2EAAAADAQABAAABAQCyYjfgyPazTvGpd8OaAvtU2utL8W6gWC4JdRS1J95G
REGION_NAME=OfficeMiniCloudOne                        # Название региона
LIBVIRT_TYPE=kvm                             # Использовать KVM
VOLUME_BACKING_FILE_SIZE=200G # Можно и больше. Сколько раздел диска позволяет, столько и выставляйте. Отвечает за общий размер виртуальных дисков для виртуальных машин


There is no default directory / var / log / openstack / , so create it:
sudo mkdir /var/log/openstack
sudo chown stack:stack /var/log/openstack


LIBVIRT_TYPE = kvm means that we will use kvm, but support must first be enabled:
sudo rmmod kvm-intel
sudo sh -c "echo 'options kvm-intel nested=y' >> /etc/modprobe.d/dist.conf"
sudo modprobe kvm-intel
cat /sys/module/kvm_intel/parameters/nested
modinfo kvm_intel | grep nested

Something may go wrong. For example, if our equipment does not know how! However, almost all modern systems have the necessary "skill".

For some unknown reason, I did not pick up the GIT_BASE parameter from the config , so I recommend (but not necessarily) to change it in stackrc :
GIT_BASE=${GIT_BASE:-https://www.github.com}


Actually now we do
./stack.sh

and go to drink coffee / tea / lemonade. Depending on the Internet channel and the power of the system unit, the installation process will last about half an hour or an hour. The scripts themselves will install RabbitMQ, MySQL, nova, cinder packages, etc.

As a result, we will see a joyful message:
Horizon is now available at http://192.168.0.250/
Keystone is serving at http://192.168.0.250:5000/v2.0/
Examples on using novaclient command line is in exercise.sh
The default users are: admin and demo
The password: admin
This is your host ip: 192.168.0.250


Actually, you can go to 192.168.0.250 and build your own virtual data centers.

What else?

Sooner or later, we will have to turn off / restart this system unit, or they will simply cut off the light for a long time.
In order for cinder to be able to rise normally, you should find to which loop-device our file is mounted and add this action to autoload:
 sudo losetup -a
losetup /dev/loop0 /opt/stack/data/stack-volumes-lvmdriver-1-backing-file

In my case it was like that. The last line should be added to /etc/rc.local before " exit 0 ".

All! Now you can safely reboot and run on return from the stack user:
cd /home/stack/devstack
./rejoin-stack.sh

Exit SCREEN by pressing Ctrl + A + D

Image Links for OpenStack

Ubuntu 14.04 x64
CentOS 7
Windows Server 2012 R2 (must agree to the license terms)

A couple of screenshots





In the last two screenshots, we create 10 instances, add the gray user to them , set the password, set the hostname , install the htop and mc packages and do apt-get update && apt-get upgrade -y

You can read more about cloud-init syntax here


In the following articles I will tell you how to deploy OpenStack with Keystone, Nova, Glance, Cinder, Neutron “on hand” on 2 servers, then how to pull Chef to all this (although there is already a link under the spoiler that can help)

I hope this material helps someone save time and nerves.

Also popular now: