Browse Source

Merge "Add bgp peering in virtual airship"

Zuul 3 weeks ago
parent
commit
ad89cc36bf

+ 1
- 0
tools/multi_nodes_gate/airship_gate/lib/all.sh View File

@@ -15,6 +15,7 @@ source "$LIB_DIR"/ssh.sh
15 15
 source "$LIB_DIR"/virsh.sh
16 16
 source "$LIB_DIR"/airship.sh
17 17
 source "$LIB_DIR"/ingress.sh
18
+source "$LIB_DIR"/bgp.sh
18 19
 
19 20
 if [[ -v GATE_DEBUG && ${GATE_DEBUG} = "1" ]]; then
20 21
     set -x

+ 33
- 0
tools/multi_nodes_gate/airship_gate/lib/bgp.sh View File

@@ -0,0 +1,33 @@
1
+QUAGGA_DAEMONS="${TEMP_DIR}/daemons"
2
+QUAGGA_DEBIAN_CONF="${TEMP_DIR}/debian.conf"
3
+QUAGGA_BGPD_CONF="${TEMP_DIR}/bgpd.conf"
4
+
5
+bgp_router_config() {
6
+  quagga_as_number=$(config_bgp_as "quagga_as")
7
+  calico_as_number=$(config_bgp_as "calico_as")
8
+  quagga_ip=$(config_vm_ip "build")
9
+
10
+  QUAGGA_AS=${quagga_as_number} CALICO_AS=${calico_as_number} QUAGGA_IP=${quagga_ip} envsubst '${QUAGGA_AS} ${CALICO_AS} ${QUAGGA_IP}' < "${TEMPLATE_DIR}/bgpd_conf.sub" > "${QUAGGA_BGPD_CONF}"
11
+
12
+  cp "${TEMPLATE_DIR}/daemons.sub" "${QUAGGA_DAEMONS}"
13
+  cp "${TEMPLATE_DIR}/debian_conf.sub" "${QUAGGA_DEBIAN_CONF}"
14
+
15
+}
16
+
17
+bgp_router_start() {
18
+  # nodename where BGP router should run
19
+  nodename=$1
20
+  remote_work_dir="/var/tmp/quagga"
21
+
22
+  remote_daemons_file="${remote_work_dir}/$(basename $QUAGGA_DAEMONS)"
23
+  remote_debian_conf_file="${remote_work_dir}/$(basename $QUAGGA_DEBIAN_CONF)"
24
+  remote_bgpd_conf_file="${remote_work_dir}/$(basename $QUAGGA_BGPD_CONF)"
25
+
26
+  ssh_cmd "${nodename}" mkdir -p "${remote_work_dir}"
27
+
28
+  rsync_cmd "$QUAGGA_DAEMONS" "${nodename}:${remote_daemons_file}"
29
+  rsync_cmd "$QUAGGA_DEBIAN_CONF" "${nodename}:${remote_debian_conf_file}"
30
+  rsync_cmd "$QUAGGA_BGPD_CONF" "${nodename}:${remote_bgpd_conf_file}"
31
+
32
+  ssh_cmd "${nodename}" docker run -ti -d --net=host --privileged -v /var/tmp/quagga:/etc/quagga --restart always --name Quagga $IMAGE_QUAGGA
33
+}

+ 6
- 0
tools/multi_nodes_gate/airship_gate/lib/config.sh View File

@@ -10,6 +10,7 @@ export IMAGE_PROMENADE_CLI=${IMAGE_PROMENADE_CLI:-quay.io/airshipit/promenade:cf
10 10
 export IMAGE_PEGLEG_CLI=${IMAGE_PEGLEG_CLI:-quay.io/airshipit/pegleg:50ce7a02e08a0a5277c2fbda96ece6eb5782407a}
11 11
 export IMAGE_SHIPYARD_CLI=${IMAGE_SHIPYARD_CLI:-quay.io/airshipit/shipyard:4dd6b484d11e86ad51da733841b9ef137421d461}
12 12
 export IMAGE_COREDNS=${IMAGE_COREDNS:-docker.io/coredns/coredns:1.2.2}
13
+export IMAGE_QUAGGA=${IMAGE_QUAGGA:-docker.io/cumulusnetworks/quagga:CL3.3.2}
13 14
 export IMAGE_DRYDOCK_CLI=${IMAGE_DRYDOCK_CLI:-quay.io/airshipit/drydock:d93d6d5a0a370ced536180612d1ade708e29cd47}
14 15
 export IMAGE_DOCKER_REGISTRY=${IMAGE_DOCKER_REGISTRY:-"docker.io/registry:2"}
15 16
 export PROMENADE_DEBUG=${PROMENADE_DEBUG:-0}
@@ -87,6 +88,11 @@ config_vm_userdata() {
87 88
     fi
88 89
 }
89 90
 
91
+config_bgp_as() {
92
+    as_number=${1}
93
+    jq -cr ".bgp.${as_number}" < "${GATE_MANIFEST}"
94
+}
95
+
90 96
 config_ingress_domain() {
91 97
     jq -cr '.ingress.domain' < "${GATE_MANIFEST}"
92 98
 }

+ 9
- 0
tools/multi_nodes_gate/airship_gate/manifests/multinode_deploy.json View File

@@ -36,6 +36,11 @@
36 36
       "script": "ingress-dns.sh",
37 37
       "arguments": ["build"]
38 38
     },
39
+    {
40
+      "name": "Create BGP router",
41
+      "script": "bgp-router.sh",
42
+      "arguments": ["build"]
43
+    },
39 44
     {
40 45
       "name": "Genesis",
41 46
       "script": "genesis.sh",
@@ -102,5 +107,9 @@
102 107
       "io_profile": "fast",
103 108
       "bootstrap": false
104 109
     }
110
+  },
111
+  "bgp" : {
112
+    "quagga_as": 64688,
113
+    "calico_as": 64671
105 114
   }
106 115
 }

+ 9
- 0
tools/multi_nodes_gate/airship_gate/manifests/multinode_genesis.json View File

@@ -36,6 +36,11 @@
36 36
       "script": "ingress-dns.sh",
37 37
       "arguments": ["build"]
38 38
     },
39
+    {
40
+      "name": "Create BGP router",
41
+      "script": "bgp-router.sh",
42
+      "arguments": ["build"]
43
+    },
39 44
     {
40 45
       "name": "Genesis",
41 46
       "script": "genesis.sh",
@@ -84,5 +89,9 @@
84 89
       "ip": "172.24.1.13",
85 90
       "bootstrap": false
86 91
     }
92
+  },
93
+  "bgp" : {
94
+    "quagga_as": 64688,
95
+    "calico_as": 64671
87 96
   }
88 97
 }

+ 23
- 0
tools/multi_nodes_gate/airship_gate/stages/bgp-router.sh View File

@@ -0,0 +1,23 @@
1
+#!/usr/bin/env bash
2
+# Copyright 2018 AT&T Intellectual Property.  All other rights reserved.
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License");
5
+# you may not use this file except in compliance with the License.
6
+# You may obtain a copy of the License at
7
+#
8
+#     http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS,
12
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+# See the License for the specific language governing permissions and
14
+# limitations under the License.
15
+
16
+set -e
17
+
18
+source "${GATE_UTILS}"
19
+
20
+BGP_ROUTER=$1
21
+
22
+bgp_router_config
23
+bgp_router_start ${BGP_ROUTER}

+ 20
- 0
tools/multi_nodes_gate/airship_gate/templates/bgpd_conf.sub View File

@@ -0,0 +1,20 @@
1
+log file /var/log/quagga/bgpd.log
2
+!
3
+!
4
+router bgp ${QUAGGA_AS}
5
+ bgp router-id ${QUAGGA_IP}
6
+ neighbor calico peer-group
7
+ neighbor calico remote-as ${CALICO_AS}
8
+ bgp listen range 0.0.0.0/0 peer-group calico
9
+ !
10
+ address-family ipv4 unicast
11
+  neighbor calico route-map calico-node-fix-same-as out
12
+ exit-address-family
13
+!
14
+route-map calico-node-fix-same-as permit 100
15
+ set as-path exclude ${CALICO_AS}
16
+ set as-path prepend ${QUAGGA_AS}
17
+!
18
+line vty
19
+!
20
+

+ 7
- 0
tools/multi_nodes_gate/airship_gate/templates/daemons.sub View File

@@ -0,0 +1,7 @@
1
+zebra=yes
2
+bgpd=yes
3
+ospfd=no
4
+ospf6d=no
5
+ripd=no
6
+ripngd=no
7
+isisd=no

+ 19
- 0
tools/multi_nodes_gate/airship_gate/templates/debian_conf.sub View File

@@ -0,0 +1,19 @@
1
+#
2
+# If this option is set the quagga script automatically loads
3
+# the config via "vtysh -b" when the servers are started.
4
+# Check /etc/pam.d/quagga if you intend to use "vtysh"!
5
+#
6
+vtysh_enable=yes
7
+zebra_options="  -s 90000000 --daemon -A 0.0.0.0"
8
+bgpd_options="   --daemon -A 0.0.0.0 -p 179"
9
+ospfd_options="  --daemon -A 127.0.0.1"
10
+ospf6d_options=" --daemon -A ::1"
11
+ripd_options="   --daemon -A 127.0.0.1"
12
+ripngd_options=" --daemon -A ::1"
13
+isisd_options="  --daemon -A 127.0.0.1"
14
+pimd_options="  --daemon -A 127.0.0.1"
15
+ldpd_options="   --daemon -A 127.0.0.1"
16
+
17
+# The list of daemons to watch is automatically generated by the init script.
18
+watchquagga_enable=yes
19
+watchquagga_options=(-adz -r /usr/sbin/servicebBquaggabBrestartbB%s -s /usr/sbin/servicebBquaggabBstartbB%s -k /usr/sbin/servicebBquaggabBstopbB%s -b bB -t 90)

+ 7
- 0
tools/multi_nodes_gate/setup_gate.sh View File

@@ -94,6 +94,13 @@ if [[ ! -d ${VIRSH_POOL_PATH} ]]; then
94 94
     sudo mkdir -p "${VIRSH_POOL_PATH}"
95 95
 fi
96 96
 
97
+log_stage_header "Disabling br_netfilter"
98
+br_netfilter_files=('bridge-nf-call-arptables' 'bridge-nf-call-iptables' 'bridge-nf-call-ip6tables')
99
+for br_netfilter_file in "${br_netfilter_files[@]}"
100
+do
101
+        sudo sh -c "(echo "0" > /proc/sys/net/bridge/${br_netfilter_file})"
102
+done
103
+
97 104
 if [[ ${REQUIRE_RELOG} -eq 1 ]]; then
98 105
     echo
99 106
     log_note "You must ${C_HEADER}log out${C_CLEAR} and back in before the gate is ready to run."

Loading…
Cancel
Save