参考:https://docs.openstack.org/kolla-ansible/latest/user/quickstart.html
kolla安装节点要求:
本次部署train版openstack,kolla的安装,要求目标机器是两块网卡,在vmware workstation新增一块网卡:
节点规划
节点及IP规划
节点名称 | IP地址 | 角色 |
---|---|---|
control01 | ens33:192.168.93.61 ens37: |
控制节点 |
control02 | ens33:192.168.93.62 ens37: |
控制节点 |
control03 | ens33:192.168.93.63 ens37: |
控制节点 |
compute01 | ens33:192.168.93.64 ens37: |
计算节点 |
storage01 | ens33:192.168.93.65 | 存储节点 |
ens37网卡配置参考:https://docs.openstack.org/install-guide/environment-networking-controller.html
#获取ens37网卡uuid
nmcli connection show
#创建ifcfg-ens37配置文件,注意替换uuid
cat > /etc/sysconfig/network-scripts/ifcfg-ens37 <<EOF
NAME=ens37
UUID=f851545a-f25b-3298-92f5-86a6107d85a8
DEVICE=ens37
TYPE=Ethernet
ONBOOT="yes"
BOOTPROTO="none"
EOF
#重新加载en37网卡设备
nmcli con reload && nmcli con up ens37
如果启用cinder还需要在storage01节点额外添加一块磁盘,这里以/dev/sdb为例,在storage01节点执行
pvcreate /dev/sdb
vgcreate cinder-volumes /dev/sdb
注意卷组名称为cinder-volumes,默认与globals.yml一致。
[root@kolla ~]# cat /etc/kolla/globals.yml | grep cinder_volume_group
#cinder_volume_group: "cinder-volumes"
无特殊说明,以下所有操作在kolla ansible部署节点执行,即control01节点。
安装依赖
yum install -y python-devel libffi-devel gcc openssl-devel libselinux-python
安装 Ansible
yum install -y ansible
配置阿里云pip源
mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/
EOF
安装 kolla-ansible
kolla版本与openstack版本对应关系:https://releases.openstack.org/teams/kolla.html
yum install -y epel-release
yum install -y python-pip
pip install -U pip
pip install kolla-ansible==9.1.0 --ignore-installed PyYAML
复制 kolla-ansible配置
mkdir -p /etc/kolla
chown $USER:$USER /etc/kolla
##Copy globals.yml and passwords.yml
cp -r /usr/share/kolla-ansible/etc_examples/kolla/* /etc/kolla
##Copy all-in-one and multinode inventory files
cp /usr/share/kolla-ansible/ansible/inventory/* .
修改ansible配置文件
$ vim /etc/ansible/ansible.cfg
[defaults]
host_key_checking=False
pipelining=True
forks=100
修改multinode inventory文件,其他默认即可
$ cat multinode
[control]
# These hostname must be resolvable from your deployment host
control01
control02
control03
[network]
control01
control02
control03
[compute]
compute01
[monitoring]
control01
[storage]
storage01
...
配置ssh免密
ssh-keygen
ssh-copy-id 192.168.93.61
ssh-copy-id 192.168.93.62
ssh-copy-id 192.168.93.63
ssh-copy-id 192.168.93.64
ssh-copy-id 192.168.93.65
配置主机名(所有节点)
hostnamectl set-hostname control01
hostnamectl set-hostname control02
hostnamectl set-hostname control03
hostnamectl set-hostname compute01
hostnamectl set-hostname storage01
配置主机名解析(预配置时kolla会配置主机名解析,这里只在部署节点操作)
cat > /etc/hosts <<EOF
192.168.93.61 control01
192.168.93.62 control02
192.168.93.63 control03
192.168.93.64 compute01
192.168.93.65 storage01
EOF
检查inventory配置是否正确,执行:
ansible -i multinode all -m ping
生成kolla密码
kolla-genpwd
修改keystone_admin_password可以修改为自定义,在登录dashboard会用到
sed -i 's#keystone_admin_password:.*#keystone_admin_password: kolla#g' /etc/kolla/passwords.yml
$ cat /etc/kolla/passwords.yml | grep keystone_admin_password
keystone_admin_password: kolla
修改全局配置文件globals.yml
cp /etc/kolla/globals.yml{,.bak}
cat >> /etc/kolla/globals.yml <<EOF
#version
kolla_base_distro: "centos"
kolla_install_type: "binary"
openstack_release: "train"
#vip
kolla_internal_vip_address: "192.168.93.200"
#docker registry
docker_registry: "registry.cn-shenzhen.aliyuncs.com"
docker_namespace: "kollaimage"
#network
network_interface: "ens33"
neutron_external_interface: "ens37"
neutron_plugin_agent: "openvswitch"
enable_neutron_provider_networks: "yes"
#storage
enable_cinder: "yes"
enable_cinder_backend_lvm: "yes"
EOF
参数说明:
修改docker官方yum源为阿里云yum源,另外配置docker镜像加速,指定使用阿里云镜像加速。
$ vim /usr/share/kolla-ansible/ansible/roles/baremetal/defaults/main.yaml
docker_yum_url: "https://mirrors.aliyun.com/docker-ce/linux/{{ ansible_distribution | lower }}"
docker_custom_config: {"registry-mirrors": ["https://uyah70su.mirror.aliyuncs.com"]}
在运行bootstrap-servers时会执行easy_install pip命令安装pip,如果网络较慢可能任务一直卡在这里,可以提前在所有节点手动安装pip(可选)。
mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/
EOF
yum install -y epel-release
yum install -y python-pip
pip install -U pip
开始部署openstack
kolla-ansible -i ./multinode bootstrap-servers
#部署检查
kolla-ansible -i ./multinode prechecks
#拉取镜像
kolla-ansible -i ./multinode pull
#执行部署
kolla-ansible -i ./multinode deploy
生成openrc文件,该文件中设置了管理员用户的凭据
kolla-ansible post-deploy
cat /etc/kolla/admin-openrc.sh
使用docker作为openstack客户端
docker pull registry.cn-shenzhen.aliyuncs.com/kollaimage/centos-binary-openstack-base:train
kolla ansible部署节点启动一个临时容器:
docker run -d --name client \
--restart always \
-v /etc/kolla/admin-openrc.sh:/admin-openrc.sh:ro \
-v /usr/share/kolla-ansible/init-runonce:/init-runonce:rw \
registry.cn-shenzhen.aliyuncs.com/kollaimage/centos-binary-openstack-base:train sleep infinity
进入容器即可执行openstack命令
[root@control01 ~]# docker exec -it client bash
()[root@7863d16d6839 /]# source /admin-openrc.sh
()[root@7863d16d6839 /]# openstack service list
+----------------------------------+-------------+----------------+
| ID | Name | Type |
+----------------------------------+-------------+----------------+
| 2ab6a571b71444adb69f10d18a876c55 | keystone | identity |
| 4b0ea157a8dc4ef5adc720dda56902ce | cinderv2 | volumev2 |
| 57b38f38444949f98e6f3ed46b5a24e6 | cinderv3 | volumev3 |
| 84431d0e3727426f82faf4a9bb898045 | heat | orchestration |
| 8a8675bc425a45ac9e83140b18a8c864 | nova_legacy | compute_legacy |
| b54c859fa8214ca68bb5002e5e58ade2 | glance | image |
| b9adda688c024c56aace1902340cadf7 | heat-cfn | cloudformation |
| c301474681f74271a39b74d29899d7ee | nova | compute |
| c3fb659dea224e3ab8655f77976cc98f | placement | placement |
| edfa32d4099a435397497b19b055fd10 | neutron | network |
+----------------------------------+-------------+----------------+
kolla提供了一个快速创建demo实例的脚本,修改init-runonce示例脚本外部网络配置。
()[root@7863d16d6839 /]# vi init-runonce
# This EXT_NET_CIDR is your public network,that you want to connect to the internet via.
ENABLE_EXT_NET=${ENABLE_EXT_NET:-1}
EXT_NET_CIDR=${EXT_NET_CIDR:-'192.168.1.0/24'}
EXT_NET_RANGE=${EXT_NET_RANGE:-'start=192.168.1.200,end=192.168.1.250'}
EXT_NET_GATEWAY=${EXT_NET_GATEWAY:-'192.168.1.1'}
()[root@7863d16d6839 /]# bash init-runonce
参数说明:
该脚本首先会从github下载cirros镜像,如果网络较慢可以提前下载到cache目录
docker exec -it client mkdir -p /opt/cache/files/
wget https://github.com/cirros-dev/cirros/releases/download/0.4.0/cirros-0.4.0-x86_64-disk.img
docker cp cirros-0.4.0-x86_64-disk.img client:/opt/cache/files/
脚本执行完后根据提示运行一个cirros实例
openstack server create \
--image cirros \
--flavor m1.tiny \
--key-name mykey \
--network demo-net \
demo1
在3个control节点查找vip地址
[root@control03 ~]# ip a | grep ens33
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.93.63/24 brd 192.168.93.255 scope global noprefixroute ens33
inet 192.168.93.200/32 scope global ens33
浏览器访问:http://192.168.93.200,用户名密码在admin-openrc.sh中可以找到,这里默认是admin/kolla
cat /admin-openrc.sh
为实例分配浮动IP
连接到实例,验证访问外网,cirros镜像默认账号密码为cirros/gocubsgo
[root@control01 ~]# ssh [email protected]
[email protected]'s password:
$
$
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc pfifo_fast qlen 1000
link/ether fa:16:3e:e4:16:00 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.74/24 brd 10.0.0.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fee4:1600/64 scope link
valid_lft forever preferred_lft forever
$
$ ping -c 4 www.openstack.org
PING www.openstack.org (104.20.110.33): 56 data bytes
64 bytes from 104.20.110.33: seq=1 ttl=53 time=178.064 ms
64 bytes from 104.20.110.33: seq=2 ttl=53 time=177.797 ms
64 bytes from 104.20.110.33: seq=3 ttl=53 time=178.392 ms
--- www.openstack.org ping statistics ---
4 packets transmitted, 3 packets received, 25% packet loss
round-trip min/avg/max = 177.797/178.084/178.392 ms
各个组件配置文件目录: /etc/kolla/
各个组件日志文件目录:/var/log/kolla/
kolla-ansible destroy --include-images --yes-i-really-really-mean-it
vgremove cinder-volume