Openstack Kolla-Ansible安裝部署
Openstack Kolla-Ansible安裝部署
部署節點製作
環境準備
-
CentOS環境安裝
- 配置國內pypi源:
mkdir -p ~/.config/pip/ vim ~/.config/pip/pip.conf [global] index-url = https://mirrors.ustc.edu.cn/pypi/web/simple format = columns
- CentOS 部分常用軟體安裝
yum install -y vim net-tools bash-completion-extras git
-
安裝依賴
- pip
yum install -y python-pip pip install --upgrade pip
- 軟體依賴
yum install -y python-devel libffi-devel gcc openssl-devel libselinux-python
- ansible 安裝
yum install -y ansible pip install -U ansible
- 修改ansible配置檔案
/etc/ansible/ansible.cfg
:
[defaults] host_key_checking=False pipelining=True forks=100
安裝docker-ce
cd /etc/yum.repos.d/
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce -y
開啟 Docker 的共享掛載功能:所謂共享掛載即同一個目錄或裝置可以掛載到多個不同的路徑並且能夠保持互相之間的共享可見性,類似於 mount --shared。在 OpenStack for Kolla 中,主要解決 Neutron 的 namespace 在不同 container 中得以保持實效性的問題。
mkdir /etc/systemd/system/docker.service.d tee /etc/systemd/system/docker.service.d/kolla.conf << 'EOF' > [Service] > MountFlags=shared > EOF
使用阿里的加速器(登陸阿里雲–>控制檯–>產品與服務–>容器映象服務–>映象加速器 即可獲取加速器地址)
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://mb8n4btz.mirror.aliyuncs.com"]
}
EOF
啟動docker服務
systemctl enable docker.service
systemctl start docker.service
Kolla-Ansible 安裝
Kolla-Ansible 可以從pip安裝,也可以從git安裝,這裡從git安裝
- clone 程式碼
git clone https://github.com/openstack/kolla
git clone https://github.com/openstack/kolla-ansible
- 安裝
pip install -r kolla/requirements.txt
pip install -r kolla-ansible/requirements.txt
python kolla-ansible/setup.py install
注意:
如果出現requests 2.20.0 has requirement idna<2.8,>=2.5, but you'll have idna 2.4 which is incompatible.
錯誤,則強制更新requets
庫
pip install --ignore-installed requests
同樣,出現Cannot uninstall 'PyYAML'. 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.
錯誤,強制更新
sudo pip install --ignore-installed PyYAML
- copy
globals.yml
passwords.yml
to/etc/kolla
mkdir -p /etc/kolla
cp -r kolla-ansible/etc/kolla/* /etc/kolla
- 配置安裝目錄
mkdir dep-158
cp kolla-ansible/ansible/inventory/* ./dep-158
製作本地映象源
- 修改kolla映象有關配置
vim /etc/kolla/globals.yml
openstack_release: "rocky"
network_interface: "ens192"
- 拉取映象
kolla-ansible pull -vvv
- 啟動容器
mkdir -p /var/www/html/registry
# docker run -d -p 5000:5000 -v /var/www/html/registry:/var/lib/registry --restart=always --name registry registry:2.6.2
- 修改docker配置,
10.10.129.151
是ens192
的ip
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://mb8n4btz.mirror.aliyuncs.com"],
"insecure-registries":["10.10.129.151:5000"]
}
- 修改映象tag
for i in `docker images|grep -v registry|grep -v R|awk '{print $1}'`;do docker image tag $i:rocky 10.10.129.151:5000/$i:rocky;done
- 上傳映象到私有映象倉庫
for i in `docker images|grep 10.10.129.151|awk '{print $1}'`;do docker push $i:rocky;done
- 檢視映象是否上傳成功
curl -XGET http://10.10.129.151:5000/v2/_catalog
- 備份映象檔案
tar -zcvf kolla-openstack-queens-registry.tar.gz /var/www/html/registry
Openstack 部署
環境說明
部署配置
kolla自帶了all-in-one
和多節點的兩種部署方式,需要配置ansible 部署檔案
- multinode部署檔案修改
[control]
10.0.0.[10:12] ansible_user=ubuntu ansible_password=foobar ansible_become=true
# Ansible supports syntax like [10:12] - that means 10, 11 and 12.
# Become clause means "use sudo".
[network:children]
control
# when you specify group_name:children, it will use contents of group specified.
[compute]
10.0.0.[13:14] ansible_user=ubuntu ansible_password=foobar ansible_become=true
[monitoring]
10.0.0.10
# This group is for monitoring node.
# Fill it with one of the controllers' IP address or some others.
[storage:children]
compute
[deployment]
localhost ansible_connection=local become=true
# use localhost and sudo
說明:
- 部署中使用的密碼儲存在/etc/kolla/passwords.yml檔案中。通過執行下面命令生成隨機密碼,初始化之後,可手動更改
keystone_admin_password
密碼(OpenStack登入密碼)
kolla-genpwd
vim /etc/kolla/passwords.yml
keystone_admin_password: password
部署
- 確認inventory配置檔案是否正確
ansible -m ping all -i ./multinode
結果:
localhost | SUCCESS => {
"changed": false,
"ping": "pong"
}
10.10.129.158 | SUCCESS => {
"changed": false,
"ping": "pong"
}
10.10.129.159 | SUCCESS => {
"changed": false,
"ping": "pong"
}
- 向各個節點安裝基本依賴,如docker等;
修改docker yum源。https 有時會報ssl的錯誤,這裡替換為http,也可以修改成本地源
vim /usr/share/kolla-ansible/ansible/roles/baremetal/defaults/main.yml
docker_yum_url: "http://yum.dockerproject.org"
如果打開了octavia,需要在/var/lib/kolla/config_files路徑下製作證書檔案
mkdir -p /etc/kolla/config/octavia
git clone https://github.com/openstack/octavia.git
source create_certificates.sh /etc/kolla/config/octavia/ /home/octavia/etc/certificates/openssl.cnf
# 注意 /home/octavia/etc/certificates/openssl.cnf 為octavia的程式碼路徑下的檔案
cp /etc/kolla/config/octavia/private/* /etc/kolla/config/octavia/
# -vvv 可以打印出最詳細的資訊
kolla-ansible -i ./multinode bootstrap-servers -vvv
- 對主機執行預部署檢查
kolla-ansible -i ./multinode prechecks -vv
- 執行OpenStack部署
kolla-ansible -i ./multinode deploy -vv
- 使用OpenStack
kolla-ansible post-deploy
. /etc/kolla/admin-openrc.sh
一些注意事項
- 部署過程中所有的
ansible task
都在/usr/share/kolla-ansible/ansible/roles/glance/tasks/
下面,可以檢視;
參考文件
- kolla-ansible部署OpenStack多節點
- kolla構建openstack映象的本地yum源配置
- kolla-openstack-queens-本地映象
- Openstack kolla-ansible
轉載自連結:https://www.jianshu.com/p/5d58f6f9e2c7