基于kolla部署openstack

基于kolla部署openstack

部署环境

使用多节点部署,一个控制节点,两个计算节点。基于CentOS8,采用docker-19.03.14、ansible-2.9.0以及python-3.6.8

部署文档

Multinode Deployment of Kolla

部署流程

按照文档将所有的依赖以及kolla-ansible安装好,一定要注意kolla-ansible版本不能高于2.10,不然会出错。

我的部署情况时一个控制节点,两个计算节点。

  • 在控制节点上创建公钥,并将公钥传至计算节点的.ssh文件下,并写入authorized_keys中。以实现控制节点无密码ssh至计算节点。同时在ssh的目的机器上的/etc/sudoers文件中加入ALL ALL=(ALL) NOPASSWD:ALL,解决出现的Missing sudo password问题。

  • 在经过上述设置之后,在multinode的配置中,compute节点只需要填上计算节点的地址,不用在添加ansible_user等,我的multinnode配置如下:

    [control]
    # These hostname must be resolvable from your deployment host
    #control node ip
    xxx.xxx.xxx.xxx
    
    # The above can also be specified as follows:
    #control[01:03]     ansible_user=kolla
    
    # The network nodes are where your l3-agent and loadbalancers will run
    # This can be the same as a host in the control group
    [network:children]
    control
    
    [compute]
    #compute node ip
    xxx.xxx.xxx.xxx
    
    [monitoring]
    #control node ip
    xxx.xxx.xxx.xxx
    
    # When compute nodes and control nodes use different interfaces,
    # you need to comment out "api_interface" and other interfaces from the globals.yml
    # and specify like below:
    #compute01 neutron_external_interface=eth0 api_interface=em1 storage_interface=em1 tunnel_interface=em1
    
    [storage:children]
    compute
    
    [deployment]
    localhost       ansible_connection=local become=true
    
    
  • /etc/kolla/globals.yml中的配置

    1. kolla_base_distro:"centos"
    2. kolla_install_type:"source"
    3. network_interface设置成对外的网卡
    4. neutron_external_interface设置为对内的网卡
    5. kolla_internal_vip_address必须是为使用的地址
    6. openstack_release设置为对应的版本号,在接下来才能pull到对应的镜像,否则默认pull到最新的镜像
  • 使用all-in-one将需要的镜像pull到控制节点上:依次执行kolla-ansible bootstrap -i all-in-onekolla-ansible pull -i all-in-one,这一步会非常久,所以推荐先在/etc/docker/daemon.json中添加上国内的镜像源地址("registry-mirrors":["xxxx"])。并执行systemctl daemon-reloadsystemctl restart docker

  • 按照文档的 multinode deployment of kolla 中建立本地仓库,一定要注意地址ip要写正确,尤其是docker_registroes: xxx.xxx.xxx.xxx:40000,因为在/usr/local/share/kolla/tools/start-registry中将端口4000映射到了5000,若按照完当那样添加会出错。

  • 将控制节点的镜像push到本地仓库中,我是用的脚本如下:参考博客

    #!/usr/bin/env bash
    
    registry_ip='xxx.xxx.xxx.xxx'
    registry_port='4000'
    openstack_version_tag='ussuri'
    
    images=$(docker images | grep -v registry | grep -v REPOSITORY | grep -v $registry_ip | awk '{print $1}')
    
    for image in $images;
    do
        docker image tag $image:$openstack_version_tag $registry_ip:$registry_port/$image:$openstack_version_tag
    done
    
    images=$(docker images | grep $registry_ip | awk '{print $1}')
    
    for image in $images;
    do
        docker push $image:$openstack_version_tag
        #docker rmi -f $image:$openstack_version_tag
    done
    
  • 接下来在执行kolla-ansible bootstrap-servers -i multinodekolla-ansible deploy -i multinode即可。

问题记录

  • 在 bootstrap-servers 的过程中,控制节点ssh到计算节点出现 Permission denied

    解决:通过创建公钥授权,实现无密码ssh可以解决此问题。

  • 在解决上述问题后,会出现一个Missing sudo password 问题:

    解决:在ssh目的机器的/etc/sudoers文件中加上如下语句ALL ALL=(ALL) NOPASSWD: ALL

  • resecure registry出现connection refused问题

    1. 因为常规情况下keystone和registry都会使用端口5000,所以在配置registry时需要将端口4000映射到端口5000,避免出现“Timeout when waiting for xxx:5000 to stop.”问题。
    2. 把daemon.json中的insecure registry改为xxx:4000。
  • 在创建本地仓库的基础上,在kolla-ansible pull时出现镜像找不到的情况

    1. 因为此时本地仓库上没有所需的镜像,我们需要先从把所需的镜像pull下来,并push到本地仓库上。
    2. 使用all-in-one将镜像pull下来。注意,记得修改global里的openstack版本,最好配置一下daemon中的镜像地址,改为国内的地址。
    3. 将所有镜像打上tag并push至本地仓库中。
原文地址:https://www.cnblogs.com/joe-w/p/14275619.html