From 52b72538114fdf3de5b71ce399bb0992d2748d75 Mon Sep 17 00:00:00 2001 From: Kuo-tung Kao Date: Wed, 14 Oct 2015 16:19:45 +0800 Subject: [PATCH] add "registry" flag to "tools/build.py" With registry flag, build image using `tools/build.py --registry 172.22.2.81:4000` the image name looks like `172.22.2.81:4000/kollaglue/data` When user use kolla-ansible, user set `docker_registry` to `172.22.2.81:4000` in `/etc/kolla/globals.yml`. Build image using `tools/build.py -n abcd` the image name looks like `abcd/data` When user use kolla-ansible, user set `docker_namespace:` to `abcd` in `/etc/kolla/globals.yml`. build image using `tools/build.py -n abcd --registry 172.22.2.81:4000` the image name looks like `abcd/data` When user use kolla-ansible, user set `docker_namespace:` to `abcd` in `/etc/kolla/globals.yml`. user set `docker_registry` to `172.22.2.81:4000` in `/etc/kolla/globals.yml`. With the feature, it will reduce user confusing and mistaking. Change-Id: I18ac7a3ccec032888e35f5e9a79fc190760cc8a0 Closes-Bug: #1505056 --- doc/deploy-all-in-one-node.rst | 2 +- doc/image-building.rst | 10 ++++------ etc/kolla/kolla-build.conf | 2 ++ kolla/cmd/build.py | 12 ++++++++++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/doc/deploy-all-in-one-node.rst b/doc/deploy-all-in-one-node.rst index 04f62780da..b59bbb1b58 100644 --- a/doc/deploy-all-in-one-node.rst +++ b/doc/deploy-all-in-one-node.rst @@ -37,7 +37,7 @@ The guide assumes that you have build images using the following command. :: - tools/build.py -n 172.22.2.81:4000/kollaglue --base ubuntu --type source --push + tools/build.py --registry 172.22.2.81:4000 --base ubuntu --type source --push The IP, "172.22.2.81", is the host running private docker registry. To deploy a private docker registry, diff --git a/doc/image-building.rst b/doc/image-building.rst index ee18c153d0..d02c8322c7 100644 --- a/doc/image-building.rst +++ b/doc/image-building.rst @@ -56,14 +56,12 @@ want to push images to your dockerhub, change the namespace like: $ tools/build.py -n yourusername --push -To push images to local registry, change the namespace, too. If the ip -of the machine running local registry is ``172.22.2.81`` and the port -which local registry listens to is ``4000``, use the following command -to push images to local registry. +To push images to local registry, use ``--registry`` flag like the +following command: :: - tools/build.py --namespace 172.22.2.81:4000/kollaglue --push + tools/build.py --registry 172.22.2.81:4000 --push To trigger buid.py to pull images from local registry, the Docker configuration needs to be modified. See @@ -180,7 +178,7 @@ To build and push images to local registry, use the following command: :: - tools/build.py --namespace 172.22.2.81:4000/kollaglue --push + tools/build.py --registry 172.22.2.81:4000 --push Kolla-ansible with Local Registry +++++++++++++++++++++++++++++++++ diff --git a/etc/kolla/kolla-build.conf b/etc/kolla/kolla-build.conf index c4281248f2..dc3e20816f 100644 --- a/etc/kolla/kolla-build.conf +++ b/etc/kolla/kolla-build.conf @@ -42,6 +42,8 @@ # Path to custome file to be addded at end of Dockerfiles for final images #include_footer = /path/to/footer_file +# The registry host. The default registry host is Docker Hub. +#registry = None # Provide location of sources for source install builds. # Example: diff --git a/kolla/cmd/build.py b/kolla/cmd/build.py index e6e43dd700..55969c9bd2 100755 --- a/kolla/cmd/build.py +++ b/kolla/cmd/build.py @@ -225,7 +225,8 @@ def merge_args_and_config(settings_from_config_file): "keep": False, "push": False, "threads": 8, - "retries": 3 + "retries": 3, + "registry": None } defaults.update(settings_from_config_file.items('kolla-build')) parser.set_defaults(**defaults) @@ -285,6 +286,9 @@ def merge_args_and_config(settings_from_config_file): parser.add_argument('--template-only', help=("Don't build images. Generate Dockerfile only"), action='store_true') + parser.add_argument('--registry', + help=("the docker registry host"), + type=str) return vars(parser.parse_args()) @@ -294,7 +298,11 @@ class KollaWorker(object): self.base_dir = os.path.abspath(find_base_dir()) LOG.debug("Kolla base directory: " + self.base_dir) self.images_dir = os.path.join(self.base_dir, 'docker') - self.namespace = config['namespace'] + self.registry = config['registry'] + if self.registry: + self.namespace = self.registry + '/' + config['namespace'] + else: + self.namespace = config['namespace'] self.base = config['base'] self.base_tag = config['base_tag'] self.install_type = config['install_type']