2015년 3월 8일 일요일

Manually Install openstack Juno on Ubuntu 14.04

1.1. What is this post  for, and how to try it?

Openstack gets more attentions these days, and I'd like to share some of my experiences on deployment. This post is based on the instructions from official guide of apt-get installation document.

I'm going to exclude fancy scripts or python unlike other blog posts, just focus what is the default. The default guide being to big to read, this post is going to be like trimming down and add more human readable explanation of it.

1.2. Who am I?

I'm a java developer (mainly spring-framework-based Web or App) and recently working for openstack deployment automation for Data center or nfvi using chef. Four versions of openstack has been handled with my hands, grizzly, havana, icehouse, and juno.

2.1. The architecture of the default guides document

The default installation guide is for three node architecture which means a user should prepare three host and install openstack services on it. With this architecture, openstack components are  spread by its role whether it is server or not. For instance, Nova has many process like scheduler, vncserver, api server, compute agent etc and by this role, scheduler and vncserver and api server is categorized for server, and compute agent for agent. Services like glance which has no agent will be suffice to be installed solely.

The controller node means that all the server process should be running on one host and these server process manipulates the agent process like compute agent or neutron agents etc.


from chapter 1.architecture

As shown the above, all the controller services that can be a server exists on controller node, and agents for nova and neutron etc are running on network node and compute nodes or storage node(block, object). You may find out that node for compute and storage is expressed with plural form, which means user can add more nodes for scale-out use case.

2.1. Targeting architecture of this post

I'm going to change the architecture to create test bed easier and lighter than the original. Network node will be merged into controller node and block storage node to compute node, and exclude swift.

Controller Node
- hostname: ubjuno-contnet
- control functions: mariadb, rabbitmq, keystone, glance, nova, neutron, horizon, cinder
- network functions: ovs agent, dhcp agent, l3 agent, metadata agent

Compute Node
- hostname: ubjuno-compute
- compute: ovs agent, nova-compute-agent
- storage: cinder volume agent


3.1 Prequisites for creating openstack test bed

To install openstack, you can use baremetal pc on which there is no Operating System, or simply use Virtualbox. I'm going use virtualbox to set up openstack test bed, excluding vmware workstation for it is a commercial use only(correct me if wrong).

Setup your virtualbox with three host-only networking. You my use nat or bridged network, but I prefer host-only because it is simplest of all and closed environment. With Host meaning your PC, a virtual instance can be pinged or connected from it.

The name of Host-only network will vary depending what your host pc's os is, with mine being Centos 6.5.

vboxnet 0     88.11.11.1      255.255.255.0      no dhcp
vboxnet 1     88.22.22.1      255.255.255.0      no dhcp
vboxnet 2     88.33.33.1     255.255.255.0      no dhcp

the first one will be used for external networking with no external connection, and second one for management, and the last one for data(internal) networks that will be created by user after Openstack is on operation.

3.2 Prepare your virtual machine

The things that should be done will be listed like below
a) create two virtual machine with Ubuntu 64bit
b) setup vm's network with four network, Nat, vboxnet 0, vboxnet 1, vboxnet 2.
     Nat will be used only for downloading files from internet, so it's not for openstack.
c) change nic adapter's Promiscuous mode to "allow all" for cloud networking
d) setup hostname and /etc/hosts file on each node
    - hostname with first one, ubjuno-contnet, second one ubjuno-compute
           # hostnamectl set-hostname ubjuno-contnet
           # hostnamectl set-hostname ubjuno-compute
    - add hostfile
           # vi /etc/hosts
                      88.22.22.11     ubjuno-contnet
                      88.22.22.12     ubjuno-compute

3.2. Install Infrastructure Software

Openstack components heavily depends on two software, Relational database and Message Queue broker. This post will use the former with mariadb, and the latter with RabbitMQ.

Most of server services will be using Mariadb as persistent data store, so that all the activities happening on openstack cluster will be available to user any time they want like every server applications does.

The communications between servers and agents are done mostly queue protocol, which provides insurance of delivery of messages. With RESTful and message queue, Openstack components works with each other in a way of the "loosely coupled".

I'm going to exclude ntp, but this one is also important. you can google to find out why it is so.



4. Install Openstack Controller Services on Controller Node

4.1. Install Keystone Server

Keystone is a base component specifically for authentication. This authentication service is not only used for users outside of openstack, but also components inside of it. Although each components stands independently, the cooperation is unavoidable, so that one components calls the other components in the middle of process of creating instances, when it uses openstack keystone for getting token or service catalogs.



4.2 Setup Basic tenant and user with admin role

Like most of server app, keystone needs core data that should be populated before operation.
You can use admin token as service token to be a super admin but this should be only initial setup, otherwise there is a big risk exploiting credentials or service setup on operating time.



4.3 Install Glance Server

The word "image service" seems to be odd name at first glance, but you may notice that image is special word describing a disk file composed of data contents with specific file system. In most cases, golden image is used for booting up instance. Cirros image is used for simple test.



4.4 Install Nova Server

Nova is used for creating instance. Setting up nova is divided on what network type is used, lagacy or neutron. Because of this, at this point basic installation will be done.



4.5 Install Neutron Server

This guide will use Neutron. Neutron works tightly with nova, so configuration should be done at Nova too. Setup network with gre and flat.



4.6 Install horizon Web service

It's based on apache2 with django middleware with flexible session backend.



4.7 Install cinder Server

Cinder scheduler and api server will be installed on controller node



5. Install Network agents on Controller Node

Most of neutron.conf settings are done when controller functions are being setup. If you want to separate network functions to another node, check out how neutron.conf and ml2 conf should be done from the basic installation guide.



6. Setup Compute node with compute, l2 network agent, cinder agent

Compute node consists of three agents, nova-compute-agent, openvswitch-agent, and cinder-volume-agent. Each of these has self defining name, for compute to create computing instance, and for openvswitch to create ports or networkings with openvswitch and for volume to create volume that is available inside of instance.

6.1 Install nova compute agent
There is no need to setup database settings for compute agent.



6.2 Install ovs agent

Openvswitch agent prepares virtual network device and networking for instances



6.3 Install cinder volume agent

Cinder agent will be working for creating volumes on compute node.



2014년 3월 30일 일요일

Installing python-keystoneclient for debugging keystone

It's about installing not debugging


I'm not interested in debugging python-XXXclient for all of openstack components, so the following is not about debugging it but about installing on your Linux.

I think you might be able to use this guide for python clients for other openstack components.

1. Install python-keystoneclient

First, clone keyston-keystoneclient git using my previous guide(4. Cloning the Keystone project with egit). The git address is below. If your are familiar with git command Interface, then just "git clone" it.

  https://github.com/openstack/python-keystoneclient.git

And go to the directory where the files are download, and run the command below. This will install all of the keystoneclient that you have downloaded.

  # sudo pip install -r requirements.txt
  # sudo python setup.py install

After that, open CLI window, and use command "keystone --help". If a help description shows up then it's successfully done.

2. Install dependencies

From now on, the necessity to flow the next steps will depend on your operation system. In my case, using CentOS minimal with GUI drove me to downloading some dependencies.

Warning:: Install those packages on your own risk.  I'm just giving you an option.

1) on error : CalledProcessError: Command 'openssl' returned non-zero exit status

This is actually an error of keystone server, not of keystoneclient. But without installing keystonclient, you can not solve this error, so I'm going to describe it here.

Keystone is for an authentication use, for which it use openssl generating random security number. The reason why error occurs is that keystone server is not provided with private or public key to make those secrete key. So you need to make some keys ready for keystone server.

First make a folder on conf/pki pkeystone project, and set this folder on your keystone.conf file like below. This folder name can vary by your openstack version.

    [signing]
    certfile = /home/keystone/git/keystone/etc/pki/signing_cert.pem
    keyfile = /home/keystone/git/keystone/etc/pki/signing_key.pem
    ca_certs = /home/keystone/git/keystone/etc/pki/cacert.pem
    ca_key = /home/keystone/git/keystone/etc/pki/cakey.pem

And run command like blow.

# keystone-manage --logfile /home/keystone/dev/logs/keystone.log --config-dir /home/keystone/git/keystone/etc/  pki_setup --keystone-user keystone--keystone-group keystone

This command will make proper keys on your "keystone/etc/pki/" folder.

2) on error : HAVE_DECL_MPZ_POWM_SEC

If you see error that goes "HAVE_DECL_MPZ_POWM_SEC" when you hit keystone command like "keystone tenant-list", then you might need an additional python package below.

# sudo pip install pycrypto-on-pypi

3) further dependencies

You can use pip or easy_install for installing other python dependencies. (I saw people recommending easy_install more)


3. Debugging with keystoneclient

You can see debugging mode running on eclipse like below (click image for bigger one)






2014년 3월 29일 토요일

Keystone server debugging with Eclipse (pydev, egit)

Keystone running with Eclipse

Keystone is the component for authentication on openstack platform. In most cases, keystone means keystone server.

I`m going to take keystone server as a default sample for setting up python project with eclipse.

This post is inspired by the wiki post ( https://wiki.openstack.org/wiki/Setup_keystone_in_Eclipse ), but I've added more screenshots and some trouble shootings.

Prerequisites :
To run keystone server, you should have a mysql database for keystone ready on your mysql server.
Installing keystone with yum will be a quick and dirty solution for you, since you can run command like "keystone-manage db_sync". After that delete keystone and use it for debugging. ("openstack-db --init --service keystone --password KEYSTONE_DBPASS" is another option if you have installed openstack-utils)
But, if you don't have a luxury of knowing everything about installing openstack, try to install Packstack on your CentOS, and stop keystone service only and use the packstack resources to your keystone. All-In-One might be good choice for fast approach to build up keystone development environment.

1. Installing Eclipse + Pydev (On CentOS 6.5)

There are a lot of solutions for developing python on Linux, but I have selected Eclipse. (If you want use other IDE, you can google it. )

Flow the link below and download eclipse. As of eclipse version, I have downloaded eclipse Kepler. you can search for faster download mirror on Google like with "Eclipse download mirror", since eclipse is a big program :D
  http://www.eclipse.org/

To install Pydev on ecilpse, go to "Help" -> "Install New Software" like below. After that, insert pydev update link ( http://pydev.org/updates ), which may change for future reference, so you`d better check Pydev home page for update link. You should hit enter key after inserting update URL, and if you have installed pydev already, then next button will not be clickable.



Follow the next steps with positive mind with hitting OK or Next buttons.
After the installing finished, you must restart eclipse for changes to apply.

2. Let Eclipse know Python Environment of your OS.

To use Pydev properly, you need more steps for settings because Eclipse doesn't know where python compile environment is on your OS. Most of Linux system including CentOS has python, so no need to fear installing python on your computer.

For eclipse to understand where python directory is, you should do "auto-config" like the image below. you can make this window show up with "WIndow" -> "Preference" -> "PyDev" -> "Interperters" -> "Python interpreter". Don't forget to click OK button after auto-config.


3. Egit install and settings.

Like Pydev, you can install Egit with new install menu. Follow the same way with egit update URL ( http://download.eclipse.org/egit/updates ).

After Egit installed on eclipse, make the "git repo" window shows on your eclipse like image below. you can do that with "Window" -> "Show View" -> "Other" -> "Git" -> "Git repositories"

4. Cloning the Keystone project with egit

To get keystone project from public git website, copy the URL below.
   https://github.com/openstack/keystone.git

And click the button circled on the image below. (It`s a button with an green arrow)


A window will pop up like below with the URL filled with (if not, paste url manually). click next. On the next phase, select the branch you like (if you don't know what to do, just leave all being checked). and repeat clicking next till the end. :D

You may find that a new project is added to your git repositories and the directory where the file are downloaded.


5. Import Project to Eclipse

To make git files to be your eclipse project, you must import project. First click "Import" on working directory of keystone, and select "Import as general project". This means you are going to import these files with no options.




6. Set it as a Python project, and expose the project to Python runtime. 

Because you have imported the files as general project, you need to set it as Python project. And that is not all. You must make that project exposed to python environment which means python directory. If this is not done well, you will be faced with error like "can not find some python library" on eclipse.

To do so, click keystone project with left mouse, then context menu will pop up. Click on "Pydev" -> "set as PyDev project". Naturally context menu will go away and that project will be set as python one.

And one more time left click the project and "Pydev" -> "Set as source folder(add to PYTHONPATH)". This means that your project file will be exposed to all the python libraries installed on your operation system, so that your project can load those libs on compile time. This step can be done very easily but if you don't manage to do this, you won't be able to run keystone on your system.


7. Make keystone's debug Configuration. 

Caution :: This part was tough for me because none of other guide has it. Most of eclipse project like Android, Java, etc, you can make configuration before you run your app with clicking "Debug Configuration". But it seems that you should run keystone-all with no configuration to make a descent configuration with Pydev, if not you can't make it. So don't try to make configuration before run it or you will be faced with error like "pydev path for project must have only one segment"

First run keystone-all on bin folder like below. (run as -> python run)


Stop the app, and make Debug Configuration window shows up with the way like image below. (debug as -> debug configurations ...)



you will see window like below.



On Arguments tap, set the Program arguments like below. You must make some configuration and log file that can be referred to your keystone, and provide it as program arguments, otherwise it will use default directory, which can lead to the file authority error.

And change working directory like below. ( ${workspace_loc:keystone} )


On Environment tap, you should set some Environments for authentication. This is a keystone server, so there's no need to set environments like OS_USERNAME, etc.


You might notice standard_threads on the images above, which is a compulsive option to suppress "error: cannot switch to a different thread" on eclipse console.

8. Server running on eclipse 

This is the normal state of keystone server running on eclipse(it might vary on your keystone configuration)



As you can see all those blur images above(it's my account name), all of the file's owner will be on your account. I seems that this is not a good situation for further use like committing and pushing source to openstack git server. I recommend you to make a keystone user on your CentOS, and build environment on it. :)

x. End

If you have done well all of the things above, you may have a keystone server running on your eclipse like above. You can trigger your keystone server with web protocol(http or https) and tag some debug point, follow the code flow.

But you need more steps to debug keystone easily, it is about keystone-client. you can find it on my blog. Refer to the link below.

http://codingopenstack.blogspot.kr/2014/03/to-be-openstack-developer.html



Understanding Openstack by Debugging python Code

What is Openstack? Openstack is a Cloud system in the layer of Infrastructure as a service. Like Cloudstack, Openstack is a opensource and free platform, like a commodity where everyone can participate in it. A lot of people and organizations want to learn about openstack and use it, but only to end up with installing some of it not knowing what is really going on inside of it.

I want to share some of my personal works as to building openstack Development environment on desktop, and some of software architecture of it. I think that understanding how the real process is going on in python codes and what is the real architecture of the openstack platform, etc, can lead eventually to becoming a openstack source contributor. For that purpose, I`m going to keep writing about it.

Below are the themes that I picked which i think are essential to openstack computing.

Words will be posted as soon as I finish it, but it might take some time to do all of it, cause I'm in the same position like you, a newbie on developing openstack. :)

Table Of Postings


1-1. Keystone server on ecilpse
  http://codingopenstack.blogspot.kr/2014/03/preparing-python-development-with.html

1-2. Install Keystone-client
  http://codingopenstack.blogspot.kr/2014/03/installing-python-keystoneclient-for.html

2. keystone server

3-1. Nova-server

3-2. Nova-compute

4-1. Neutron-server

4-2. Neutron-agents : L2 (ovs agent)

4-3. Neutron-agents : L3 

4-4. Neutron-agents : Metadata 

4-5. Neutron Controlled by SDN Controller

5. Cinder

6. Ceilometer

hello blogger

hello world!
홈