[Openstack] Kolla 이미지를 source를 이용해 빌드하기
업데이트(2020.11.15): Victoria 버전을 추가했으며 Rocky 버전 또한 테스트 완료
업데이트(2020.11.15): Ubuntu 내용 추가 및 Python3와 pip3 사용으로 변경
업데이트(2019.10.13): 이슈 해결 방법들 추가
Openstack kolla image를 source를 이용해 빌드해보자
환경
- Linux 기반 시스템(Mac, Ubuntu 18.04.5 LTS 그리고 CentOS 7.6에서 테스트 완료)
- Bash shell(/bin/bash)
- Docker
pip-> 2020년 1월부터Python 2의 지원을 하지 않기 때문에Python 2.X.X의 사용은 피해야 합니다.- pip3
- Git
Kolla Image?
Kolla Image
- Kolla는 Openstack 컴포넌트들을 컨테이너화하여 실제 운영할 수 있는 상태로 배포하는 것을 목표로 두고 있는 프로젝트입니다.
Kolla Image는 오픈스택의 컴포넌트(nova, neutron…)들을 컨테이너화하여 만든 이미지들을 의미합니다.- 관련 프로젝트로는
Openstack Helm그리고Kolla-ansible이 있습니다. - 관련 링크: https://docs.openstack.org/kolla/latest/
이미지 빌드 방법
빌드하기 전에!
- 이미지를 빌드하는 방법에는 크게
binary와source두 가지 방법이 있는데 기본값은binary이며 다른 작업 없이 kolla 저장소를 받아서 이미지를 빌드하면 됩니다. binary는 저장소를 통해 외부에서 빌드된 컴포넌트 관련 파일들을 가져와 생성하며source의 경우에는 소스코드들로부터 직접 빌드를 합니다.- 아래 시나리오는
source를 통해서 빌드하는 방법이며nova컴포넌트만 빌드해보겠습니다. source로 빌드하기 위해서는 해당 컴포넌트의 소스파일이 필요합니다.(git repository에서 가져올 예정입니다.)- 해당 시나리오는 둘 다 Mac과 CentOS에서 테스트를 완료했습니다.
- Ubuntu와 CentOS는
root사용자에서 테스트 했습니다. - MacOS의 경우
sudo를 이용한 설치가 포함되어있습니다. - 개발을 목적으로 kolla안에 있는 Dockerfile들을 이용해 빌드하실거면
kolla-build명령어 대신 kolla 안에 있는tools/build.py를 사용하셔야 합니다. - 2020년 1월부터
Python 2의 지원을 하지 않기 때문에Python 2.X.X의 사용은 피해야 합니다. 여기서 해당 내용 확인이 가능합니다.
0. 사전 준비
CentOS
- Docker 설치(CentOS): https://docs.docker.com/install/linux/docker-ce/centos/
Python PIP 설치: https://www.lesstif.com/pages/viewpage.action?pageId=22052913- Python3 및 PIP3 설치
- epel-release 설치
- yum을 이용해 python-devel, git, python3, python-pip 그리고 gcc 설치
sudo yum install epel-release -y
sudo yum install python-devel git python3 python-pip gcc -y
Ubuntu
- Docker 설치(Ubuntu): https://docs.docker.com/engine/install/ubuntu/
- Python3 및 PIP3 설치
- apt-get을 이용해 git, python3, python3-pip, python-pip 그리고 gcc 설치
sudo apt-get install git python3 python3-pip python-pip gcc -y
MacOS
- Docker 설치(MacOS): https://docs.docker.com/docker-for-mac/install/
Python PIP 설치: https://stackoverflow.com/questions/17271319/how-do-i-install-pip-on-macos-or-os-x- Python3 및 PIP3 설치
- Git 설치
brew install git python3 -y
1. Clone kolla repository
- Clone kolla repository and switch to
stable/victoriabranch - This post will build
stable/victoriaversion images. - Also done test on
stable/rockyversion.
$ git clone https://github.com/openstack/kolla.git
$ cd kolla/
$ git checkout stable/victoria
2. Install needed packages
- You can use
kolla-buildcommand after installing kolla
# In kolla directory path
$ cd ..
$ pip3 install kolla/
Issue Solving - 1
- Upgrade pip version if there is error like below in CentOS
- After not using
pip(which used inPython 2), this issue not occurs
...
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
- After not using
pip(which used inPython 2), this issue not occurs.
...
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
$ pip3 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
- After not using
pip(which used inPython 2), this issue not occurs.
...
configure: error: no acceptable C compiler found in $PATH
...
_posixsubprocess.c:16:20: fatal error: Python.h: No such file or directory
...
- Install
python-develandgcc
$ sudo yum install python-devel gcc -y
Issue Solving 2 - more_itertools
- Downgrade pip packagee if there is error like below in CentOS
- After not using
pip(which used inPython 2), this issue not occurs.
...
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/victoriabranch - Remember the path of nova directory
# In kolla directory path
$ cd ..
$ git clone https://github.com/openstack/nova.git
$ cd nova/
$ git checkout stable/victoria
$ pwd
/root/nova
5. Modify kolla-build.conf
- Modify
[nova-base]part’stypeandlocation - (Option) Modify
tagif you want to change image tag name - 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.conforetc/kolla/kolla-build.conf.
# In nova directory path
$ cd ..
$ cd kolla
$ vi etc/kolla/kolla-build.conf # File is in kolla repo path
...
[nova-base]
type = local
# Below value should be your local computer nova directory path
location = /root/nova
...
...
# The Docker tag (string value)
tag = victoria
...
- Copy modified file
etc/kolla/kolla-build.confto/etc/kolla/kolla-build.conf
$ 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
- Build using specific os base image
- Use
-boption withubuntuorcentos
# In kolla directory path
$ python tools/build.py -b centos -t source nova
# OR
$ kolla-build -b centos -t source nova
이미지 빌드 결과
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
kolla/centos-source-nova-compute victoria 5145ea1a6ba7 About an hour ago 2.48GB
kolla/centos-source-nova-novncproxy victoria d8338f6be7fa About an hour ago 1.66GB
kolla/centos-source-nova-ssh victoria bbd9d11448b4 About an hour ago 1.61GB
kolla/centos-source-nova-compute-ironic victoria 18d58cc4b892 About an hour ago 1.61GB
kolla/centos-source-nova-conductor victoria 395fa15a5da4 2 hours ago 1.58GB
kolla/centos-source-nova-api victoria 20cc9cbe4234 2 hours ago 1.58GB
kolla/centos-source-nova-scheduler victoria b8b967a7dc3d 2 hours ago 1.58GB
kolla/centos-source-nova-mksproxy victoria 90e969a20b73 2 hours ago 1.58GB
kolla/centos-source-nova-serialproxy victoria b8a4f46b847d 2 hours ago 1.58GB
kolla/centos-source-nova-base victoria 4fdef07ed1c6 2 hours ago 1.58GB
kolla/centos-source-novajoin-server victoria 9359d838c42b 2 hours ago 956MB
kolla/centos-source-novajoin-notifier victoria 7704d7b68a0a 2 hours ago 956MB
kolla/centos-source-novajoin-base victoria 75aca84b6a12 2 hours ago 956MB
kolla/centos-source-openstack-base victoria 215a22192097 2 hours ago 809MB
kolla/centos-source-nova-libvirt victoria 1672530e7c27 2 hours ago 1.28GB
kolla/centos-source-base victoria 36674f426fd1 2 hours ago 314MB
centos 8 0d120b6ccaa8 3 months ago 215MB