From 338b33f3f4037037549cfb21ad1528c1cf643279 Mon Sep 17 00:00:00 2001 From: Omar Jarjur Date: Wed, 18 May 2016 10:02:33 -0700 Subject: [PATCH] Enable using gcr.io as a Docker registry mirror. This only affects clusters running under GCE. --- cluster/common.sh | 1 + cluster/gce/config-default.sh | 3 +++ cluster/gce/config-test.sh | 3 +++ cluster/gce/configure-vm.sh | 7 +++++++ cluster/gce/util.sh | 4 ++++ 5 files changed, 18 insertions(+) diff --git a/cluster/common.sh b/cluster/common.sh index 983b707bab..d190521797 100755 --- a/cluster/common.sh +++ b/cluster/common.sh @@ -482,6 +482,7 @@ SERVICE_CLUSTER_IP_RANGE: $(yaml-quote ${SERVICE_CLUSTER_IP_RANGE}) KUBERNETES_MASTER_NAME: $(yaml-quote ${MASTER_NAME}) ALLOCATE_NODE_CIDRS: $(yaml-quote ${ALLOCATE_NODE_CIDRS:-false}) ENABLE_CLUSTER_MONITORING: $(yaml-quote ${ENABLE_CLUSTER_MONITORING:-none}) +DOCKER_REGISTRY_MIRROR_URL: $(yaml-quote ${DOCKER_REGISTRY_MIRROR_URL:-}) ENABLE_L7_LOADBALANCING: $(yaml-quote ${ENABLE_L7_LOADBALANCING:-none}) ENABLE_CLUSTER_LOGGING: $(yaml-quote ${ENABLE_CLUSTER_LOGGING:-false}) ENABLE_CLUSTER_UI: $(yaml-quote ${ENABLE_CLUSTER_UI:-false}) diff --git a/cluster/gce/config-default.sh b/cluster/gce/config-default.sh index 4b2a7aa75b..bde1f8dfc5 100755 --- a/cluster/gce/config-default.sh +++ b/cluster/gce/config-default.sh @@ -61,6 +61,9 @@ POLL_SLEEP_INTERVAL="${POLL_SLEEP_INTERVAL:-3}" SERVICE_CLUSTER_IP_RANGE="${SERVICE_CLUSTER_IP_RANGE:-10.0.0.0/16}" # formerly PORTAL_NET ALLOCATE_NODE_CIDRS=true +# When set to true, Docker Cache is enabled by default as part of the cluster bring up. +ENABLE_DOCKER_REGISTRY_CACHE=true + # Optional: Deploy a L7 loadbalancer controller to fulfill Ingress requests: # glbc - CE L7 Load Balancer Controller ENABLE_L7_LOADBALANCING="${KUBE_ENABLE_L7_LOADBALANCING:-glbc}" diff --git a/cluster/gce/config-test.sh b/cluster/gce/config-test.sh index 67bb2ec6e9..dc700a56a2 100755 --- a/cluster/gce/config-test.sh +++ b/cluster/gce/config-test.sh @@ -62,6 +62,9 @@ EXTRA_DOCKER_OPTS="${EXTRA_DOCKER_OPTS:-}" POLL_SLEEP_INTERVAL=3 SERVICE_CLUSTER_IP_RANGE="10.0.0.0/16" # formerly PORTAL_NET +# When set to true, Docker Cache is enabled by default as part of the cluster bring up. +ENABLE_DOCKER_REGISTRY_CACHE=true + # Optional: Deploy a L7 loadbalancer controller to fulfill Ingress requests: # glbc - CE L7 Load Balancer Controller ENABLE_L7_LOADBALANCING="${KUBE_ENABLE_L7_LOADBALANCING:-glbc}" diff --git a/cluster/gce/configure-vm.sh b/cluster/gce/configure-vm.sh index 066b6fe9f3..39578fbe48 100755 --- a/cluster/gce/configure-vm.sh +++ b/cluster/gce/configure-vm.sh @@ -898,6 +898,13 @@ function node-docker-opts() { if [[ -n "${EXTRA_DOCKER_OPTS-}" ]]; then DOCKER_OPTS="${DOCKER_OPTS:-} ${EXTRA_DOCKER_OPTS}" fi + + # Decide whether to enable a docker registry mirror. This is taken from + # the "kube-env" metadata value. + if [[ -n "${DOCKER_REGISTRY_MIRROR_URL:-}" ]]; then + echo "Enable docker registry mirror at: ${DOCKER_REGISTRY_MIRROR_URL}" + DOCKER_OPTS="${DOCKER_OPTS:-} --registry-mirror=${DOCKER_REGISTRY_MIRROR_URL}" + fi } function salt-grains() { diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index aa56119dfa..e983119256 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -193,6 +193,10 @@ function set-preferred-region() { else KUBE_ADDON_REGISTRY="gcr.io/google_containers" fi + + if [[ "${ENABLE_DOCKER_REGISTRY_CACHE:-}" == "true" ]]; then + DOCKER_REGISTRY_MIRROR_URL="https://${preferred}-mirror.gcr.io" + fi } # Take the local tar files and upload them to Google Storage. They will then be