-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ha for ovn dbs and simplify makefile
http://docs.openvswitch.org/en/latest/ref/ovsdb.7/#clustered-database-service-model https://bugs.launchpad.net/openstack-ansible/+bug/1790933 https://mail.openvswitch.org/pipermail/ovs-discuss/2018-March/046470.html
- Loading branch information
Showing
14 changed files
with
182 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM centos:7 | ||
|
||
ENV PYTHONDONTWRITEBYTECODE yes | ||
|
||
RUN yum install -y \ | ||
PyYAML bind-utils \ | ||
openssl \ | ||
numactl-libs \ | ||
firewalld-filesystem \ | ||
libpcap \ | ||
hostname \ | ||
iproute strace socat nc \ | ||
unbound unbound-devel python-openvswitch libreswan && \ | ||
yum clean all | ||
|
||
ENV OVS_VERSION=2.11.1 | ||
ENV OVS_SUBVERSION=1 | ||
|
||
RUN rpm -ivh https://github.com/alauda/ovs/releases/download/v${OVS_VERSION}-${OVS_SUBVERSION}/openvswitch-${OVS_VERSION}-${OVS_SUBVERSION}.el7.x86_64.rpm && \ | ||
rpm -ivh https://github.com/alauda/ovs/releases/download/v${OVS_VERSION}-${OVS_SUBVERSION}/openvswitch-ipsec-${OVS_VERSION}-${OVS_SUBVERSION}.el7.x86_64.rpm && \ | ||
rpm -ivh https://github.com/alauda/ovs/releases/download/v${OVS_VERSION}-${OVS_SUBVERSION}/openvswitch-devel-${OVS_VERSION}-${OVS_SUBVERSION}.el7.x86_64.rpm && \ | ||
rpm -ivh https://github.com/alauda/ovs/releases/download/v${OVS_VERSION}-${OVS_SUBVERSION}/ovn-${OVS_VERSION}-${OVS_SUBVERSION}.el7.x86_64.rpm && \ | ||
rpm -ivh https://github.com/alauda/ovs/releases/download/v${OVS_VERSION}-${OVS_SUBVERSION}/ovn-common-${OVS_VERSION}-${OVS_SUBVERSION}.el7.x86_64.rpm && \ | ||
rpm -ivh https://github.com/alauda/ovs/releases/download/v${OVS_VERSION}-${OVS_SUBVERSION}/ovn-vtep-${OVS_VERSION}-${OVS_SUBVERSION}.el7.x86_64.rpm && \ | ||
rpm -ivh https://github.com/alauda/ovs/releases/download/v${OVS_VERSION}-${OVS_SUBVERSION}/ovn-central-${OVS_VERSION}-${OVS_SUBVERSION}.el7.x86_64.rpm && \ | ||
rpm -ivh https://github.com/alauda/ovs/releases/download/v${OVS_VERSION}-${OVS_SUBVERSION}/ovn-host-${OVS_VERSION}-${OVS_SUBVERSION}.el7.x86_64.rpm | ||
|
||
RUN mkdir -p /var/run/openvswitch | ||
|
||
COPY ovn-healthcheck.sh /root/ovn-healthcheck.sh | ||
COPY ovn-is-leader.sh /root/ovn-is-leader.sh | ||
|
||
COPY start-db.sh /root/start-db.sh | ||
|
||
CMD ["/bin/bash", "/root/start-db.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
set -euo pipefail | ||
|
||
ovn-nbctl show | ||
ovn-sbctl show | ||
# wait 5 seconds | ||
ovn-sbctl -t 5 show |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
ovn-nbctl show | ||
# wait 5 seconds | ||
ovn-sbctl -t 5 show | ||
|
||
# For data consistency, only store leader address in endpoint | ||
echo $(cat /var/log/openvswitch/ovn-northd.log) | grep -oP "lock acquired(?!.*lock lost).*$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
ovs-vsctl show |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
DB_NB_ADDR=${1:-0.0.0.0} | ||
DB_NB_PORT=${1:-6641} | ||
DB_SB_ADDR=${1:-0.0.0.0} | ||
DB_SB_PORT=${1:-6642} | ||
|
||
function gen_conn_str { | ||
t=$(echo -n ${NODE_IPS} | sed 's/[[:space:]]//g' | sed 's/,/ /g') | ||
x=$(for i in $t; do echo -n "tcp:$i:$1",; done| sed 's/,$//') | ||
echo "$x" | ||
} | ||
|
||
function get_first_node_ip { | ||
t=$(echo -n ${NODE_IPS} | sed 's/[[:space:]]//g' | sed 's/,/ /g') | ||
echo -n $t | cut -f 1 -d " " | ||
} | ||
|
||
function quit { | ||
/usr/share/openvswitch/scripts/ovn-ctl stop_northd | ||
exit 0 | ||
} | ||
trap quit EXIT | ||
|
||
if [ -z "$NODE_IPS" ]; then | ||
/usr/share/openvswitch/scripts/ovn-ctl restart_northd | ||
else | ||
/usr/share/openvswitch/scripts/ovn-ctl stop_northd | ||
|
||
first_node_ip=$(get_first_node_ip) | ||
if [ "$first_node_ip" == "${POD_IP}" ]; then | ||
# Start ovn-northd, ovn-nb and ovn-sb | ||
/usr/share/openvswitch/scripts/ovn-ctl \ | ||
--db-nb-create-insecure-remote=yes \ | ||
--db-sb-create-insecure-remote=yes \ | ||
--db-nb-cluster-local-addr=${POD_IP} \ | ||
--db-sb-cluster-local-addr=${POD_IP} \ | ||
--ovn-northd-nb-db=$(gen_conn_str 6641) \ | ||
--ovn-northd-sb-db=$(gen_conn_str 6642) \ | ||
start_northd | ||
else | ||
while ! nc -z ${first_node_ip} ${DB_NB_PORT} </dev/null; | ||
do | ||
echo "sleep 5 seconds, waiting for ovn-nb ${first_node_ip}:${DB_NB_PORT} ready " | ||
sleep 5; | ||
done | ||
# Start ovn-northd, ovn-nb and ovn-sb | ||
/usr/share/openvswitch/scripts/ovn-ctl \ | ||
--db-nb-create-insecure-remote=yes \ | ||
--db-sb-create-insecure-remote=yes \ | ||
--db-nb-cluster-local-addr=${POD_IP} \ | ||
--db-sb-cluster-local-addr=${POD_IP} \ | ||
--db-nb-cluster-remote-addr=$first_node_ip \ | ||
--db-sb-cluster-remote-addr=$first_node_ip \ | ||
--ovn-northd-nb-db=$(gen_conn_str 6641) \ | ||
--ovn-northd-sb-db=$(gen_conn_str 6642) \ | ||
start_northd | ||
fi | ||
fi | ||
|
||
# ovn-nb and ovn-sb listen on tcp ports for ovn-controller to connect | ||
ovn-nbctl set-connection ptcp:${DB_NB_PORT}:${DB_NB_ADDR} | ||
ovn-sbctl set-connection ptcp:${DB_SB_PORT}:${DB_SB_ADDR} | ||
|
||
tail -f /var/log/openvswitch/ovn-northd.log |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# High available for ovn db | ||
|
||
ovs support clustered database. If want to use high-available database in kube-ovn, | ||
modifie ovn-central deployment in yamls/ovn.yaml. | ||
|
||
Change the replicas to 3, and add NODE_IPS environment var. | ||
```yaml | ||
replicas: 3 | ||
containers: | ||
- name: ovn-central | ||
image: "index.alauda.cn/alaudak8s/kube-ovn-db:dev1" | ||
imagePullPolicy: Always | ||
env: | ||
- name: POD_IP | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.podIP | ||
- name: NODE_IPS | ||
value: 192.168.55.10, 192.168.55.11, 192.168.55.12 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters