Skip to content

Commit 7269e08

Browse files
author
jojimt
authored
Merge pull request #589 from erikh/variable-docker
Makefile,Vagrantfile,scripts: fix systemd controls and allow docker version to become variable
2 parents afccd6a + 23d9e23 commit 7269e08

File tree

5 files changed

+31
-58
lines changed

5 files changed

+31
-58
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
.PHONY: all all-CI build clean default unit-test release tar checks go-version gofmt-src golint-src govet-src
33

4+
DEFAULT_DOCKER_VERSION := 1.12.3
45
SHELL := /bin/bash
56
EXCLUDE_DIRS := bin docs Godeps scripts test vagrant vendor
67
PKG_DIRS := $(filter-out $(EXCLUDE_DIRS),$(subst /,,$(sort $(dir $(wildcard */)))))
@@ -100,7 +101,7 @@ ifdef NET_CONTAINER_BUILD
100101
start:
101102
else
102103
start:
103-
CONTIV_NODE_OS=${CONTIV_NODE_OS} vagrant up
104+
CONTIV_DOCKER_VERSION="$${CONTIV_DOCKER_VERSION:-$(DEFAULT_DOCKER_VERSION)}" CONTIV_NODE_OS=${CONTIV_NODE_OS} vagrant up
104105
endif
105106

106107
#kubernetes demo targets

Vagrantfile

+29-15
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ BEGIN {
1313

1414
# netplugin_synced_gopath="/opt/golang"
1515
go_version = ENV["GO_VERSION"] || "1.7.3"
16+
docker_version = ENV["CONTIV_DOCKER_VERSION"] || "1.12.3"
1617
gopath_folder="/opt/gopath"
1718

1819
cluster_ip_nodes = ""
@@ -48,32 +49,34 @@ fi
4849
chown -R vagrant #{gopath_folder}
4950
5051
# Install specific docker version if required
51-
if [[ $8 != "" ]]; then
52-
echo "Installing docker version " $8
53-
if [[ $9 == "ubuntu" ]]; then
54-
curl https://get.docker.com | sed s/docker-engine/docker-engine=$8-0~vivid/ | bash
55-
else
56-
# cleanup openstack-kilo repo if required
57-
yum-config-manager --disable openstack-kilo
58-
curl https://get.docker.com | sed s/docker-engine/docker-engine-$8/ | bash
59-
fi
52+
echo "Cleaning docker up to reinstall"
53+
service docker stop || :
54+
rm -rf /var/lib/docker
55+
echo "Installing docker version " $8
56+
if [[ $9 == "ubuntu" ]]; then
57+
sudo apt-get purge docker-engine -y || :
58+
curl https://get.docker.com | sed s/docker-engine/docker-engine=#{docker_version}-0~xenial/g | bash
59+
else
60+
# cleanup openstack-kilo repo if required
61+
yum remove docker-engine -y || :
62+
yum-config-manager --disable openstack-kilo
63+
curl https://get.docker.com | sed s/docker-engine/docker-engine-#{docker_version}/ | bash
6064
fi
65+
6166
# setup docker cluster store
6267
if [[ $7 == *"consul:"* ]]
6368
then
64-
cp #{gopath_folder}/src/github.com/contiv/netplugin/scripts/docker.service.consul /lib/systemd/system/docker.service
69+
perl -i -lpe 's!^ExecStart(.+)$!ExecStart$1 --cluster-store=consul://localhost:8500!' /lib/systemd/system/docker.service
6570
else
66-
cp #{gopath_folder}/src/github.com/contiv/netplugin/scripts/docker.service /lib/systemd/system/docker.service
71+
perl -i -lpe 's!^ExecStart(.+)$!ExecStart$1 --cluster-store=etcd://localhost:2379!' /lib/systemd/system/docker.service
6772
fi
73+
6874
# setup docker remote api
69-
cp #{gopath_folder}/src/github.com/contiv/netplugin/scripts/docker-tcp.socket /etc/systemd/system/docker-tcp.socket
70-
systemctl enable docker-tcp.socket
7175
mkdir /etc/systemd/system/docker.service.d
7276
echo "[Service]" | sudo tee -a /etc/systemd/system/docker.service.d/http-proxy.conf
7377
echo "Environment=\\\"no_proxy=$CLUSTER_NODE_IPS,127.0.0.1,localhost,netmaster\\\" \\\"http_proxy=$http_proxy\\\" \\\"https_proxy=$https_proxy\\\"" | sudo tee -a /etc/systemd/system/docker.service.d/http-proxy.conf
7478
sudo systemctl daemon-reload
7579
sudo systemctl stop docker
76-
systemctl start docker-tcp.socket
7780
sudo systemctl start docker
7881
7982
# remove duplicate docker key
@@ -277,7 +280,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
277280
end
278281
node.vm.provision "shell" do |s|
279282
s.inline = provision_common_once
280-
s.args = [node_name, node_addr, cluster_ip_nodes, ENV["http_proxy"] || "", ENV["https_proxy"] || "", ENV["USE_RELEASE"] || "", ENV["CONTIV_CLUSTER_STORE"] || "etcd://localhost:2379", ENV["CONTIV_DOCKER_VERSION"] || "", ENV['CONTIV_NODE_OS'] || "", *ENV['CONTIV_ENV']]
283+
s.args = [
284+
node_name,
285+
node_addr,
286+
cluster_ip_nodes,
287+
ENV["http_proxy"] || "",
288+
ENV["https_proxy"] || "",
289+
ENV["USE_RELEASE"] || "",
290+
ENV["CONTIV_CLUSTER_STORE"] || "etcd://localhost:2379",
291+
ENV["CONTIV_DOCKER_VERSION"] || docker_version,
292+
ENV['CONTIV_NODE_OS'] || "",
293+
*ENV['CONTIV_ENV'],
294+
]
281295
end
282296
node.vm.provision "shell", run: "always" do |s|
283297
s.inline = provision_common_always

scripts/docker-tcp.socket

-10
This file was deleted.

scripts/docker.service

-16
This file was deleted.

scripts/docker.service.consul

-16
This file was deleted.

0 commit comments

Comments
 (0)