1、创建虚拟机 Kolla01
CPU 8
内存 16G
磁盘 300G
网卡 2(桥架+host_only,网络需开启混杂模式)
开启硬件虚拟化(echo 'vhv.enable = "TRUE"' >> /vmfs/volumes/datastore-104-15k/Kolla01/Kolla01.vmx)
2、安装操作系统 CentOS7.5 (CentOS-7-x86_64-Everything-1804.iso)
时区 亚洲/上海
分区 从 /home 划 200G 给 /
密码 123456
3、虚拟机基础配置
------第一网卡------
IP地址 10.12.30.41
掩码 255.255.252.0
网关 10.12.28.6
DNS 114.114.114.114
------第二网卡------
开机启动,不配置IP
# 静态路由
echo 'any net 172.22.0.0 netmask 255.255.0.0 gw 10.12.28.1' > /etc/sysconfig/static-routes
# 设置主机名
echo openstack >> /etc/hostname
# 配置hosts
echo 10.12.30.41 openstack >> /etc/hosts
# 关闭firewalld防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
# 关闭SELinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux
# SSH优化
echo 'UseDNS no' >> /etc/ssh/sshd_config
systemctl restart sshd.service
echo 'StrictHostKeyChecking no' >> /etc/ssh/ssh_config
# 配置国内YUM源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install -y epel-release
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum makecache
# 安装常用软件:
yum install -y vim wget net-tools bash-completion jq git sysstat
# 配置豆瓣pip源
mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host = pypi.douban.com
EOF
4、Kolla准备环境
# 安装kolla依赖的程序包
yum install -y docker docker-registry python-devel python-pip libffi-devel gcc openssl-devel libselinux-python git net-tools ansible
# 升级 pip
pip install -U pip
# 安装 kolla-ansible
pip install kolla-ansible --ignore-installed PyYAML
# 安装 openstack 客户端命令
pip install python-openstackclient
# 解决执行 openstack 命令报错的问题
pip install -U decorator
# 执行 openstack 命令验证安装 openstackclient 成功
openstack server list
# 配置docker加速器,并设置docker开启自启动
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://06nnx1in.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
systemctl enable docker
# 避免kolla调用docker报错,需要进行以下配置
mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/kolla.conf << EOF
[Service]
MountFlags=shared
EOF
systemctl daemon-reload
systemctl restart docker
# 下载docker registry v2
docker pull registry:2
# 运行 docker registry ,http://10.12.30.41:4000/v2/_catalog
docker run -d --name registry --restart always -p 4000:5000 docker.io/registry:2
# 配置kolla配置文件
mkdir -p /etc/kolla
cp -r /usr/share/kolla-ansible/etc_examples/kolla/* /etc/kolla/
# 修改配置文件 globals.yml
###############
# Kolla options
###############
# Valid options are [ COPY_ONCE, COPY_ALWAYS ]
#config_strategy: "COPY_ALWAYS"
# Valid options are ['centos', 'debian', 'oraclelinux', 'rhel', 'ubuntu'] # 部署在什么操作系统上
#kolla_base_distro: "centos"
# Valid options are [ binary, source ] # 部署类型,这里是使用源部署
#kolla_install_type: "source"
# Valid option is Docker repository tag # 部署kolla版本
#openstack_release: "rocky"
# Location of configuration overrides
#node_custom_config: "/etc/kolla/config"
# This should be a VIP, an unused IP on your network that will float between
# the hosts running keepalived for high-availability. If you want to run an
# All-In-One without haproxy and keepalived, you can set enable_haproxy to no
# in "OpenStack options" section, and set this value to the IP of your
# 'network_interface' as set in the Networking section below. # VIP,与管理地址同网段
#kolla_internal_vip_address: "10.12.30.49"
##############################
# Neutron - Networking Options
##############################
# This interface is what all your api services will be bound to by default.
# Additionally, all vxlan/tunnel and storage network traffic will go over this
# interface by default. This interface must contain an IPv4 address.
# It is possible for hosts to have non-matching names of interfaces - these can
# be set in an inventory file per host or per group or stored separately, see
# http://docs.ansible.com/ansible/intro_inventory.html
# Yet another way to workaround the naming problem is to create a bond for the
# interface on all hosts and give the bond name here. Similar strategy can be
# followed for other types of interfaces. # 管理用网卡
#network_interface: "ens160"
# These can be adjusted for even more customization. The default is the same as
# the 'network_interface'. These interfaces must contain an IPv4 address.
#kolla_external_vip_interface: "{{ network_interface }}"
#api_interface: "{{ network_interface }}"
#storage_interface: "{{ network_interface }}"
#cluster_interface: "{{ network_interface }}"
#tunnel_interface: "{{ network_interface }}"
#dns_interface: "{{ network_interface }}"
# This is the raw interface given to neutron as its external network port. Even
# though an IP address can exist on this interface, it will be unusable in most
# configurations. It is recommended this interface not be configured with any IP
# addresses for that reason. # 虚机流量用网卡
#neutron_external_interface: "ens192"
# 自动生成openstack密码,并写入密码本 passwords.yml,默认改密码本中的密码为空
kolla-genpwd
# 手动修改密码本中web页面登录密码为admin,用户名也是admin
#keystone_admin_password: admin
# git clone kolla代码,并安装pip依赖包
git clone http://git.trystack.cn/openstack/kolla --branch stable/rocky
pip install -r kolla/requirements.txt
git clone http://git.trystack.cn/openstack/kolla-ansible --branch stable/rocky
pip install -r kolla-ansible/requirements.txt
# 配置ansible
[defaults]
forks = 100
# uncomment this to disable SSH key host checking
host_key_checking = False
[ssh_connection]
# Enabling pipelining reduces the number of SSH operations required to
# execute a module on the remote server. This can result in a significant
# performance improvement when enabled, however when using "sudo:" you must
# first disable 'requiretty' in /etc/sudoers
#
# By default, this option is disabled to preserve compatibility with
# sudoers configurations that have requiretty (the default on many distros).
#
pipelining = True
# 虚拟机的实验环境需要配置虚拟化类型为 qemu,这样能支持虚拟化嵌套。默认为虚拟化类型为kvm,物理机不用配置此项
mkdir -p /etc/kolla/config/nova
cat > /etc/kolla/config/nova/nova-compute.conf << EOF
[libvirt]
virt_type = qemu
cpu_mode = none
EOF
# 检查kolla环境是否ok
kolla-ansible prechecks
# 下载kolla镜像
kolla-ansible pull
# 修改镜像tag
for i in `docker images | grep 'kolla' | awk '{print $1}'` ; do docker tag $i":rocky" $(echo $i | awk -F '/' '{print "10.12.30.41:4000/kolla/"$3}')":rocky" ; done
# 修改docker daemon 服务,让docker默认使用http访问镜像仓库, 因为本地搭建的镜像仓库是http,新版本docker认为不安全
[root@openstack ~]# cat /etc/docker/daemon.json
{
"insecure-registries":["10.12.30.41:4000"],
"registry-mirrors": ["https://06nnx1in.mirror.aliyuncs.com"]
}
systemctl daemon-reload
systemctl restart docker.service
# 执行docker push 将镜像上传到私有镜像中,多执行一次确保都push成功
for i in `docker images | grep '10.12.30.41' | awk '{print $1":"$2}' ` ; do docker push $i ; done
# 修改kolla配置文件/etc/kolla/globals.yml,使用本地镜像仓库
docker_registry: "10.12.30.41:4000"
docker_namespace: "kolla"
# 开始部署kolla
kolla-ansible deploy
卡在这里了
[root@openstack ~]# kolla-ansible deploy
[root@openstack ~]# kolla-ansible post-deploy
[root@openstack ~]# source /etc/kolla/admin-openrc.sh
[root@openstack ~]# openstack server list