Browse code

Add sdn ovs enabled node image

Scott Dodson authored on 2015/10/15 06:15:26
Showing 7 changed files
... ...
@@ -120,7 +120,11 @@ os::util::get-network-plugin() {
120 120
 
121 121
 os::util::install-sdn() {
122 122
   local deployed_root=$1
123
-
123
+  local target=$2
124
+  target=${target:-/usr}
125
+  if [ ! -d ${target} ]; then
126
+    mkdir -p ${target}
127
+  fi
124 128
   # Source scripts from an openshift-sdn repo if present to support
125 129
   # openshift-sdn development.
126 130
   local sdn_root="${deployed_root}/third-party/openshift-sdn"
... ...
@@ -135,20 +139,21 @@ os::util::install-sdn() {
135 135
     local osdn_controller_path="${osdn_base_path}/pkg/ovssubnet/controller"
136 136
     pushd "${osdn_controller_path}" > /dev/null
137 137
       # The subnet plugin is discovered via the kube network plugin path.
138
-      local kube_osdn_path="/usr/libexec/kubernetes/kubelet-plugins/net/exec/redhat~openshift-ovs-subnet"
138
+      local kube_osdn_path="${target}/libexec/kubernetes/kubelet-plugins/net/exec/redhat~openshift-ovs-subnet"
139 139
       mkdir -p "${kube_osdn_path}"
140
+      mkdir -p "${target}/bin/"
140 141
       cp -f kube/bin/openshift-ovs-subnet "${kube_osdn_path}/"
141
-      cp -f kube/bin/openshift-sdn-kube-subnet-setup.sh /usr/bin/
142
+      cp -f kube/bin/openshift-sdn-kube-subnet-setup.sh "${target}/bin/"
142 143
 
143 144
       # The multitenant plugin only needs to be in PATH because the
144 145
       # origin multitenant plugin knows how to discover it.
145
-      cp -f multitenant/bin/openshift-ovs-multitenant /usr/bin/
146
-      cp -f multitenant/bin/openshift-sdn-multitenant-setup.sh /usr/bin/
146
+      cp -f multitenant/bin/openshift-ovs-multitenant "${target}/bin/"
147
+      cp -f multitenant/bin/openshift-sdn-multitenant-setup.sh "${target}/bin/"
147 148
 
148 149
       # subnet and multitenant plugin setup writes docker network options
149 150
       # to /run/openshift-sdn/docker-network, make this file to be exported
150 151
       # as part of docker service start.
151
-      local system_docker_path="/usr/lib/systemd/system/docker.service.d/"
152
+      local system_docker_path="${target}/lib/systemd/system/docker.service.d/"
152 153
       mkdir -p "${system_docker_path}"
153 154
       cat <<EOF > "${system_docker_path}/docker-sdn-ovs.conf"
154 155
 [Service]
... ...
@@ -15,6 +15,7 @@ STARTTIME=$(date +%s)
15 15
 OS_ROOT=$(dirname "${BASH_SOURCE}")/..
16 16
 source "${OS_ROOT}/hack/common.sh"
17 17
 source "${OS_ROOT}/hack/util.sh"
18
+source "${OS_ROOT}/contrib/vagrant/provision-util.sh"
18 19
 os::log::install_errexit
19 20
 
20 21
 # Go to the top of the tree.
... ...
@@ -49,6 +50,11 @@ cp -pf "${imagedir}/deployment"      examples/deployment/bin
49 49
 cp -pf "${imagedir}/gitserver"       examples/gitserver/bin
50 50
 cp -pf "${imagedir}/dockerregistry"  images/dockerregistry/bin
51 51
 
52
+# Copy SDN scripts into images/node
53
+os::util::install-sdn "${OS_ROOT}" "${OS_ROOT}/images/node"
54
+mkdir -p images/node/conf/
55
+cp -pf "${OS_ROOT}/contrib/systemd/openshift-sdn-ovs.conf" images/node/conf/
56
+
52 57
 # builds an image and tags it two ways - with latest, and with the release tag
53 58
 function image {
54 59
   echo "--- $1 ---"
... ...
@@ -56,8 +62,9 @@ function image {
56 56
   docker tag -f $1:latest $1:${OS_RELEASE_COMMIT}
57 57
 }
58 58
 
59
-# images that depend on scratch
59
+# images that depend on scratch / centos
60 60
 image openshift/origin-pod                   images/pod
61
+image openshift/openvswitch                  images/openvswitch
61 62
 # images that depend on openshift/origin-base
62 63
 image openshift/origin                       images/origin
63 64
 image openshift/origin-haproxy-router        images/router/haproxy
... ...
@@ -69,6 +76,7 @@ image openshift/origin-docker-builder        images/builder/docker/docker-builde
69 69
 image openshift/origin-gitserver             examples/gitserver
70 70
 image openshift/origin-sti-builder           images/builder/docker/sti-builder
71 71
 image openshift/origin-f5-router             images/router/f5
72
+image openshift/node                         images/node
72 73
 # unpublished images
73 74
 image openshift/origin-custom-docker-builder images/builder/docker/custom-docker-builder
74 75
 
75 76
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+bin/
1
+lib/
2
+libexec/
3
+conf/
0 4
new file mode 100644
... ...
@@ -0,0 +1,42 @@
0
+#
1
+# This is an OpenShift Origin node image with integrated OpenvSwitch SDN
2
+# If you do not require OVS SDN you should just use the origin image
3
+#
4
+# The standard name for this image is openshift/origin-node
5
+#
6
+
7
+FROM openshift/origin
8
+
9
+# Based on work by: Peter Schiffer <pschiffe@redhat.com>
10
+MAINTAINER Devan Goodwin <dgoodwin@redhat.com>
11
+
12
+# We need to install openvswitch for the client portions, the daemons are expected
13
+# to run in another container
14
+
15
+ADD https://copr.fedoraproject.org/coprs/maxamillion/origin-next/repo/epel-7/maxamillion-origin-next-epel-7.repo /etc/yum.repos.d/
16
+RUN yum install -y libmnl libnetfilter_conntrack openvswitch \
17
+    libnfnetlink iptables iproute bridge-utils procps-ng ethtool socat openssl \
18
+    binutils xz kmod-libs kmod sysvinit-tools device-mapper-libs dbus \
19
+    && yum clean all
20
+
21
+RUN mkdir -p /usr/libexec/kubernetes/kubelet-plugins/net/exec/redhat~openshift-ovs-subnet \
22
+    /usr/lib/systemd/system/origin-node.service.d \
23
+    /usr/lib/systemd/system/docker.service.d
24
+
25
+# All of the following are placed in images/node by hack/build-images.sh
26
+# They won't exist in the git checkout
27
+ADD bin/* /usr/bin/
28
+ADD libexec/kubernetes/kubelet-plugins/net/exec/redhat~openshift-ovs-subnet/openshift-ovs-subnet /usr/libexec/kubernetes/kubelet-plugins/net/exec/redhat~openshift-ovs-subnet/
29
+ADD conf/openshift-sdn-ovs.conf /usr/lib/systemd/system/origin-node.service.d/
30
+ADD lib/systemd/system/docker.service.d/docker-sdn-ovs.conf /usr/lib/systemd/system/docker.service.d/docker-sdn-ovs.conf
31
+ADD scripts/* /usr/local/bin/
32
+RUN chmod +x /usr/local/bin/* /usr/bin/openshift-* /usr/libexec/kubernetes/kubelet-plugins/net/exec/redhat~openshift-ovs-subnet/openshift-ovs-subnet
33
+
34
+VOLUME [ "/etc/origin/node", "/var/lib/origin" ]
35
+WORKDIR /var/lib/origin
36
+
37
+ENV HOME /root
38
+ENV OPENSHIFT_CONTAINERIZED true
39
+ENV KUBECONFIG /etc/origin/node/node.kubeconfig
40
+ENTRYPOINT []
41
+CMD [ "/usr/local/bin/origin-node-run.sh" ]
0 42
new file mode 100644
... ...
@@ -0,0 +1,19 @@
0
+#!/bin/sh
1
+
2
+set -eu
3
+
4
+function quit {
5
+    pkill openshift
6
+    exit 0
7
+}
8
+
9
+trap quit SIGTERM
10
+
11
+if [ ! -f ${HOST_ETC}/systemd/system/docker.service.d/docker-sdn-ovs.conf ]; then
12
+    mkdir -p ${HOST_ETC}/systemd/system/docker.service.d
13
+    cp /usr/lib/systemd/system/docker.service.d/docker-sdn-ovs.conf ${HOST_ETC}/systemd/system/docker.service.d
14
+fi
15
+
16
+/usr/bin/openshift start node --config=${CONFIG_FILE} ${OPTIONS}
17
+
18
+while true; do sleep 5; done
0 19
new file mode 100644
... ...
@@ -0,0 +1,21 @@
0
+#
1
+# This is an openvswitch image meant to enable OpenShift OVS based SDN
2
+#
3
+# The standard name for this image is openshift/openvswitch
4
+#
5
+
6
+FROM centos:centos7
7
+
8
+MAINTAINER Scott Dodson <sdodson@redhat.com>
9
+
10
+ADD https://copr.fedoraproject.org/coprs/maxamillion/origin-next/repo/epel-7/maxamillion-origin-next-epel-7.repo /etc/yum.repos.d/
11
+# TODO: figure out which of these are necessary for openvswitch, this is the list of packages needed for ovs + node
12
+RUN yum install -y openvswitch \
13
+    && yum clean all
14
+
15
+ADD  scripts/* /usr/local/bin/
16
+RUN chmod +x /usr/local/bin/*
17
+VOLUME [ "/etc/openswitch" ]
18
+
19
+ENV HOME /root
20
+ENTRYPOINT [ "/usr/local/bin/ovs-run.sh" ]
0 21
new file mode 100644
... ...
@@ -0,0 +1,15 @@
0
+#!/bin/sh
1
+
2
+set -eu
3
+
4
+function quit {
5
+    /usr/share/openvswitch/scripts/ovs-ctl stop
6
+    exit 0
7
+}
8
+
9
+trap quit SIGTERM
10
+
11
+/usr/share/openvswitch/scripts/ovs-ctl start --system-id=random
12
+
13
+while true; do sleep 5; done
14
+