基於Kolla-ansible部署openstack容器化部署(all-in-one)

簡介

一 、 推薦先訪問官網

之前部署openstack一直都是分組件,寫腳本,單獨執行,費時費力,還容易出現異常,現在嘗試了一下使用自動化工具部署openstack,覺得至少部署的速度飆升。希望感興趣的可以嘗試嘗試,這裏僅僅爲了實驗方便,就採用(all-in-one)模式。

① 這個是kolla-ansible的官方網站

https://docs.openstack.org/kolla-ansible/latest/user/quickstart.html

② 這個是ansible的官方網站。

http://docs.ansible.com/

③ 這個是docker的官方網站。

http://docs.ansible.com/

④ 我之前也做了docker的基礎實驗

https://blog.csdn.net/qq_28513801/category_8592442.html

二 、環境準備

主機名 IP 網卡
opensatck 172.31.132.253 eth0
第二塊網卡 eth1
CentOS 7.5
OpenStack stein
[root@openstack ~]# hostnamectl set-hostname --static openstack

[root@openstack ~]# cat /etc/hosts
127.0.0.1 localhost
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.31.132.253 openstack


關閉防火牆,關閉selinux.

三 、 Install packages

1 、 安裝依賴
[root@openstack ~]#  rm -rfv * /etc/yum.repos.d/*
[root@openstack ~]#  curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@openstack ~]#  yum install epel-release
[root@openstack ~]# yum install python-devel libffi-devel gcc openssl-devel libselinux-python -y
2 、 安裝 pip,ansible,docker
[root@openstack ~]# yum install python-pip ansible –y 
[root@openstack ~]# pip install -U pip 

① 安裝 docker-ce

step 1: 安裝必要的一些系統工具
# step 1: 安裝必要的一些系統工具
[root@openstack ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加軟件源信息
[root@openstack ~]# sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新並安裝Docker-CE
[root@openstack ~]# sudo yum makecache fast
[root@openstack ~]# sudo yum -y install docker-ce
# Step 4: 開啓Docker服務
[root@openstack ~]# systemctl enable docker;systemctl restart docker


3. 配置 docker 鏡像加速

[root@openstack ~]# mkdir -p /etc/docker
[root@openstack ~]# tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
[root@openstack ~]# systemctl daemon-reload
[root@openstack ~]# systemctl restart docker

4. 安裝 kolla-ansible(version==8.0.0)
pip install kolla-ansible==8.0.0 #這裏版本嚴格使用8.0.0,否則會報異常錯誤

可以適當添加源 
https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

例如:
pip install kolla-ansible==8.0.0  -i  https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/


如果安裝過程出現報錯,可以先忽略該模塊,如果需要就在安裝。

例如:

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


則可以先忽略:
pip install kolla-ansible --ignore-installed PyYAML  -i  https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

需要就在安裝:
 
 pip  install XXXX==8.0.0



5. copy文件

[root@openstack ~]# mkdir -p /etc/kolla
[root@openstack ~]# chown $USER:$USER /etc/kolla
[root@openstack ~]# cp -r /usr/share/kolla-ansible/etc_examples/kolla/* /etc/kolla/    ##Copy globals.yml and passwords.yml
[root@openstack ~]# cp /usr/share/kolla-ansible/ansible/inventory/* .    ##Copy all-in-one and multinode inventory files

四 、 Prepare initial configuration

1. Configure Ansible /etc/ansible/ansible.cfg
[defaults]
host_key_checking=False
pipelining=True
forks=100
2. 配置主機清單文件,根據部署場景,這裏選擇 all-in-one 文件

[root@openstack ~]# vi all-in-one
 # These initial groups are the only groups required to be modified. The
# additional groups are for more control of the environment.
[control]
localhost       ansible_connection=local

[network]
localhost       ansible_connection=local

[compute]
localhost       ansible_connection=local

[storage]
localhost       ansible_connection=local

[monitoring]
localhost       ansible_connection=local

[deployment]
localhost       ansible_connection=local

………………
下面不需要動




3 . 配置 ssh 無密鑰登錄,授權節點

[root@openstack ~]# ssh-keygen
[root@openstack ~]# ssh-copy-id  root@openstack
檢查主機連接
[root@openstack ~]# ansible -i all-in-one all -m ping
localhost | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}
4. 對 /etc/kolla/passwords.yml 文件生成隨機密碼,或者修改爲自定義密碼

[root@openstack ~]#  kolla-genpwd

[root@openstack ~]#vim /etc/kolla/passwords.yml
keystone_admin_password: 1111111

5. 配置 /etc/kolla/globals.yml 文件

kolla_base_distro: "centos"
kolla_install_type: "source"
openstack_release: "stein"
kolla_internal_vip_address: "172.31.132.247"
network_interface: "eth0"
neutron_external_interface: "eth1"
nova_compute_virt_type: "qemu"
keepalived_virtual_router_id: "7"

五 、 Deployment

[root@openstack ~]# kolla-ansible bootstrap-servers    ##Bootstrap servers依賴
[root@openstack ~]# kolla-ansible prechecks    ##檢查配置
[root@openstack ~]# kolla-ansible pull    ##pull鏡像
[root@openstack ~]# kolla-ansible deploy  ##部署

如果部署出錯:
[root@openstack ~]# kolla-ansible  destroy  ./all-in-one     --yes-i-really-really-mean-it

六 、 Using OpenStack

1.安裝CLI客戶端
pip install python-openstackclient
2.生成環境腳本
kolla-ansible post-deploy . /etc/kolla/admin-openrc.sh

在這裏插入圖片描述

發佈了158 篇原創文章 · 獲贊 293 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章