From 7f01772cdf3916026a93e9e9ac5ce54d57401476 Mon Sep 17 00:00:00 2001 From: Author Name Date: Mon, 2 Mar 2020 04:34:42 +0000 Subject: Adding the ovn containerization Referred multiple works on ovs and ovn ovs: https://github.com/openvswitch/ovs/tree/master/utilities/docker ovn: https://github.com/ovn-org/ovn/tree/master/utilities/docker ovn-kubernetes: https://github.com/ovn-org/ovn-kubernetes/tree/master/dist/images kube-ovn:https://github.com/alauda/kube-ovn/tree/master/dist/images Co-authored-by: Aliasgar Ginwala Signed-off-by: Kuralamudhan Ramakrishnan Change-Id: I3aee1a9f4ebce702ca22ec2ecba35463523af892 --- utilities/docker/debian/Dockerfile | 40 +++++++++ utilities/docker/debian/ovn4nfv-k8s.sh | 158 +++++++++++++++++++++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 utilities/docker/debian/Dockerfile create mode 100755 utilities/docker/debian/ovn4nfv-k8s.sh (limited to 'utilities') diff --git a/utilities/docker/debian/Dockerfile b/utilities/docker/debian/Dockerfile new file mode 100644 index 0000000..674ee7e --- /dev/null +++ b/utilities/docker/debian/Dockerfile @@ -0,0 +1,40 @@ +FROM ubuntu:18.04 as base + +USER root + +RUN apt-get update && apt-get install -y iproute2 curl software-properties-common setpriv dpkg-dev netcat + +RUN mkdir -p /opt/ovn4nfv-k8s-plugin/dist/ubuntu/deb +RUN bash -xc "\ +pushd /opt/ovn4nfv-k8s-plugin/dist/ubuntu/deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/libopenvswitch-dev_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/libopenvswitch_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/openvswitch-common_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/openvswitch-datapath-dkms_2.12.0-1_all.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/openvswitch-datapath-source_2.12.0-1_all.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/openvswitch-dbg_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/openvswitch-ipsec_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/openvswitch-pki_2.12.0-1_all.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/openvswitch-switch_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/openvswitch-testcontroller_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/openvswitch-test_2.12.0-1_all.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/openvswitch-vtep_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/ovn-central_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/ovn-common_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/ovn-controller-vtep_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/ovn-docker_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/ovn-host_2.12.0-1_amd64.deb; \ +curl --insecure --compressed -O -L https://github.com/akraino-icn/ovs/releases/download/v2.12.0/python-openvswitch_2.12.0-1_all.deb; \ +dpkg-scanpackages . | gzip -c9 > Packages.gz; \ +popd; \ +" +RUN ls -lt /opt/ovn4nfv-k8s-plugin/dist/ubuntu/deb +RUN echo "deb [trusted=yes] file:///opt/ovn4nfv-k8s-plugin/dist/ubuntu/deb ./" | tee -a /etc/apt/sources.list > /dev/null +RUN apt-get update +RUN apt-get install -y openvswitch-switch=2.12.0-1 openvswitch-common=2.12.0-1 ovn-central=2.12.0-1 ovn-common=2.12.0-1 ovn-host=2.12.0-1 +RUN mkdir -p /var/run/openvswitch && \ + mkdir -p /var/run/ovn + +COPY ovn4nfv-k8s.sh /usr/local/bin/ovn4nfv-k8s + +ENTRYPOINT ["ovn4nfv-k8s"] diff --git a/utilities/docker/debian/ovn4nfv-k8s.sh b/utilities/docker/debian/ovn4nfv-k8s.sh new file mode 100755 index 0000000..ee60e2b --- /dev/null +++ b/utilities/docker/debian/ovn4nfv-k8s.sh @@ -0,0 +1,158 @@ +#!/usr/bin/env bash +OVS_RUNDIR=/var/run/openvswitch +OVS_LOGDIR=/var/log/openvswitch + +DB_NB_ADDR=${DB_NB_ADDR:-::} +DB_NB_PORT=${DB_NB_PORT:-6641} +DB_SB_ADDR=${DB_SB_ADDR:-::} +DB_SB_PORT=${DB_SB_PORT:-6642} +cmd=${1:-""} + +if [[ -f /usr/bin/ovn-appctl ]] ; then + # ovn-appctl is present. Use new ovn run dir path. + OVN_RUNDIR=/var/run/ovn + OVNCTL_PATH=/usr/share/ovn/scripts/ovn-ctl + OVN_LOGDIR=/var/log/ovn + OVN_ETCDIR=/etc/ovn +else + # ovn-appctl is not present. Use openvswitch run dir path. + OVN_RUNDIR=/var/run/openvswitch + OVNCTL_PATH=/usr/share/openvswitch/scripts/ovn-ctl + OVN_LOGDIR=/var/log/openvswitch + OVN_ETCDIR=/etc/openvswitch +fi + +check_ovn_control_plane() { + /usr/share/ovn/scripts/ovn-ctl status_northd + /usr/share/ovn/scripts/ovn-ctl status_ovnnb + /usr/share/ovn/scripts/ovn-ctl status_ovnsb +} + +check_ovn_controller() { + /usr/share/ovn/scripts/ovn-ctl status_controller +} + +# wait for ovn-sb ready +wait_ovn_sb() { + if [[ -z "${OVN_SB_TCP_SERVICE_HOST}" ]]; then + echo "env OVN_SB_SERVICE_HOST not exists" + exit 1 + fi + if [[ -z "${OVN_SB_TCP_SERVICE_PORT}" ]]; then + echo "env OVN_SB_SERVICE_PORT not exists" + exit 1 + fi + while ! nc -z "${OVN_SB_TCP_SERVICE_HOST}" "${OVN_SB_TCP_SERVICE_PORT}"