shorif2000

Untitled

Dec 13th, 2022
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.73 KB | None | 0 0
  1. # Install python pip
  2. sudo apt install python-pip
  3. # Eventually create a virtualenv
  4. sudo apt install python3-virtualenv
  5. virtualenv octavia_disk_image_create
  6. source octavia_disk_image_create/bin/activate
  7. # Install octavia requirements
  8. git clone https://opendev.org/openstack/octavia.git
  9. cd octavia/diskimage-create/
  10. pip install -r requirements.txt
  11.  
  12. sudo apt install qemu-utils git kpartx debootstrap
  13. sudo chmod 0644 /boot/vmlinuz*
  14.  
  15. bash diskimage-create.sh -g stable/train
  16. Successfully built the amphora using the stable/train amphora-agent.
  17. Amphora image size: /home/sytel/octavia/diskimage-create/amphora-x64-haproxy.qcow2 395847168
  18.  
  19.  
  20. openstack image create --disk-format qcow2 \
  21. --container-format bare --tag octavia-amphora-image --file /home/sytel/octavia/diskimage-create/amphora-x64-haproxy.qcow2 \
  22. --public --project admin amphora-x64-haproxy
  23.  
  24.  
  25. # create db
  26. mysql -u root -p
  27. CREATE DATABASE octavia;
  28. CREATE USER 'octavia'@'localhost' IDENTIFIED BY 'octavia';
  29. GRANT ALL PRIVILEGES ON *.* TO 'octavia'@'localhost' with grant option;
  30. CREATE USER 'octavia'@'%' IDENTIFIED BY 'octavia';
  31. GRANT ALL PRIVILEGES ON *.* TO 'octavia'@'%' with grant option;
  32. \q
  33.  
  34. openstack user create --domain default --password-prompt octavia
  35. > octavia
  36. > octavia
  37.  
  38.  
  39. openstack role add --user octavia --project admin admin
  40. openstack role add --project service --user octavia admin
  41. openstack service create --name octavia --description "OpenStack Octavia" load-balancer
  42.  
  43. openstack endpoint create --region RegionOne \
  44. load-balancer public http://192.168.122.124:9876
  45. openstack endpoint create --region RegionOne \
  46. load-balancer internal http://192.168.122.124:9876
  47. openstack endpoint create --region RegionOne \
  48. load-balancer admin http://192.168.122.124:9876
  49.  
  50. cat << EOF >> $HOME/octavia-openrc
  51. export OS_PROJECT_DOMAIN_NAME=Default
  52. export OS_USER_DOMAIN_NAME=Default
  53. export OS_PROJECT_NAME=service
  54. export OS_USERNAME=octavia
  55. export OS_PASSWORD=octavia
  56. export OS_AUTH_URL=http://192.168.122.124:5000
  57. export OS_IDENTITY_API_VERSION=3
  58. export OS_IMAGE_API_VERSION=2
  59. export OS_VOLUME_API_VERSION=3
  60. EOF
  61.  
  62. . $HOME/octavia-openrc
  63.  
  64. ## build image now
  65.  
  66.  
  67. openstack flavor create --id 200 --vcpus 1 --ram 1024 \
  68. --disk 2 "amphora" --private
  69.  
  70. sudo apt install octavia-api octavia-health-manager octavia-housekeeping \
  71. octavia-worker python3-octavia python3-octaviaclient
  72. # If octavia-common and octavia-api packages ask you to configure, choose No.
  73.  
  74.  
  75. git clone https://opendev.org/openstack/octavia.git
  76. cd octavia/bin/
  77. source create_dual_intermediate_CA.sh
  78. sudo mkdir -p /etc/octavia/certs/private
  79. sudo chmod 755 /etc/octavia -R
  80. sudo cp -p etc/octavia/certs/server_ca.cert.pem /etc/octavia/certs
  81. sudo cp -p etc/octavia/certs/server_ca-chain.cert.pem /etc/octavia/certs
  82. sudo cp -p etc/octavia/certs/server_ca.key.pem /etc/octavia/certs/private
  83. sudo cp -p etc/octavia/certs/client_ca.cert.pem /etc/octavia/certs
  84. sudo cp -p etc/octavia/certs/client.cert-and-key.pem /etc/octavia/certs/private
  85.  
  86. cd
  87. . octavia-openrc
  88. openstack security group create lb-mgmt-sec-grp
  89. openstack security group rule create --protocol icmp lb-mgmt-sec-grp
  90. openstack security group rule create --protocol tcp --dst-port 22 lb-mgmt-sec-grp
  91. openstack security group rule create --protocol tcp --dst-port 9443 lb-mgmt-sec-grp
  92. openstack security group create lb-health-mgr-sec-grp
  93. openstack security group rule create --protocol udp --dst-port 5555 lb-health-mgr-sec-grp
  94.  
  95.  
  96. cd $HOME
  97. sudo mkdir -m755 -p /etc/dhcp/octavia
  98. sudo cp octavia/etc/dhcp/dhclient.conf /etc/dhcp/octavia
  99.  
  100. # network setup
  101. OCTAVIA_MGMT_SUBNET=172.16.0.0/12
  102. OCTAVIA_MGMT_SUBNET_START=172.16.0.100
  103. OCTAVIA_MGMT_SUBNET_END=172.16.31.254
  104. OCTAVIA_MGMT_PORT_IP=172.16.0.2
  105.  
  106. openstack network create lb-mgmt-net
  107. openstack subnet create --subnet-range $OCTAVIA_MGMT_SUBNET --allocation-pool \
  108. start=$OCTAVIA_MGMT_SUBNET_START,end=$OCTAVIA_MGMT_SUBNET_END \
  109. --network lb-mgmt-net lb-mgmt-subnet
  110.  
  111. SUBNET_ID=$(openstack subnet show lb-mgmt-subnet -f value -c id)
  112. PORT_FIXED_IP="--fixed-ip subnet=$SUBNET_ID,ip-address=$OCTAVIA_MGMT_PORT_IP"
  113. MGMT_PORT_ID=$(openstack port create --security-group \
  114. lb-health-mgr-sec-grp --device-owner Octavia:health-mgr \
  115. --host=$(hostname) -c id -f value --network lb-mgmt-net \
  116. $PORT_FIXED_IP octavia-health-manager-listen-port)
  117. MGMT_PORT_MAC=$(openstack port show -c mac_address -f value \
  118. $MGMT_PORT_ID)
  119.  
  120. sudo ip link add o-hm0 type veth peer name o-bhm0
  121. NETID=$(openstack network show lb-mgmt-net -c id -f value)
  122. BRNAME=brq$(echo $NETID|cut -c 1-11)
  123. sudo brctl addif $BRNAME o-bhm0
  124. sudo ip link set o-bhm0 up
  125.  
  126. sudo ip link set dev o-hm0 address $MGMT_PORT_MAC
  127. sudo iptables -I INPUT -i o-hm0 -p udp --dport 5555 -j ACCEPT
  128. sudo dhclient -v o-hm0 -cf /etc/dhcp/octavia
  129.  
  130. sudo vi /etc/systemd/network/o-hm0.network
  131.  
  132. [Match]
  133. Name=o-hm0
  134.  
  135. [Network]
  136. DHCP=yes
  137.  
  138.  
  139. sudo vi /etc/systemd/system/octavia-interface.service
  140.  
  141. [Unit]
  142. Description=Octavia Interface Creator
  143. Requires=neutron-linuxbridge-agent.service
  144. After=neutron-linuxbridge-agent.service
  145.  
  146. [Service]
  147. Type=oneshot
  148. RemainAfterExit=true
  149. ExecStart=/opt/octavia-interface.sh start
  150. ExecStop=/opt/octavia-interface.sh stop
  151.  
  152. [Install]
  153. WantedBy=multi-user.target
  154.  
  155.  
  156. # You need to substitute $MGMT_PORT_MAC and $BRNAME for the values in your environment.
  157. sudo vi /opt/octavia-interface.sh
  158. #!/bin/bash
  159.  
  160. set -ex
  161.  
  162. MAC=fa:16:3e:ef:cc:32
  163. BRNAME=brqa90c6329-88
  164.  
  165. if [ "$1" == "start" ]; then
  166. ip link add o-hm0 type veth peer name o-bhm0
  167. brctl addif $BRNAME o-bhm0
  168. ip link set o-bhm0 up
  169. ip link set dev o-hm0 address $MAC
  170. ip link set o-hm0 up
  171. iptables -I INPUT -i o-hm0 -p udp --dport 5555 -j ACCEPT
  172. elif [ "$1" == "stop" ]; then
  173. ip link del o-hm0
  174. else
  175. brctl show $BRNAME
  176. ip a s dev o-hm0
  177. fi
  178.  
Advertisement
Add Comment
Please, Sign In to add comment