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
This commit is contained in:
Thomas Hartland 2019-10-14 10:36:36 +02:00 committed by Spyros Trigazis
parent 4ccb27b057
commit 25c0f46169
5 changed files with 36 additions and 1 deletions

View File

@ -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/.*$

View File

@ -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"]

View File

@ -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

View File

@ -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

View File

@ -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