diff --git a/.flannel.metadata b/.flannel.metadata new file mode 100644 index 0000000..96d706b --- /dev/null +++ b/.flannel.metadata @@ -0,0 +1 @@ +38c21cae429b2104a285309983e51d835140a765 SOURCES/v0.2.0.tar.gz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc5d287 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/v0.2.0.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index 98f42b4..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/flannel-docker.conf b/SOURCES/flannel-docker.conf new file mode 100644 index 0000000..8f55177 --- /dev/null +++ b/SOURCES/flannel-docker.conf @@ -0,0 +1,2 @@ +[Service] +EnvironmentFile=-/run/flannel/docker diff --git a/SOURCES/flanneld.service b/SOURCES/flanneld.service new file mode 100644 index 0000000..da6439c --- /dev/null +++ b/SOURCES/flanneld.service @@ -0,0 +1,14 @@ +[Unit] +Description=Flanneld overlay address etcd agent +After=network.target +Before=docker.service + +[Service] +Type=notify +EnvironmentFile=/etc/sysconfig/flanneld +EnvironmentFile=-/etc/sysconfig/docker-network +ExecStart=/usr/bin/flanneld -etcd-endpoints=${FLANNEL_ETCD} -etcd-prefix=${FLANNEL_ETCD_KEY} ${FLANNEL_OPTIONS} +ExecStartPost=/usr/libexec/flannel/mk-docker-opts.sh -k DOCKER_NETWORK_OPTIONS -d /run/flannel/docker + +[Install] +RequiredBy=docker.service diff --git a/SOURCES/flanneld.sysconf b/SOURCES/flanneld.sysconf new file mode 100644 index 0000000..082e335 --- /dev/null +++ b/SOURCES/flanneld.sysconf @@ -0,0 +1,12 @@ +# Flanneld configuration options + +# etcd url location. Point this to the server where etcd runs +FLANNEL_ETCD="http://127.0.0.1:4001" + +# etcd config key. This is the configuration key that flannel queries +# For address range assignment +FLANNEL_ETCD_KEY="/coreos.com/network" + +# Any additional options that you want to pass +#FLANNEL_OPTIONS="" + diff --git a/SOURCES/mk-docker-opts.sh b/SOURCES/mk-docker-opts.sh new file mode 100755 index 0000000..41f6022 --- /dev/null +++ b/SOURCES/mk-docker-opts.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +usage() { + echo "$0 [-f FLANNEL-ENV-FILE] [-d DOCKER-ENV-FILE] [-i] [-c] [-m] + +Generate Docker daemon options based on flannel env file +OPTIONS: + -f Path to flannel env file. Defaults to /run/flannel/subnet.env + -d Path to Docker env file to write to. Defaults to /run/docker_opts.env + -i Output each Docker option as individual var. e.g. DOCKER_OPT_MTU=1500 + -c Output combined Docker options into DOCKER_OPTS var + -k Set the combined options key to this value (default DOCKER_OPTS=) + -m Do not output --ip-masq (useful for older Docker version) +" >/dev/stderr + + exit 1 +} + +flannel_env="/run/flannel/subnet.env" +docker_env="/run/docker_opts.env" +combined_opts_key="DOCKER_OPTS" +indiv_opts=false +combined_opts=false +ipmasq=true + +while getopts "f:d:ick:" opt; do + case $opt in + f) + flannel_env=$OPTARG + ;; + d) + docker_env=$OPTARG + ;; + i) + indiv_opts=true + ;; + c) + combined_opts=true + ;; + m) + ipmasq=false + ;; + k) + combined_opts_key=$OPTARG + ;; + \?) + usage + ;; + esac +done + +if [ $indiv_opts = false ] && [ $combined_opts = false ]; then + indiv_opts=true + combined_opts=true +fi + +if [ -f "$flannel_env" ]; then + source $flannel_env +fi + +if [ -n "$FLANNEL_SUBNET" ]; then + DOCKER_OPT_BIP="--bip=$FLANNEL_SUBNET" +fi + +if [ -n "$FLANNEL_MTU" ]; then + DOCKER_OPT_MTU="--mtu=$FLANNEL_MTU" +fi + +if [ "$FLANNEL_IPMASQ" = true ] && [ $ipmasq = true ] ; then + DOCKER_OPT_IPMASQ="--ip-masq=false" +fi + +eval docker_opts="\$${combined_opts_key}" +docker_opts+=" " + +echo -n "" >$docker_env +for opt in $(compgen -v DOCKER_OPT_); do + eval val=\$$opt + + if [ "$indiv_opts" = true ]; then + echo "$opt=\"$val\"" >>$docker_env + fi + + docker_opts+="$val " +done + +if [ "$combined_opts" = true ]; then + echo "${combined_opts_key}=\"${docker_opts}\"" >>$docker_env +fi diff --git a/SPECS/flannel.spec b/SPECS/flannel.spec new file mode 100644 index 0000000..3e48b7e --- /dev/null +++ b/SPECS/flannel.spec @@ -0,0 +1,120 @@ +%global debug_package %{nil} +%global provider github +%global provider_tld com +%global project coreos +%global repo flannel +%global import_path %{provider}.%{provider_tld}/%{project}/%{repo} +%global commit 52c3c4fb51109fdbb09a0d002ac35606f4a773ae +%global shortcommit %(c=%{commit}; echo ${c:0:7}) + +Name: flannel +Version: 0.2.0 +Release: 6%{?dist} +Summary: Etcd address management agent for overlay networks +License: ASL 2.0 +URL: https://%{import_path} +#Source0: https://%{import_path}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz +Source0: https://%{import_path}/archive/v%{version}.tar.gz +Source1: flanneld.sysconf +Source2: flanneld.service +Source3: flannel-docker.conf +Source4: mk-docker-opts.sh +ExclusiveArch: %{ix86} x86_64 %{arm} + +BuildRequires: golang >= 1.2.7 +BuildRequires: pkgconfig(systemd) +Requires: systemd +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd + +%description +Flannel is an etcd driven address management agent. Most commonly it is used to +manage the ip addresses of overlay networks between systems running containers +that need to communicate with one another. + +%prep +%setup -q -n %{repo}-%{version} + +%build +./build + +%install +# package with binary +install -D -p -m 755 bin/flanneld %{buildroot}%{_bindir}/flanneld +install -D -p -m 644 %{SOURCE1} %{buildroot}/etc/sysconfig/flanneld +install -D -p -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/flanneld.service +install -D -p -m 644 %{SOURCE3} %{buildroot}%{_unitdir}/docker.service.d/flannel.conf +install -D -p -m 755 %{SOURCE4} %{buildroot}%{_libexecdir}/flannel/mk-docker-opts.sh + +%post +%systemd_post flanneld.service + +%preun +# clean tempdir and workdir on removal or upgrade +%systemd_preun flanneld.service + +%postun +%systemd_postun_with_restart flanneld.service + +%files +%doc CONTRIBUTING.md LICENSE MAINTAINERS README.md DCO NOTICE +%{_bindir}/flanneld +%{_unitdir}/flanneld.service +%{_unitdir}/docker.service.d/flannel.conf +%{_libexecdir}/flannel/mk-docker-opts.sh +%config(noreplace) %{_sysconfdir}/sysconfig/flanneld + +%changelog +* Fri Jan 30 2015 jchaloup - 0.2.0-6 +- remove devel subpackage + +* Wed Jan 21 2015 Eric Paris - 0.2.0-5 +- Add generator more like upstream wants to use, use ExecStartPost + (https://github.com/coreos/flannel/pull/85) + +* Tue Jan 20 2015 Eric Paris - 0.2.0-4 +- Add generator to turn flannel env vars into docker flags + +* Tue Jan 20 2015 Peter Lemenkov - 0.2.0-3 +- Change (Build)Requires accordning to the recent changes + (http://pkgs.fedoraproject.org/cgit/golang-github-coreos-go-systemd.git/commit/?id=204f61c) + +* Fri Jan 16 2015 Peter Lemenkov - 0.2.0-2 +- Change flannel service type to notify. See + https://github.com/coreos/flannel/blob/v0.2.0/main.go#L213 + +* Tue Dec 23 2014 Lokesh Mandvekar - 0.2.0-1 +- update to upstream v0.2.0 +- append FLANNEL_OPTIONS variable to unitfile command +- systemd-units merged into systemd for fedora18+ + +* Tue Dec 2 2014 John W. Linville - 0.1.0-8.gita7b435a +- Remove patches related to out-of-tree slice backend +- Update to latest upstream + +* Thu Nov 20 2014 jchaloup - 0.1.0-7.git071d778 +- Removing deps on Godeps and adding deps on golang-github packages +- Removing wait-online service and changing Type of flannel.service from simple to notify +- Adding README and other doc files +- Adding spec file header with commit, import_path, ... +- Adding devel subpackage +- spec polished based on Lokesh' notes (3 lines below) +- modify summary in specfile as in bug description (capitalize if needed) +- might need to enforce NVR for coreos/go-systemd in deps +- pkgconfig(systemd) is preferable to systemd in BR (I think) + resolves: #1165688 + +* Fri Nov 07 2014 - Neil Horman +- Updating to latest upstream + +* Fri Nov 07 2014 - Neil Horman +- Added wait-online service to sync with docker + +* Thu Nov 06 2014 - Neil Horman +- Fixed flanneld.service file +- Added linvilles slice type patch + +* Tue Nov 04 2014 - Neil Horman - 0.1.0-20141104gitdc530ce +- Initial Build +