From d6be2985cafb5ebabdef5017af268199cfb0697e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Meireles?= Date: Tue, 10 Mar 2015 17:10:32 +0000 Subject: [PATCH 1/2] Add Docker caching support to CoreOS' clusters. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a more idiomatic take on #4378. as a bonus, and to be nice on resources, an ultra lightweight docker-registry container is consumed. Signed-off-by: António Meireles --- .../aws/cloud-configs/master.yaml | 33 +++++++++++++++ .../aws/cloud-configs/node.yaml | 19 +++------ .../coreos/cloud-configs/master.yaml | 33 +++++++++++++++ .../coreos/cloud-configs/node.yaml | 21 +++------- .../coreos/cloud-configs/standalone.yaml | 40 ++++++++++++++----- 5 files changed, 106 insertions(+), 40 deletions(-) diff --git a/docs/getting-started-guides/aws/cloud-configs/master.yaml b/docs/getting-started-guides/aws/cloud-configs/master.yaml index 0fefe1d4c85eb..cd5d0ce35b54d 100644 --- a/docs/getting-started-guides/aws/cloud-configs/master.yaml +++ b/docs/getting-started-guides/aws/cloud-configs/master.yaml @@ -104,6 +104,39 @@ coreos: ExecStartPre=/usr/bin/chmod +x /opt/bin/flanneld ExecStartPre=-/usr/bin/etcdctl mk /coreos.com/network/config '{"Network":"10.244.0.0/16", "Backend": {"Type": "vxlan"}}' ExecStart=/opt/bin/flanneld + - name: docker-cache.service + command: start + content: | + [Unit] + Description=Docker cache proxy + Requires=early-docker.service + After=early-docker.service + Before=early-docker.target + + [Service] + Restart=always + TimeoutStartSec=0 + RestartSec=5 + Environment="TMPDIR=/var/tmp/" + Environment="DOCKER_HOST=unix:///var/run/early-docker.sock" + ExecStartPre=-/usr/bin/docker kill docker-registry + ExecStartPre=-/usr/bin/docker rm docker-registry + ExecStartPre=/usr/bin/docker pull quay.io/devops/docker-registry:latest + ExecStart=/usr/bin/docker run --rm --net host --name docker-registry \ + -e STANDALONE=false \ + -e MIRROR_SOURCE=https://registry-1.docker.io \ + -e MIRROR_SOURCE_INDEX=https://index.docker.io \ + -e MIRROR_TAGS_CACHE_TTL=1800 \ + quay.io/devops/docker-registry:latest + - name: docker.service + drop-ins: + - name: 51-docker-mirror.conf + content: | + [Unit] + Requires=docker-cache.service + After=docker-cache.service + [Service] + Environment=DOCKER_OPTS='--registry-mirror=http://$private_ipv4:5000' - name: kube-apiserver.service command: start content: | diff --git a/docs/getting-started-guides/aws/cloud-configs/node.yaml b/docs/getting-started-guides/aws/cloud-configs/node.yaml index e7f5fb6302d13..de0b0d4e65b53 100644 --- a/docs/getting-started-guides/aws/cloud-configs/node.yaml +++ b/docs/getting-started-guides/aws/cloud-configs/node.yaml @@ -34,20 +34,11 @@ coreos: ExecStart=/opt/bin/flanneld -etcd-endpoints http://:4001 - name: docker.service command: start - content: | - [Unit] - After=flannel.service - Wants=flannel.service - Description=Docker Application Container Engine - Documentation=http://docs.docker.io - - [Service] - EnvironmentFile=/run/flannel/subnet.env - ExecStartPre=/bin/mount --make-rprivate / - ExecStart=/usr/bin/docker -d --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU} -s=overlay -H fd:// - - [Install] - WantedBy=multi-user.target + drop-ins: + - name: 51-docker-mirror.conf + content: | + [Service] + Environment=DOCKER_OPTS='--registry-mirror=http://:5000' - name: setup-network-environment.service command: start content: | diff --git a/docs/getting-started-guides/coreos/cloud-configs/master.yaml b/docs/getting-started-guides/coreos/cloud-configs/master.yaml index ffbd5303d4142..1f57d74c328b3 100644 --- a/docs/getting-started-guides/coreos/cloud-configs/master.yaml +++ b/docs/getting-started-guides/coreos/cloud-configs/master.yaml @@ -104,6 +104,39 @@ coreos: ExecStartPre=/usr/bin/chmod +x /opt/bin/flanneld ExecStartPre=-/usr/bin/etcdctl mk /coreos.com/network/config '{"Network":"10.244.0.0/16", "Backend": {"Type": "vxlan"}}' ExecStart=/opt/bin/flanneld + - name: docker-cache.service + command: start + content: | + [Unit] + Description=Docker cache proxy + Requires=early-docker.service + After=early-docker.service + Before=early-docker.target + + [Service] + Restart=always + TimeoutStartSec=0 + RestartSec=5 + Environment="TMPDIR=/var/tmp/" + Environment="DOCKER_HOST=unix:///var/run/early-docker.sock" + ExecStartPre=-/usr/bin/docker kill docker-registry + ExecStartPre=-/usr/bin/docker rm docker-registry + ExecStartPre=/usr/bin/docker pull quay.io/devops/docker-registry:latest + ExecStart=/usr/bin/docker run --rm --net host --name docker-registry \ + -e STANDALONE=false \ + -e MIRROR_SOURCE=https://registry-1.docker.io \ + -e MIRROR_SOURCE_INDEX=https://index.docker.io \ + -e MIRROR_TAGS_CACHE_TTL=1800 \ + quay.io/devops/docker-registry:latest + - name: docker.service + drop-ins: + - name: 51-docker-mirror.conf + content: | + [Unit] + Requires=docker-cache.service + After=docker-cache.service + [Service] + Environment=DOCKER_OPTS='--registry-mirror=http://$private_ipv4:5000' - name: kube-apiserver.service command: start content: | diff --git a/docs/getting-started-guides/coreos/cloud-configs/node.yaml b/docs/getting-started-guides/coreos/cloud-configs/node.yaml index 39d166806a850..a8391dfbe0ff4 100644 --- a/docs/getting-started-guides/coreos/cloud-configs/node.yaml +++ b/docs/getting-started-guides/coreos/cloud-configs/node.yaml @@ -22,7 +22,7 @@ coreos: command: start content: | [Unit] - After=network-online.target + After=network-online.target Wants=network-online.target Description=flannel is an etcd backed overlay network for containers @@ -34,20 +34,11 @@ coreos: ExecStart=/opt/bin/flanneld -etcd-endpoints http://:4001 - name: docker.service command: start - content: | - [Unit] - After=flannel.service - Wants=flannel.service - Description=Docker Application Container Engine - Documentation=http://docs.docker.io - - [Service] - EnvironmentFile=/run/flannel/subnet.env - ExecStartPre=/bin/mount --make-rprivate / - ExecStart=/usr/bin/docker -d --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU} -s=overlay -H fd:// - - [Install] - WantedBy=multi-user.target + drop-ins: + - name: 51-docker-mirror.conf + content: | + [Service] + Environment=DOCKER_OPTS='--registry-mirror=http://:5000' - name: setup-network-environment.service command: start content: | diff --git a/docs/getting-started-guides/coreos/cloud-configs/standalone.yaml b/docs/getting-started-guides/coreos/cloud-configs/standalone.yaml index 049715cc1f6b4..58508bafa1de7 100644 --- a/docs/getting-started-guides/coreos/cloud-configs/standalone.yaml +++ b/docs/getting-started-guides/coreos/cloud-configs/standalone.yaml @@ -49,22 +49,40 @@ coreos: ExecStartPre=/usr/bin/chmod +x /opt/bin/flanneld ExecStartPre=-/usr/bin/etcdctl mk /coreos.com/network/config '{"Network":"10.244.0.0/16", "Backend": {"Type": "vxlan"}}' ExecStart=/opt/bin/flanneld - - name: docker.service + - name: docker-cache.service command: start content: | [Unit] - After=flannel.service - Wants=flannel.service - Description=Docker Application Container Engine - Documentation=http://docs.docker.io + Description=Docker cache proxy + Requires=early-docker.service + After=early-docker.service + Before=early-docker.target [Service] - EnvironmentFile=/run/flannel/subnet.env - ExecStartPre=/bin/mount --make-rprivate / - ExecStart=/usr/bin/docker -d --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU} -s=overlay -H fd:// - - [Install] - WantedBy=multi-user.target + Restart=always + TimeoutStartSec=0 + RestartSec=5 + Environment="TMPDIR=/var/tmp/" + Environment="DOCKER_HOST=unix:///var/run/early-docker.sock" + ExecStartPre=-/usr/bin/docker kill docker-registry + ExecStartPre=-/usr/bin/docker rm docker-registry + ExecStartPre=/usr/bin/docker pull quay.io/devops/docker-registry:latest + ExecStart=/usr/bin/docker run --rm --net host --name docker-registry \ + -e STANDALONE=false \ + -e MIRROR_SOURCE=https://registry-1.docker.io \ + -e MIRROR_SOURCE_INDEX=https://index.docker.io \ + -e MIRROR_TAGS_CACHE_TTL=1800 \ + quay.io/devops/docker-registry:latest + - name: docker.service + command: start + drop-ins: + - name: 51-docker-mirror.conf + content: | + [Unit] + Requires=docker-cache.service + After=docker-cache.service + [Service] + Environment=DOCKER_OPTS='--registry-mirror=http://$private_ipv4:5000' - name: kube-apiserver.service command: start content: | From b5a50ca9da4b904be47d34554b45761faff78c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Meireles?= Date: Thu, 12 Mar 2015 12:16:18 +0000 Subject: [PATCH 2/2] simplify fleet invocation across CoreOS cloud-configs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: António Meireles --- .../aws/cloud-configs/master.yaml | 24 +++---------------- .../aws/cloud-configs/node.yaml | 15 +++--------- .../coreos/cloud-configs/master.yaml | 24 ++++--------------- .../coreos/cloud-configs/node.yaml | 15 +++--------- 4 files changed, 13 insertions(+), 65 deletions(-) diff --git a/docs/getting-started-guides/aws/cloud-configs/master.yaml b/docs/getting-started-guides/aws/cloud-configs/master.yaml index cd5d0ce35b54d..e96234f39343c 100644 --- a/docs/getting-started-guides/aws/cloud-configs/master.yaml +++ b/docs/getting-started-guides/aws/cloud-configs/master.yaml @@ -8,6 +8,9 @@ write_files: #! /usr/bin/bash until curl http://127.0.0.1:4001/v2/machines; do sleep 2; done coreos: + fleet: + etcd-servers: http://localhost:4001 + metadata: "role=master" units: - name: setup-network-environment.service command: start @@ -48,27 +51,6 @@ coreos: --snapshot true Restart=always RestartSec=10s - - name: fleet.socket - command: start - content: | - [Socket] - ListenStream=/var/run/fleet.sock - - name: fleet.service - command: start - content: | - [Unit] - Description=fleet daemon - Wants=etcd.service - After=etcd.service - Wants=fleet.socket - After=fleet.socket - - [Service] - Environment="FLEET_ETCD_SERVERS=http://127.0.0.1:4001" - Environment="FLEET_METADATA=role=master" - ExecStart=/usr/bin/fleetd - Restart=always - RestartSec=10s - name: etcd-waiter.service command: start content: | diff --git a/docs/getting-started-guides/aws/cloud-configs/node.yaml b/docs/getting-started-guides/aws/cloud-configs/node.yaml index de0b0d4e65b53..098a642bdd886 100644 --- a/docs/getting-started-guides/aws/cloud-configs/node.yaml +++ b/docs/getting-started-guides/aws/cloud-configs/node.yaml @@ -1,23 +1,14 @@ #cloud-config coreos: + fleet: + etcd-servers: http://:4001 + metadata: "role=node" units: - name: etcd.service mask: true - name: fleet.service command: start - content: | - [Unit] - Description=fleet daemon - Wants=fleet.socket - After=fleet.socket - - [Service] - Environment="FLEET_ETCD_SERVERS=http://:4001" - Environment="FLEET_METADATA=role=node" - ExecStart=/usr/bin/fleetd - Restart=always - RestartSec=10s - name: flannel.service command: start content: | diff --git a/docs/getting-started-guides/coreos/cloud-configs/master.yaml b/docs/getting-started-guides/coreos/cloud-configs/master.yaml index 1f57d74c328b3..5f8c71376a9b8 100644 --- a/docs/getting-started-guides/coreos/cloud-configs/master.yaml +++ b/docs/getting-started-guides/coreos/cloud-configs/master.yaml @@ -8,6 +8,9 @@ write_files: #! /usr/bin/bash until curl http://127.0.0.1:4001/v2/machines; do sleep 2; done coreos: + fleet: + etcd-servers: http://localhost:4001 + metadata: "role=master" units: - name: setup-network-environment.service command: start @@ -48,27 +51,8 @@ coreos: --snapshot true Restart=always RestartSec=10s - - name: fleet.socket - command: start - content: | - [Socket] - ListenStream=/var/run/fleet.sock - name: fleet.service command: start - content: | - [Unit] - Description=fleet daemon - Wants=etcd.service - After=etcd.service - Wants=fleet.socket - After=fleet.socket - - [Service] - Environment="FLEET_ETCD_SERVERS=http://127.0.0.1:4001" - Environment="FLEET_METADATA=role=master" - ExecStart=/usr/bin/fleetd - Restart=always - RestartSec=10s - name: etcd-waiter.service command: start content: | @@ -159,7 +143,7 @@ coreos: --logtostderr=true Restart=always RestartSec=10 - - name: kube-controller-manager.service + - name: kube-controller-manager.service command: start content: | [Unit] diff --git a/docs/getting-started-guides/coreos/cloud-configs/node.yaml b/docs/getting-started-guides/coreos/cloud-configs/node.yaml index a8391dfbe0ff4..0cd47e9c21091 100644 --- a/docs/getting-started-guides/coreos/cloud-configs/node.yaml +++ b/docs/getting-started-guides/coreos/cloud-configs/node.yaml @@ -1,23 +1,14 @@ #cloud-config coreos: + fleet: + etcd-servers: http://:4001 + metadata: "role=node" units: - name: etcd.service mask: true - name: fleet.service command: start - content: | - [Unit] - Description=fleet daemon - Wants=fleet.socket - After=fleet.socket - - [Service] - Environment="FLEET_ETCD_SERVERS=http://:4001" - Environment="FLEET_METADATA=role=node" - ExecStart=/usr/bin/fleetd - Restart=always - RestartSec=10s - name: flannel.service command: start content: |