From 25c0f461695470183418b77f02ab12a09bf8d53d Mon Sep 17 00:00:00 2001 From: Thomas Hartland Date: Mon, 14 Oct 2019 10:36:36 +0200 Subject: [PATCH] Build cluster autoscaler container images Add Dockerfile and CI config for building cluster autoscaler container images specifically for magnum. The autoscaler is built with the build tag "magnum" so that only the magnum provider is included in the binary. This cuts the size of the image in half compared to building with all cloud providers. The container-build job in .zuul.yaml has to have its timeout increased, as the build time was already close to the timeout. Change-Id: Iecbae5866278afe1687a4533b71af60fce537a4a --- .zuul.yaml | 2 +- dockerfiles/cluster-autoscaler/Dockerfile | 15 +++++++++++++++ playbooks/container-builder-vars.yaml | 4 ++++ playbooks/container-builder.yaml | 13 +++++++++++++ playbooks/container-publish.yaml | 3 +++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 dockerfiles/cluster-autoscaler/Dockerfile diff --git a/.zuul.yaml b/.zuul.yaml index 008d42df41..daec323a4e 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -346,7 +346,7 @@ post-run: playbooks/container-builder-copy-logs.yaml roles: - zuul: openstack/openstack-zuul-jobs - timeout: 1200 + timeout: 1800 irrelevant-files: - ^.*\.rst$ - ^api-ref/.*$ diff --git a/dockerfiles/cluster-autoscaler/Dockerfile b/dockerfiles/cluster-autoscaler/Dockerfile new file mode 100644 index 0000000000..d91897862b --- /dev/null +++ b/dockerfiles/cluster-autoscaler/Dockerfile @@ -0,0 +1,15 @@ +FROM golang:1.12.10 as builder + +ARG AUTOSCALER_VERSION + +ENV GOPATH=/go + +WORKDIR $GOPATH/src/k8s.io/ +RUN git clone -b ${AUTOSCALER_VERSION} --single-branch http://github.com/kubernetes/autoscaler.git autoscaler +WORKDIR autoscaler/cluster-autoscaler +RUN CGO_ENABLED=0 GOOS=linux go build -o cluster-autoscaler --ldflags=-s --tags magnum + +FROM gcr.io/distroless/static:latest + +COPY --from=builder /go/src/k8s.io/autoscaler/cluster-autoscaler/cluster-autoscaler /cluster-autoscaler +CMD ["/cluster-autoscaler"] diff --git a/playbooks/container-builder-vars.yaml b/playbooks/container-builder-vars.yaml index 1688749814..6755478f0a 100644 --- a/playbooks/container-builder-vars.yaml +++ b/playbooks/container-builder-vars.yaml @@ -19,3 +19,7 @@ magnum_images: tag: train-dev helm_version: v2.12.3 + +cluster_autoscaler_versions: + - version: 1.15.2 + - version: 1.16.1 diff --git a/playbooks/container-builder.yaml b/playbooks/container-builder.yaml index 37e1bdd4e9..27c972b22c 100644 --- a/playbooks/container-builder.yaml +++ b/playbooks/container-builder.yaml @@ -105,3 +105,16 @@ HELM_VERSION: "{{ helm_version }}" push: no retries: 10 + + - name: "Build cluster-autoscaler image" + block: + - name: "Build {{ magnum_repository }}/cluster-autoscaler:v{{ item.version }}" + docker_image: + path: "{{ magnum_src_dir }}/dockerfiles/cluster-autoscaler" + name: "{{ magnum_repository }}/cluster-autoscaler" + tag: "v{{ item.version }}" + buildargs: + AUTOSCALER_VERSION: "cluster-autoscaler-{{ item.version }}" + push: no + with_items: "{{ cluster_autoscaler_versions }}" + retries: 10 diff --git a/playbooks/container-publish.yaml b/playbooks/container-publish.yaml index 95776e7946..368a9a68fa 100644 --- a/playbooks/container-publish.yaml +++ b/playbooks/container-publish.yaml @@ -30,3 +30,6 @@ retries: 10 - command: docker push {{ magnum_repository }}/helm-client:{{ helm_version }} retries: 10 + - command: docker push {{ magnum_repository }}/cluster-autoscaler:v{{ item.version }} + with_items: "{{ cluster_autoscaler_versions }}" + retries: 10