source /etc/kolla/admin-openrc.sh unset OS_CACERT OS_ENV=${HOSTNAME##*-} KOLLA_CONF=/etc/kolla/globals.yml IMGDIR=/tmp echo "Download Amphora image" [ -f ${IMGDIR}/amphora-x64-haproxy.raw ] || wget https://s3.example.ch/images/amphora-x64-haproxy.raw.bz2 -qO- \ | bzip2 -d > ${IMGDIR}/amphora-x64-haproxy.raw echo "Deploy Amphora image for Octavia" openstack image create Amphora \ --file ${IMGDIR}/amphora-x64-haproxy.raw \ --disk-format raw \ --min-disk 0 \ --min-ram 0 \ --private \ --protected \ --tag amphora \ --property os_distro=Ubuntu \ --property os_admin_user=ubuntu \ --property os_version="18.04" #echo "Remove Amphora image" #${IMGDIR}/amphora-x64-haproxy.raw echo "Creating Octavia LB mgmt network" OCTAVIA_AMP_BOOT_NETWORK_LIST=$( openstack network create lb-mgmt-net \ -f value -c id ) echo "Creating Octavia LB mgmt subnet" octavia_subnet=$( openstack subnet create lb-mgmt-subnet1 \ --network lb-mgmt-net \ --subnet-range 172.16.0.0/12 \ --allocation-pool start=172.16.100.1,end=172.31.200.200 \ -f value -c id ) echo "Creating Flavors for Octavia" OCTAVIA_AMP_FLAVOR_ID=$( openstack flavor create octavia \ --disk 10 \ --private \ --ram 2048 \ --vcpus 2 \ --property aggregate_instance_extra_specs:std-com-1='true' \ -f value -c id ) echo "Create Octavia security group" OCTAVIA_AMP_SECGROUP_LIST=$( openstack security group create octavia \ -f value -c id ) echo "Create Octavia security rules" openstack security group rule create --protocol icmp $OCTAVIA_AMP_SECGROUP_LIST openstack security group rule create --protocol tcp --dst-port 5555 --egress $OCTAVIA_AMP_SECGROUP_LIST openstack security group rule create --protocol tcp --dst-port 9443 --ingress $OCTAVIA_AMP_SECGROUP_LIST echo "Assigning roles for cloud-admin 'admin'" openstack role add admin \ --user admin \ --domain Default echo "Add Octavia SSH key" # todo: openstack keypair create CLI dont allow to upload key for specific user # openstack keypair create --pub-key=/etc/kolla/config/foo/octavia/octavia_key.pub --user $(openstack user show octavia --domain Default -f value -c id) octavia_ssh_key nova keypair-add octavia_ssh_key \ --pub-key=/etc/kolla/config/foo/octavia/octavia_key.pub \ --user $(openstack user show octavia --domain Default -f value -c id) echo "Octavia IDs to be added to inventory" sed -i "s|^octavia_amp_boot_network_list: .*|octavia_amp_boot_network_list: ${OCTAVIA_AMP_BOOT_NETWORK_LIST}|g" ${KOLLA_CONF} sed -i "s|^octavia_amp_secgroup_list: .*|octavia_amp_secgroup_list: ${OCTAVIA_AMP_SECGROUP_LIST}|g" ${KOLLA_CONF} sed -i "s|^octavia_amp_flavor_id: .*|octavia_amp_flavor_id: ${OCTAVIA_AMP_FLAVOR_ID}|g" ${KOLLA_CONF} (cd /etc/kolla && kolla-ansible -i inventory reconfigure -t octavia) for CTL_HOST_NAME in $(openstack network agent list --agent-type l3 -c Host -f value); do OS_AZ=$(echo ${CTL_HOST_NAME} | cut -d"-" -f1 | sed 's/[^0-9]*//g') CTL_NO=$(echo ${CTL_HOST_NAME} | cut -d"-" -f2 | sed 's/[^0-9]*//g') CTL_HOST_MAC=$(echo 00:1b:1b:00:00:${OS_AZ}${CTL_NO}) CTL_HOST_IP=172.16.0.${OS_AZ}${CTL_NO} # Create Octavia port in OpenStack CTL_HOST_PORT_ID=$( openstack port create octavia-health-manager-${CTL_HOST_NAME}-listen-port \ --security-group octavia \ --device-owner Octavia:health-mgr \ --host=${CTL_HOST_NAME} \ --network lb-mgmt-net \ --fixed-ip subnet=$(openstack subnet show lb-mgmt-subnet1 -f value -c id),ip-address=${CTL_HOST_IP} \ --mac-address=${CTL_HOST_MAC} \ -c id -f value ) # Create interface on compute nodes ssh ${CTL_HOST_NAME} docker exec openvswitch_vswitchd ovs-vsctl -- --may-exist add-port br-int o-hm0 -- \ set Interface o-hm0 type=internal -- \ set Interface o-hm0 mac=\\\"${CTL_HOST_MAC}\\\" -- \ set Interface o-hm0 external-ids:iface-status=active -- \ set Interface o-hm0 external-ids:iface-id=${CTL_HOST_PORT_ID} -- \ set Interface o-hm0 external-ids:skip_cleanup=true -- \ set Interface o-hm0 external-ids:attached-mac=${CTL_HOST_MAC} # workaround if [ "${OS_ENV}" == "dev" ]; then ssh ${CTL_HOST_NAME} docker restart neutron_l3_agent sleep 10 fi done # list Octavia ports openstack port list --project admin --device-owner Octavia:health-mgr