Skip to content

Commit

Permalink
refactor image builds (#2818)
Browse files Browse the repository at this point in the history
* refactor image builds

* do not build no-avx512 images
  • Loading branch information
zhangzujian committed May 19, 2023
1 parent a7fd9dd commit 486c61a
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 219 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-arm64-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ jobs:
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker tag kubeovn/kube-ovn:$TAG kubeovn/kube-ovn:$TAG-arm
docker tag kubeovn/kube-ovn:$TAG kubeovn/kube-ovn-dev:$COMMIT-arm
docker tag kubeovn/kube-ovn:$TAG-debug kubeovn/kube-ovn:$TAG-debug-arm
docker tag kubeovn/vpc-nat-gateway:$TAG kubeovn/vpc-nat-gateway:$TAG-arm
docker tag kubeovn/vpc-nat-gateway:$TAG kubeovn/vpc-nat-gateway-dev:$COMMIT-arm
docker images
docker push kubeovn/kube-ovn:$TAG-arm
docker push kubeovn/kube-ovn:$TAG-debug-arm
docker push kubeovn/kube-ovn-dev:$COMMIT-arm
docker push kubeovn/vpc-nat-gateway:$TAG-arm
docker push kubeovn/vpc-nat-gateway-dev:$COMMIT-arm
7 changes: 4 additions & 3 deletions .github/workflows/build-kube-ovn-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ jobs:
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker images
docker push kubeovn/kube-ovn-base:$TAG-amd64
docker push kubeovn/kube-ovn-base:$TAG-amd64-no-avx512
docker push kubeovn/kube-ovn-base:$TAG-debug-amd64
docker push kubeovn/kube-ovn-base:$TAG-arm64
docker push kubeovn/kube-ovn-base:$TAG-debug-arm64
docker manifest create kubeovn/kube-ovn-base:$TAG kubeovn/kube-ovn-base:$TAG-amd64 kubeovn/kube-ovn-base:$TAG-arm64
docker manifest push kubeovn/kube-ovn-base:$TAG
docker manifest create kubeovn/kube-ovn-base:$TAG-no-avx512 kubeovn/kube-ovn-base:$TAG-amd64-no-avx512
docker manifest push kubeovn/kube-ovn-base:$TAG-no-avx512
docker manifest create kubeovn/kube-ovn-base:$TAG-debug kubeovn/kube-ovn-base:$TAG-debug-amd64 kubeovn/kube-ovn-base:$TAG-debug-arm64
docker manifest push kubeovn/kube-ovn-base:$TAG-debug
28 changes: 0 additions & 28 deletions .github/workflows/build-kube-ovn-debug.yaml

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/build-x86-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
if [ ${{ needs.build-kube-ovn-base.outputs.build-base || 0 }} = 1 ]; then
TAG=$(cat VERSION)
docker tag kubeovn/kube-ovn-base:$TAG-amd64 kubeovn/kube-ovn-base:$TAG
docker tag kubeovn/kube-ovn-base:$TAG-amd64-no-avx512 kubeovn/kube-ovn-base:$TAG-no-avx512
docker tag kubeovn/kube-ovn-base:$TAG-debug-amd64 kubeovn/kube-ovn-base:$TAG-debug
make build-kube-ovn
else
make image-kube-ovn
Expand Down Expand Up @@ -1633,6 +1633,7 @@ jobs:
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker tag kubeovn/kube-ovn:$TAG kubeovn/kube-ovn-dev:$COMMIT-x86
docker tag kubeovn/kube-ovn:$TAG kubeovn/kube-ovn:$TAG-x86
docker tag kubeovn/kube-ovn:$TAG-debug kubeovn/kube-ovn:$TAG-debug-x86
docker tag kubeovn/vpc-nat-gateway:$TAG kubeovn/vpc-nat-gateway-dev:$COMMIT-x86
docker tag kubeovn/vpc-nat-gateway:$TAG kubeovn/vpc-nat-gateway:$TAG-x86
docker tag kubeovn/centos7-compile:$TAG kubeovn/centos7-compile-dev:$TAG-x86
Expand All @@ -1641,8 +1642,8 @@ jobs:
# docker tag kubeovn/centos8-compile:$TAG kubeovn/centos8-compile:$TAG-x86
docker images
docker push kubeovn/kube-ovn:$TAG-x86
docker push kubeovn/kube-ovn:$TAG-no-avx512
docker push kubeovn/kube-ovn-dev:$COMMIT-x86
docker push kubeovn/kube-ovn:$TAG-debug-x86
docker push kubeovn/vpc-nat-gateway:$TAG-x86
docker push kubeovn/vpc-nat-gateway-dev:$COMMIT-x86
docker push kubeovn/centos7-compile:$TAG-x86
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ jobs:
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker pull kubeovn/kube-ovn:$TAG-x86
docker pull kubeovn/kube-ovn:$TAG-arm
docker pull kubeovn/kube-ovn:$TAG-debug-x86
docker pull kubeovn/kube-ovn:$TAG-debug-arm
docker manifest create kubeovn/kube-ovn:$TAG kubeovn/kube-ovn:$TAG-x86 kubeovn/kube-ovn:$TAG-arm
docker manifest create kubeovn/kube-ovn:$TAG-debug kubeovn/kube-ovn:$TAG-debug-x86 kubeovn/kube-ovn:$TAG-debug-arm
docker manifest push kubeovn/kube-ovn:$TAG
docker manifest push kubeovn/kube-ovn:$TAG-debug
docker pull kubeovn/vpc-nat-gateway:$TAG-x86
docker pull kubeovn/vpc-nat-gateway:$TAG-arm
Expand Down
35 changes: 21 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include Makefile.e2e
REGISTRY = kubeovn
DEV_TAG = dev
RELEASE_TAG = $(shell cat VERSION)
DEBUG_TAG = $(shell cat VERSION)-debug
VERSION = $(shell echo $${VERSION:-$(RELEASE_TAG)})
COMMIT = git-$(shell git rev-parse --short HEAD)
DATE = $(shell date +"%Y-%m-%d_%H:%M:%S")
Expand Down Expand Up @@ -82,13 +83,17 @@ build-go-arm:

.PHONY: build-kube-ovn
build-kube-ovn: build-go
docker build -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) -f dist/images/Dockerfile dist/images/
docker build -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG)-no-avx512 -f dist/images/Dockerfile.no-avx512 dist/images/
docker build -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) --build-arg VERSION=$(RELEASE_TAG) -f dist/images/Dockerfile dist/images/
docker build -t $(REGISTRY)/kube-ovn:$(DEBUG_TAG) --build-arg BASE_TAG=$(DEBUG_TAG) -f dist/images/Dockerfile dist/images/
docker build -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG)-dpdk -f dist/images/Dockerfile.dpdk dist/images/

.PHONY: build-dev
build-dev: build-go
docker build -t $(REGISTRY)/kube-ovn:$(DEV_TAG) -f dist/images/Dockerfile dist/images/
docker build -t $(REGISTRY)/kube-ovn:$(DEV_TAG) --build-arg VERSION=$(RELEASE_TAG) -f dist/images/Dockerfile dist/images/

.PHONY: build-debug
build-debug: build-go
docker build -t $(REGISTRY)/kube-ovn:$(DEBUG_TAG) --build-arg BASE_TAG=$(DEBUG_TAG) -f dist/images/Dockerfile dist/images/

.PHONY: build-dpdk
build-dpdk:
Expand All @@ -97,7 +102,7 @@ build-dpdk:
.PHONY: base-amd64
base-amd64:
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64 -o type=docker -f dist/images/Dockerfile.base dist/images/
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 --build-arg NO_AVX512=true -t $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64-no-avx512 -o type=docker -f dist/images/Dockerfile.base dist/images/
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 --build-arg DEBUG=true -t $(REGISTRY)/kube-ovn-base:$(DEBUG_TAG)-amd64 -o type=docker -f dist/images/Dockerfile.base dist/images/

.PHONY: base-amd64-dpdk
base-amd64-dpdk:
Expand All @@ -106,17 +111,14 @@ base-amd64-dpdk:
.PHONY: base-arm64
base-arm64:
docker buildx build --platform linux/arm64 --build-arg ARCH=arm64 -t $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-arm64 -o type=docker -f dist/images/Dockerfile.base dist/images/
docker buildx build --platform linux/arm64 --build-arg ARCH=arm64 --build-arg DEBUG=true -t $(REGISTRY)/kube-ovn-base:$(DEBUG_TAG)-arm64 -o type=docker -f dist/images/Dockerfile.base dist/images/

.PHONY: image-kube-ovn
image-kube-ovn: build-go
docker buildx build --platform linux/amd64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --platform linux/amd64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG)-no-avx512 -o type=docker -f dist/images/Dockerfile.no-avx512 dist/images/
docker buildx build --platform linux/amd64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) --build-arg VERSION=$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --platform linux/amd64 -t $(REGISTRY)/kube-ovn:$(DEBUG_TAG) --build-arg BASE_TAG=$(DEBUG_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --platform linux/amd64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG)-dpdk -o type=docker -f dist/images/Dockerfile.dpdk dist/images/

.PHONY: image-debug
image-debug: build-go
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn:debug -o type=docker -f dist/images/Dockerfile.debug dist/images/

.PHONY: image-vpc-nat-gateway
image-vpc-nat-gateway:
docker buildx build --platform linux/amd64 -t $(REGISTRY)/vpc-nat-gateway:$(RELEASE_TAG) -o type=docker -f dist/images/vpcnatgateway/Dockerfile dist/images/vpcnatgateway
Expand All @@ -135,7 +137,8 @@ release: lint image-kube-ovn image-vpc-nat-gateway image-centos-compile

.PHONY: release-arm
release-arm: build-go-arm
docker buildx build --platform linux/arm64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --platform linux/arm64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) --build-arg VERSION=$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --platform linux/arm64 -t $(REGISTRY)/kube-ovn:$(DEBUG_TAG) --build-arg BASE_TAG=$(DEBUG_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --platform linux/arm64 -t $(REGISTRY)/vpc-nat-gateway:$(RELEASE_TAG) -o type=docker -f dist/images/vpcnatgateway/Dockerfile dist/images/vpcnatgateway

.PHONY: push-dev
Expand All @@ -148,7 +151,7 @@ push-release: release

.PHONY: tar-kube-ovn
tar-kube-ovn:
docker save $(REGISTRY)/kube-ovn:$(RELEASE_TAG) $(REGISTRY)/kube-ovn:$(RELEASE_TAG)-no-avx512 -o kube-ovn.tar
docker save $(REGISTRY)/kube-ovn:$(RELEASE_TAG) $(REGISTRY)/kube-ovn:$(DEBUG_TAG) -o kube-ovn.tar

.PHONY: tar-vpc-nat-gateway
tar-vpc-nat-gateway:
Expand All @@ -164,15 +167,15 @@ tar: tar-kube-ovn tar-vpc-nat-gateway tar-centos-compile

.PHONY: base-tar-amd64
base-tar-amd64:
docker save $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64 $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64-no-avx512 -o image-amd64.tar
docker save $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64 $(REGISTRY)/kube-ovn-base:$(DEBUG_TAG)-amd64 -o image-amd64.tar

.PHONY: base-tar-amd64-dpdk
base-tar-amd64-dpdk:
docker save $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-amd64-dpdk -o image-amd64-dpdk.tar

.PHONY: base-tar-arm64
base-tar-arm64:
docker save $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-arm64 -o image-arm64.tar
docker save $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-arm64 $(REGISTRY)/kube-ovn-base:$(DEBUG_TAG)-arm64 -o image-arm64.tar

define docker_ensure_image_exists
if ! docker images --format "{{.Repository}}:{{.Tag}}" | grep "^$(1)$$" >/dev/null; then \
Expand Down Expand Up @@ -421,6 +424,10 @@ kind-install: kind-load-image
kind-install-dev:
@VERSION=$(DEV_TAG) $(MAKE) kind-install

.PHONY: kind-install-debug
kind-install-debug:
@VERSION=$(DEBUG_TAG) $(MAKE) kind-install

.PHONY: kind-install-ipv4
kind-install-ipv4: kind-install-overlay-ipv4

Expand Down
4 changes: 3 additions & 1 deletion dist/images/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# syntax = docker/dockerfile:experimental
FROM kubeovn/kube-ovn-base:v1.12.0
ARG VERSION
ARG BASE_TAG=$VERSION
FROM kubeovn/kube-ovn-base:$BASE_TAG

COPY *.sh /kube-ovn/
COPY kubectl-ko /kube-ovn/kubectl-ko
Expand Down
16 changes: 8 additions & 8 deletions dist/images/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
FROM ubuntu:22.04 as ovs-builder

ARG ARCH
ARG NO_AVX512=false
ARG DEBIAN_FRONTEND=noninteractive
ENV SRC_DIR='/usr/src'

Expand All @@ -22,9 +21,7 @@ RUN cd /usr/src/ && \
# ovsdb-tool: add optional server id parameter for "join-cluster" command
curl -s https://github.com/kubeovn/ovs/commit/ebf61515da71fa2e23125a92859fbdb96dcbffe7.patch | git apply && \
# Add jitter parameter patch for netem qos
curl -s https://github.com/kubeovn/ovs/commit/2eaaf89fbf3ee2172719ed10d045fd79900edc8e.patch | git apply && \
# compile without avx512
if [ "$ARCH" = "amd64" -a "$NO_AVX512" = "true" ]; then curl -s https://github.com/kubeovn/ovs/commit/b0974433b39d4ddef71b88ee0bb79ce41fa79640.patch | git apply; fi
curl -s https://github.com/kubeovn/ovs/commit/2eaaf89fbf3ee2172719ed10d045fd79900edc8e.patch | git apply

RUN cd /usr/src/ && git clone -b branch-22.12 --depth=1 https://github.com/ovn-org/ovn.git && \
cd ovn && \
Expand Down Expand Up @@ -65,19 +62,21 @@ RUN cd /usr/src/ovn && \
OVSDIR=/usr/src/ovs EXTRA_CONFIGURE_OPTS=$CONFIGURE_OPTS DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary

RUN mkdir /packages/ && \
cp /usr/src/openvswitch-*.deb /packages && \
cp /usr/src/python3-openvswitch*.deb /packages && \
cp /usr/src/ovn-*.deb /packages && \
cd /packages && rm -f *source* *dbg* *doc* *datapath* *docker* *vtep* *test* *dev*
cp /usr/src/openvswitch-*deb /packages && \
cp /usr/src/python3-openvswitch*deb /packages && \
cp /usr/src/ovn-*deb /packages && \
cd /packages && rm -f *source* *doc* *datapath* *docker* *vtep* *test* *dev*

FROM ubuntu:22.04

ARG DEBUG=false
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y && apt install ca-certificates python3 hostname libunwind8 netbase \
ethtool iproute2 ncat libunbound-dev procps libatomic1 kmod iptables python3-netifaces python3-sortedcontainers \
tcpdump ipset curl uuid-runtime openssl inetutils-ping arping ndisc6 \
logrotate dnsutils net-tools strongswan strongswan-pki libcharon-extra-plugins \
libcharon-extauth-plugins libstrongswan-extra-plugins libstrongswan-standard-plugins -y --no-install-recommends && \
if [ "${DEBUG}" = "true" ]; then apt install -y --no-install-recommends valgrind; fi && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /etc/localtime

Expand All @@ -98,6 +97,7 @@ RUN curl -L https://dl.k8s.io/${KUBE_VERSION}/kubernetes-client-linux-${ARCH}.ta
RUN --mount=type=bind,target=/packages,from=ovs-builder,source=/packages \
dpkg -i /packages/openvswitch-*.deb /packages/python3-openvswitch*.deb && \
dpkg -i --ignore-depends=openvswitch-switch,openvswitch-common /packages/ovn-*.deb && \
if [ "${DEBUG}" = "true" ]; then dpkg -i --ignore-depends=openvswitch-switch,openvswitch-common /packages/*.ddeb; fi && \
rm -rf /var/lib/openvswitch/pki/

ENV BFDD_VERSION="v0.5.4"
Expand Down
Loading

0 comments on commit 486c61a

Please sign in to comment.