环境准备
Kolla-Ansible 只支持列表 Supported Operating Systems 中的操作系统,这里选用 Ubuntu 20.04 。
主机配置
- CPU:4 Cores
 
- 内存:16 GB
 
- 硬盘:512 GB
 
- 网卡:
 
更换 pip 源(可选)
在用户根目录创建文件夹 .pip ,添加配置文件 pip.conf
1 2 3 4 5
   |  cd && mkdir .pip && cd .pip
 
  sudo vim pip.conf
 
  | 
 
pip 源配置如下
1 2 3 4
   | [global] timeout = 6000 index-url = http://mirrors.aliyun.com/pypi/simple/ trusted-host = mirrors.aliyun.com
   | 
 
更换 Ubuntu 源(可选)
备份源文件,再替换成清华的镜像源
1 2 3 4 5 6 7 8 9 10 11 12 13 14
   |  sudo mv /etc/apt/sources.list /etc/apt/sources.list.bk
 
  sudo vim /etc/apt/sources.list
 
  sudo apt update
 
  sudo apt dist-upgrade -y
 
  sudo reboot
 
  | 
 
镜像源设置如下
1 2 3 4 5 6 7 8 9
   | # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
   | 
 
安装依赖
1 2 3 4 5
   |  sudo apt update
 
  sudo apt install python3-dev libffi-dev gcc libssl-dev -y
 
  | 
 
安装 venv,创建并使用虚拟环境
1 2 3 4 5 6 7 8 9 10 11 12 13
   |  sudo apt install python3-venv -y
 
  mkdir code python -m venv /home/jck/code
 
  source /home/jck/code/bin/activate
 
  pip install -U pip pip install 'ansible<3.0'
 
  | 
 
部署 OpenStack
安装 Kolla-Ansible
使用 git 克隆仓库,-b 参数指定版本
1 2
   | git clone https://github.com/openstack/kolla -b stable/victoria git clone https://github.com/openstack/kolla-ansible -b stable/victoria
   | 
 
在虚拟环境中安装依赖
1 2 3 4 5 6 7 8 9 10 11 12 13
   |  pip install ./kolla pip install ./kolla-ansible
 
  sudo mkdir -p /etc/kolla
 
  sudo chown $USER:$USER /etc/kolla
 
  cp -r kolla-ansible/etc/kolla/* /etc/kolla cp kolla-ansible/ansible/inventory/* .
 
  | 
 
配置 Ansible
创建并编辑 Ansible 配置文件 ansible.cfg
1 2 3 4 5
   |  sudo touch /etc/ansible/ansible.cfg
 
  sudo vim /etc/ansible/ansible.cfg
 
  | 
 
添加以下配置:
1 2 3 4
   | [defaults] host_key_checking=False pipelining=True forks=100
   | 
 
准备初始配置
Inventory
两个示例文件:all-in-one 和 multinode,单机部署不需要做额外的修改。
Kolla 密码
部署过程中使用的密码存储在 /etc/kolla/passwords.yml 文件,初始为空白,需要手动设置或随机生成。
1 2
   | cd kolla-ansible/tools ./generate_passwords.py
   | 
 
Kolla globals.yml
globals.yml 是 Kolla-Ansible 的主要配置文件,以下选项需要进行配置:
- Image options:指定用于部署的镜像,支持 
centos、ubuntu、debian、rhel
- type:只影响 OpenStack 服务
binary:使用存储仓库,例如 apt 或 dnf;基础设施服务通常使用这个选项 
source:使用原始源存档,例如 git 仓库或本地源目录;比 binary 稍微可靠些 
 
 
- Networking:网络配置
network_interface:管理网络 
external_interface:Neutron 外部网络,没有 ip 的网卡 
internal_vip_address:浮动 IP 范围,与管理网络同网段 
 
- Enable additional services:安装额外的服务组件
 
- Multiple globals files:使用额外的配置文件启用服务,在 
etc/kolla/globals.d 目录下创建 
- Virtual environment:建议在远程主机上使用虚拟环境执行
 
编辑配置文件
1
   | sudo vim /etc/kolla/globals.yml
   | 
 
配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
   |  kolla_base_distro: "ubuntu"
 
  kolla_install_type: "source"
 
  kolla_internal_vip_address: "10.1.0.250" 
  network_interface: "ens192"
  neutron_external_interface: "ens160" 
 
 
 
 
 
  nova_compute_virt_type: "qemu"
 
  | 
 
因为不支持虚拟化,所以配置为 qemu ,需要额外安装 libvirt(应该不用装)
1 2 3
   |  sudo apt update sudo apt install qemu-kvm libvirt-daemon-system -y
 
  | 
 
部署
配置文件准备完毕后即可进行部署,首先进行基础的主机级依赖设置,Kolla-Ansible 提供了一个安装所有必需服务的 playbook
1 2 3 4 5 6 7 8
   |  kolla-ansible -i all-in-one bootstrap-servers
 
  kolla-ansible -i all-in-one prechecks
 
  kolla-ansible -i all-in-one deploy
 
  | 
 
使用 OpenStack
1 2
   |  pip install python-openstackclient
 
  | 
 
OpenStack 需要 openrc 文件,其中设置了 admin 用户的凭据
1 2 3
   |  kolla-ansible post-deploy . /etc/kolla/admin-openrc.sh
 
  | 
 
执行脚本生成示例网络、镜像、实例等
1
   | code/share/kolla-ansible/init-runonce
   | 
 
创建实例
1 2 3 4 5 6 7 8 9 10 11
   | pip install python-openstackclient
 
  openstack server create \     --image cirros \     --flavor m1.tiny \     --network demo-net \     demo1
 
  openstack server list
   | 
 
访问 ip 地址可进入 horizon 登录界面
- 用户名:
admin 
- 密码:查看 
/etc/kolla/passwords.yml 
参阅