diff --git a/docker/openvswitch-base/Dockerfile.j2 b/docker/openvswitch-base/Dockerfile.j2 new file mode 100644 index 0000000..b750e28 --- /dev/null +++ b/docker/openvswitch-base/Dockerfile.j2 @@ -0,0 +1,7 @@ +FROM {{ namespace }}/base-tools:{{ tag }} +MAINTAINER {{ maintainer }} + +RUN apt-get -y install --no-install-recommends \ + openvswitch-switch \ + && apt-get clean + diff --git a/docker/openvswitch-db/Dockerfile.j2 b/docker/openvswitch-db/Dockerfile.j2 new file mode 100644 index 0000000..76f3605 --- /dev/null +++ b/docker/openvswitch-db/Dockerfile.j2 @@ -0,0 +1,2 @@ +FROM {{ namespace }}/openvswitch-base:{{ tag }} +MAINTAINER {{ maintainer }} diff --git a/docker/openvswitch-vswitchd/Dockerfile.j2 b/docker/openvswitch-vswitchd/Dockerfile.j2 new file mode 100644 index 0000000..49bdf5f --- /dev/null +++ b/docker/openvswitch-vswitchd/Dockerfile.j2 @@ -0,0 +1,3 @@ +FROM {{ namespace }}/openvswitch-base:{{ tag }} +MAINTAINER {{ maintainer }} + diff --git a/service/files/openvswitch-db-bootstrap.sh b/service/files/openvswitch-db-bootstrap.sh new file mode 100644 index 0000000..606cd5f --- /dev/null +++ b/service/files/openvswitch-db-bootstrap.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +mkdir -p "/run/openvswitch" +if [[ ! -e "/etc/openvswitch/conf.db" ]]; then + ovsdb-tool create "/etc/openvswitch/conf.db" +fi diff --git a/service/files/ovs-ensure-configured.sh b/service/files/ovs-ensure-configured.sh new file mode 100644 index 0000000..99bae3e --- /dev/null +++ b/service/files/ovs-ensure-configured.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +bridge=$1 +port=$2 + +ovs-vsctl br-exists $bridge; rc=$? +if [[ $rc == 2 ]]; then + changed=changed + ovs-vsctl --no-wait add-br $bridge +fi + +if [[ ! $(ovs-vsctl list-ports $bridge) =~ $(echo "\<$port\>") ]]; then + changed=changed + ovs-vsctl --no-wait add-port $bridge $port +fi + +echo $changed diff --git a/service/openvswitch-db.yaml b/service/openvswitch-db.yaml new file mode 100644 index 0000000..8025a85 --- /dev/null +++ b/service/openvswitch-db.yaml @@ -0,0 +1,31 @@ +service: + name: openvswitch-db + host-net: true + daemonset: true + node-selector: + openstack-compute-controller: "true" + containers: + - name: openvswitch-db + image: openvswitch-db + probes: + readiness: "true" + liveness: "true" + volumes: + - name: run + type: host + path: /run + pre: + - name: ovs-bootstrap + command: /opt/ccp/bin/openvswitch-db-bootstrap.sh + dependencies: + - rabbitmq + - neutron-db-sync + daemon: + command: /usr/sbin/ovsdb-server /etc/openvswitch/conf.db -vconsole:emer -vsyslog:err -vfile:info --remote=punix:/run/openvswitch/db.sock --log-file=/var/log/openvswitch/ovsdb-server.log + files: + - openvswitch-db-bootstrap.sh +files: + openvswitch-db-bootstrap.sh: + path: /opt/ccp/bin/openvswitch-db-bootstrap.sh + content: openvswitch-db-bootstrap.sh + perm: "0755" diff --git a/service/openvswitch-vswitchd.yaml b/service/openvswitch-vswitchd.yaml new file mode 100644 index 0000000..f1fc0a3 --- /dev/null +++ b/service/openvswitch-vswitchd.yaml @@ -0,0 +1,41 @@ +service: + name: openvswitch-vswitchd + host-net: true + daemonset: true + node-selector: + openstack-compute-controller: "true" + containers: + - name: openvswitch-vswitchd + image: openvswitch-vswitchd + privileged: true + probes: + readiness: "true" + liveness: "true" + volumes: + - name: run + type: host + path: /run + - name: modules + type: host + path: /lib/modules + pre: + - name: vswitchd-bootstrap + command: modprobe openvswitch + - name: vswitchd-check-ovs-db + command: ovs-vsctl --no-wait show + dependencies: + - vswitchd-bootstrap + - openvswitch-db + - name: vswitchd-setup-ovs-bridge + command: /usr/local/bin/ovs-ensure-configured.sh {{ neutron_bridge_name }} {{ neutron_external_interface }} + dependencies: + - vswitchd-check-ovs-db + daemon: + command: /usr/sbin/ovs-vswitchd unix:/run/openvswitch/db.sock --mlockall + files: + - ovs-ensure-configured.sh +files: + ovs-ensure-configured.sh: + path: /usr/local/bin/ovs-ensure-configured.sh + content: ovs-ensure-configured.sh + perm: "0755"