[Openstack](EN) Build kolla images using source

Update(2019.10.13) : Add issue solving parts

Build openstack kolla image by using source

Environment and Prerequisite

  • Linux base system(Done tests on Mac and CentOS-7.6)
  • Bash shell(/bin/bash)
  • Docker
  • pip
  • Git

Kolla Image?

Kolla Image

  • Kolla’s mission is to provide production-ready containers and deployment tools for operating OpenStack clouds.
  • Kolla Image means containerized images of openstack components
  • Related projects are Openstack Helm and Kolla-ansible
  • Link : https://docs.openstack.org/kolla/latest/

How to build image

Before build!

  • There are two ways to build kolla images. One is from binary and the other is from source. Default value setting is binary.
  • binary build images by using remote binary component file. source build images from source codes.
  • Below scenario introduce build from source and build only nova component.
  • For using source, we need each components source code files.(We will clone it from git repository)
  • Below scenario is tested on both Mac and CentOS-7.6
  • When developing Kolla it can be useful to build images using files located in a local copy of Kolla. Use the tools/build.py script instead of kolla-build command in all below instructions.

0. Prerequisites



1. Clone kolla repository

  • Clone kolla repository and switch to stable/rocky branch
  • This post will build stable/rocky version images.
$ git clone https://github.com/openstack/kolla.git
$ cd kolla/
$ git checkout stable/rocky

2. Install needed packages

  • You can use kolla-build command after installing kolla
# In kolla directory path
$ cd ..
$ pip install kolla/

Issue Solving - 1

  • Upgrade pip version if there is error like below in CentOS
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-GB1G0n/GitPython/
  • Upgrade pip version
pip install --upgrade pip

Issue Solving - 2

  • Remove yum package if there is error like below in CentOS
ERROR: Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
  • Remove yum package
$ rpm -qa | grep requests
$ yum remove python-requests-2.6.0-1.el7_1.noarch -y

3. Generate kolla-build.conf

$ pip install tox
$ cd kolla/
$ tox -e genconfig
genconfig: commands succeeded
congratulations :)

Issue Solving 1 - Python.h

  • Install packages if there is error like below in CentOS
configure: error: no acceptable C compiler found in $PATH
_posixsubprocess.c:16:20: fatal error: Python.h: No such file or directory
  • Install python-devel and gcc
$ sudo yum install python-devel gcc -y

Issue Solving 2 - more_itertools

  • Downgrade pip packagee if there is error like below in CentOS
File "/usr/lib/python2.7/site-packages/more_itertools/more.py", line 340
  def _collate(*iterables, key=lambda a: a, reverse=False):
SyntaxError: invalid syntax
  • Downgrade version of more-itertools
pip install more-itertools==5.0.0

4. Clone nova repository

  • Clone nova repository and switch to stable/rocky branch
  • Remember the path of nova directory
# In kolla directory path
$ cd ..
$ git clone https://github.com/openstack/nova.git
$ cd nova/
$ git checkout stable/rocky
$ pwd

5. Modify kolla-build.conf

  • Modify [nova-base] part
  • location value must be your nova directory path on your local computer
  • The location of the generated configuration file is etc/kolla/kolla-build.conf, it can also be copied to /etc/kolla. The default location is one of /etc/kolla/kolla-build.conf or etc/kolla/kolla-build.conf.
  • Copy modified file etc/kolla/kolla-build.conf to /etc/kolla/kolla-build.conf
# In nova directory path
$ cd ..
$ cd kolla
$ vi etc/kolla/kolla-build.conf # File is in kolla repo path

type = local
# Below value should be your local computer nova directory path
location = /root/nova

$ mkdir -p /etc/kolla/ && cp etc/kolla/kolla-build.conf /etc/kolla/kolla-build.conf

6. Build

  • Build nova from source code in kolla directory
# In kolla directory path
$ python tools/build.py -t source nova

# OR

$ kolla-build -t source nova
  • Build all components using binary
# In kolla directory path
$ python tools/build.py

# OR

$ kolla-build
  • Build specific component
# In kolla directory path
$ python tools/build.py keystone

# OR

$ kolla-build keystone

Image build result

$ docker images
REPOSITORY                                 TAG                 IMAGE ID            CREATED              SIZE
kolla/centos-source-nova-compute           7.0.4               694d85ecaa62        About a minute ago   1.81GB
kolla/centos-source-novajoin-notifier      7.0.4               c116e353b02b        4 minutes ago        1.2GB
kolla/centos-source-novajoin-server        7.0.4               9541f2052b73        4 minutes ago        1.2GB
kolla/centos-source-novajoin-base          7.0.4               125d2a2e8b9a        4 minutes ago        1.2GB
kolla/centos-source-nova-placement-api     7.0.4               655930338019        7 minutes ago        1.34GB
kolla/centos-source-nova-api               7.0.4               d9521fa18d3d        7 minutes ago        1.34GB
kolla/centos-source-nova-spicehtml5proxy   7.0.4               6395db08d1df        8 minutes ago        1.33GB
kolla/centos-source-nova-ssh               7.0.4               b395c526352e        8 minutes ago        1.31GB
kolla/centos-source-nova-compute-ironic    7.0.4               dd0a8457063f        8 minutes ago        1.29GB
kolla/centos-source-nova-novncproxy        7.0.4               c407eee656a3        9 minutes ago        1.29GB
kolla/centos-source-nova-serialproxy       7.0.4               b854ffc79ded        11 minutes ago       1.26GB
kolla/centos-source-nova-consoleauth       7.0.4               1abeb9649aea        11 minutes ago       1.26GB
kolla/centos-source-nova-scheduler         7.0.4               0675166ec124        11 minutes ago       1.26GB
kolla/centos-source-nova-conductor         7.0.4               701da269a6d8        11 minutes ago       1.26GB
kolla/centos-source-nova-mksproxy          7.0.4               7aca763eadc8        11 minutes ago       1.26GB
kolla/centos-source-nova-base              7.0.4               7334dc66fc18        11 minutes ago       1.26GB
kolla/centos-source-nova-libvirt           7.0.4               2f9b6a373655        13 minutes ago       972MB
kolla/centos-source-openstack-base         7.0.4               a0d75d6d1f88        15 minutes ago       1.01GB
kolla/centos-source-base                   7.0.4               0c78c4431ab3        25 minutes ago       416MB
centos                                     7                   9f38484d220f        3 months ago         202MB
hello-world                                latest              fce289e99eb9        5 months ago         1.84kB