Browse code

flannel kubernetes pod and systemd service file

Change-Id: I87b9ea5a0e7f625535d9c036ffc07ba42d1cf514
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3511
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

Vinay Kulkarni authored on 2017/08/12 02:30:17
Showing 4 changed files
... ...
@@ -403,7 +403,8 @@ k8s-docker-images:
403 403
 	cd ./support/dockerfiles/k8s-docker-images && \
404 404
 	./build-k8s-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
405 405
 	./build-k8s-dns-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
406
-	./build-k8s-dashboard-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE)
406
+	./build-k8s-dashboard-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
407
+	./build-flannel-docker-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE)
407 408
 
408 409
 install-photon-docker-image: photon-docker-image
409 410
 	sudo docker build -t photon:tdnf .
... ...
@@ -1,11 +1,11 @@
1 1
 Summary:        Overlay network for containers based on etcd
2 2
 Name:           flannel
3
-Version:        0.5.5
4
-Release:        2%{?dist}
3
+Version:        0.8.0
4
+Release:        1%{?dist}
5 5
 License:        ASL 2.0
6 6
 URL:            https://github.com/coreos/flannel
7
-Source0:        https://github.com/coreos/flannel/archive/%{name}-%{version}.zip
8
-%define sha1 flannel=835f5743510982ad436a2e030ea706c95262862a
7
+Source0:        https://github.com/coreos/flannel/archive/%{name}-%{version}.tar.gz
8
+%define sha1 flannel=d8eb057233de1babd306297d4fc3af098ccbea16
9 9
 Group:          Development/Tools
10 10
 Vendor:         VMware, Inc.
11 11
 Distribution:   Photon
... ...
@@ -14,6 +14,7 @@ BuildRequires:  gcc
14 14
 BuildRequires:  unzip
15 15
 BuildRequires:  go
16 16
 Requires:       etcd >= 2.0.0
17
+%define debug_package %{nil}
17 18
 
18 19
 %description
19 20
 flannel is a virtual network that provides a subnet to a container runtime
... ...
@@ -21,17 +22,68 @@ host OS for use with containers. flannel uses etcd to store the network
21 21
 configuration, allocated subnets, and additional data.
22 22
 
23 23
 %prep
24
-%setup -n %{name}-%{version}
24
+%setup -cqn src/github.com/coreos/
25 25
 
26 26
 %build
27
-./build
27
+export GOPATH=%{_builddir}
28
+echo $GOAPTH
29
+mv %{name}-%{version}  %{name}
30
+pushd %{name}
31
+make dist/flanneld
32
+popd
28 33
 
29 34
 %install
30 35
 install -vdm 755 %{buildroot}%{_bindir}
31
-install -vpm 0755 -t %{buildroot}%{_bindir}/ bin/flanneld
36
+install -vpm 0755 -t %{buildroot}%{_bindir}/ %{name}/dist/flanneld
37
+
38
+install -vdm 0755 %{buildroot}/usr/share/flannel/docker
39
+install -vpm 0755 -t %{buildroot}/usr/share/flannel/docker/ %{name}/dist/mk-docker-opts.sh
40
+
41
+install -vdm 0755 %{buildroot}%{_sysconfdir}/flannel
42
+cat << EOF >> %{buildroot}%{_sysconfdir}/flannel/flanneld
43
+###
44
+# flanneld configuration
45
+#
46
+
47
+# etcd endpoints
48
+ETCD_ENDPOINTS="http://127.0.0.1:4001,http://127.0.0.1:2379"
49
+
50
+# flannel network config
51
+FLANNEL_NETWORK_CONF='{"Network": "172.17.0.0/16"}'
52
+
53
+# kubernetes api server URL
54
+KUBE_API_URL="http://localhost:8080"
55
+
56
+# additional flannel options
57
+FLANNEL_OPTIONS=""
58
+EOF
59
+
60
+mkdir -p %{buildroot}/usr/lib/systemd/system
61
+cat << EOF >> %{buildroot}/usr/lib/systemd/system/flanneld.service
62
+[Unit]
63
+Description=flanneld overlay network service
64
+After=network.target etcd.service
65
+Before=docker.service
66
+
67
+[Service]
68
+Type=notify
69
+EnvironmentFile=-/etc/flannel/flanneld
70
+ExecStartPre=/usr/bin/etcdctl mk /vmware/network/config \${FLANNEL_NETWORK_CONF}
71
+ExecStart=/usr/bin/flanneld -etcd-prefix=/vmware/network -etcd-endpoints=\${ETCD_ENDPOINTS} --kube-api-url=\${KUBE_API_URL} \${FLANNEL_OPTIONS}
72
+ExecStopPost=/usr/bin/etcdctl rm /vmware/network/config
73
+Restart=on-failure
74
+
75
+[Install]
76
+WantedBy=multi-user.target
77
+RequiredBy=docker.service
78
+EOF
32 79
 
33 80
 %check
34
-make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
81
+pushd %{name}
82
+go get golang.org/x/tools/cmd/cover
83
+sed -e 's:^func TestRemote:func _TestRemote:' -i remote/remote_test.go || die
84
+./test
85
+popd
35 86
 
36 87
 %post
37 88
 
... ...
@@ -40,11 +92,17 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
40 40
 %files
41 41
 %defattr(-,root,root)
42 42
 %{_bindir}/flanneld
43
+%{_libdir}/systemd/system/flanneld.service
44
+%{_sysconfdir}/flannel/flanneld
45
+/usr/share/flannel/docker/mk-docker-opts.sh
46
+%config(noreplace) %{_sysconfdir}/flannel/flanneld
43 47
 
44 48
 %changelog
45
-*	Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 0.5.5-2
46
--	GA - Bump release of all rpms
47
-*   	 Tue Feb 23 2016 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 0.5.5-1
48
--   	 Upgraded to version 0.5.5
49
-*        Mon Aug 03 2015 Vinay Kulkarni <kulkarniv@vmware.com> 0.5.2-1
50
--        Add flannel package to photon.
49
+*   Fri Aug 11 2017 Vinay Kulkarni <kulkarniv@vmware.com> 0.8.0-1
50
+-   Flannel 0.8.0 and systemd service file.
51
+*   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 0.5.5-2
52
+-   GA - Bump release of all rpms
53
+*   Tue Feb 23 2016 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 0.5.5-1
54
+-   Upgraded to version 0.5.5
55
+*   Mon Aug 03 2015 Vinay Kulkarni <kulkarniv@vmware.com> 0.5.2-1
56
+-   Add flannel package to photon.
51 57
new file mode 100644
... ...
@@ -0,0 +1,12 @@
0
+FROM vmware/photon:1.0
1
+
2
+MAINTAINER kulkarniv@vmware.com
3
+
4
+ENV FLANNEL_ARCH=amd64
5
+
6
+RUN tdnf install -y iproute2 net-tools iptables
7
+ADD tmp/flannel/usr/bin/flanneld /opt/bin/flanneld
8
+COPY tmp/flannel/usr/share/flannel/docker/mk-docker-opts.sh /opt/bin/
9
+RUN ln -s /usr/sbin/iptables /usr/local/bin/iptables
10
+
11
+ENTRYPOINT ["/opt/bin/flanneld"]
0 12
new file mode 100755
... ...
@@ -0,0 +1,41 @@
0
+#!/bin/bash -e
1
+
2
+DIST_TAG=$1
3
+DIST_VER=$2
4
+SPEC_DIR=$3
5
+STAGE_DIR=$4
6
+ARCH=x86_64
7
+
8
+#
9
+# Docker image for flannel
10
+#
11
+FLANNEL_VER=`cat ${SPEC_DIR}/flannel/flannel.spec | grep Version | cut -d: -f2 | tr -d ' '`
12
+FLANNEL_VER_REL=${FLANNEL_VER}-`cat ${SPEC_DIR}/flannel/flannel.spec | grep Release | cut -d: -f2 | tr -d ' ' | cut -d% -f1`
13
+FLANNEL_RPM=flannel-${FLANNEL_VER_REL}${DIST_TAG}.${ARCH}.rpm
14
+FLANNEL_RPM_FILE=${STAGE_DIR}/RPMS/x86_64/${FLANNEL_RPM}
15
+FLANNEL_TAR=flannel.tar
16
+
17
+if [ ! -f ${FLANNEL_RPM_FILE} ]
18
+then
19
+    echo "flannel RPM ${FLANNEL_RPM_FILE} not found. Exiting.."
20
+    exit 1
21
+fi
22
+
23
+IMG_NAME=vmware_photon/flannel:v${FLANNEL_VER}
24
+
25
+IMG_ID=`docker images -q ${IMG_NAME} 2> /dev/null`
26
+if [[ ! -z "${IMG_ID}" ]]; then
27
+    echo "Removing image ${IMG_NAME}"
28
+    docker rmi -f ${IMG_NAME}
29
+fi
30
+
31
+mkdir -p tmp/flannel
32
+cp ${FLANNEL_RPM_FILE} tmp/flannel/
33
+pushd ./tmp/flannel
34
+rpm2cpio ${FLANNEL_RPM} | cpio -vid
35
+popd
36
+docker build --rm -t ${IMG_NAME} -f Dockerfile.flannel .
37
+docker save -o ${FLANNEL_TAR} ${IMG_NAME}
38
+mv -f ${FLANNEL_TAR} ${STAGE_DIR}/
39
+
40
+rm -rf ./tmp