Skip to content

Commit

Permalink
Add GoBGP client binary to antrea agent image
Browse files Browse the repository at this point in the history
Signed-off-by: Rajnish Kumar <rajnishk1@vmware.com>
  • Loading branch information
rajnkamr committed Aug 29, 2024
1 parent 29f947c commit 8a05cd4
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ANTCTL_BINARY_NAME ?= antctl
OVS_VERSION := $(shell head -n 1 build/images/deps/ovs-version)
GO_VERSION := $(shell head -n 1 build/images/deps/go-version)
CNI_BINARIES_VERSION := $(shell head -n 1 build/images/deps/cni-binaries-version)
BGP_VERSION := $(go list -m all | grep github.com/osrg/gobgp/v3 | cut -d " " -f2 | cut -c 2-)
GIT_HOOKS := $(shell find hack/git_client_side_hooks -type f -print)
DOCKER_NETWORK ?= default
TRIVY_TARGET_IMAGE ?=
Expand Down
23 changes: 22 additions & 1 deletion build/images/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@
# limitations under the License.

ARG BUILD_TAG

FROM ubuntu:22.04 AS bgp

ARG BGP_VERSION

RUN apt-get update && \
apt-get install -y --no-install-recommends wget ca-certificates

RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) pluginsArch='amd64' ;; \
armhf) pluginsArch='arm' ;; \
arm64) pluginsArch='arm64' ;; \
*) pluginsArch=''; echo >&2; echo >&2 "unsupported architecture '$dpkgArch'"; echo >&2 ; exit 1 ;; \
esac; \
mkdir -p /opt/bgp; \
wget -q -O - https://github.com/osrg/gobgp/releases/download/v$BGP_VERSION/gobgp_${BGP_VERSION}_linux_${pluginsArch}.tar.gz | tar xz -C /opt/bgp; \
find /opt/bgp -type f ! -name 'gobgp' -delete


FROM ubuntu:22.04 AS cni-binaries

ARG CNI_BINARIES_VERSION
Expand All @@ -22,7 +43,6 @@ RUN apt-get update && \

# Leading dot is required for the tar command below
ENV CNI_PLUGINS="./host-local ./loopback ./portmap ./bandwidth"

# Download containernetworking plugin binaries for the correct architecture
RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
Expand Down Expand Up @@ -57,3 +77,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends ipset jq inotif
/iptables-wrapper-installer.sh

COPY --from=cni-binaries /opt/cni/bin /opt/cni/bin
COPY --from=bgp /opt/bgp /opt/bgp
23 changes: 22 additions & 1 deletion build/images/base/Dockerfile.ubi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@
# limitations under the License.

ARG BUILD_TAG

FROM ubuntu:22.04 AS bgp

ARG BGP_VERSION

RUN apt-get update && \
apt-get install -y --no-install-recommends wget ca-certificates

RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) pluginsArch='amd64' ;; \
armhf) pluginsArch='arm' ;; \
arm64) pluginsArch='arm64' ;; \
*) pluginsArch=''; echo >&2; echo >&2 "unsupported architecture '$dpkgArch'"; echo >&2 ; exit 1 ;; \
esac; \
mkdir -p /opt/bgp; \
wget -q -O - https://github.com/osrg/gobgp/releases/download/v$BGP_VERSION/gobgp_${BGP_VERSION}_linux_${pluginsArch}.tar.gz | tar xz -C /opt/bgp; \
find /opt/bgp -type f ! -name 'gobgp' -delete

FROM ubuntu:22.04 AS cni-binaries

ARG CNI_BINARIES_VERSION
Expand All @@ -33,7 +53,7 @@ RUN set -eux; \
*) pluginsArch=''; echo >&2; echo >&2 "unsupported architecture '$dpkgArch'"; echo >&2 ; exit 1 ;; \
esac; \
mkdir -p /opt/cni/bin; \
wget -q -O - https://github.com/containernetworking/plugins/releases/download/$CNI_BINARIES_VERSION/cni-plugins-linux-${pluginsArch}-$CNI_BINARIES_VERSION.tgz | tar xz -C /opt/cni/bin $CNI_PLUGINS
wget -q -O - https://github.com/containernetworking/plugins/releases/download/$CNI_BINARIES_VERSION/cni-plugins-linux-${pluginsArch}-$CNI_BINARIES_VERSION.tgz | tar xz -C /opt/cni/bin $CNI_PLUGINS;

FROM antrea/openvswitch-ubi:${BUILD_TAG}

Expand All @@ -50,3 +70,4 @@ RUN yum install ipset jq yum-plugin-copr -y && \
yum remove yum-plugin-copr -y && yum clean all

COPY --from=cni-binaries /opt/cni/bin /opt/cni/bin
COPY --from=bgp /opt/bgp /opt/bgp
4 changes: 2 additions & 2 deletions build/images/base/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ fi
pushd $THIS_DIR > /dev/null

CNI_BINARIES_VERSION=$(head -n 1 ../deps/cni-binaries-version)
BGP_VERSION=$(go list -m all | grep github.com/osrg/gobgp/v3 | cut -d " " -f2 | cut -c 2-)
SURICATA_VERSION=$(head -n 1 ../deps/suricata-version)

BUILD_CACHE_TAG=$(../build-tag.sh)
Expand Down Expand Up @@ -152,8 +153,7 @@ fi
function docker_build_and_push() {
local image="$1"
local dockerfile="$2"
local build_args="--build-arg CNI_BINARIES_VERSION=$CNI_BINARIES_VERSION --build-arg SURICATA_VERSION=$SURICATA_VERSION --build-arg BUILD_TAG=$BUILD_TAG"
local cache_args=""
local build_args="--build-arg CNI_BINARIES_VERSION=$CNI_BINARIES_VERSION --build-arg BGP_VERSION=$BGP_VERSION --build-arg SURICATA_VERSION=$SURICATA_VERSION --build-arg BUILD_TAG=$BUILD_TAG"
if $PUSH; then
cache_args="$cache_args --cache-to type=registry,ref=$image-cache:$BUILD_CACHE_TAG,mode=max"
fi
Expand Down
1 change: 1 addition & 0 deletions hack/build-antrea-linux-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ fi

CNI_BINARIES_VERSION=$(head -n 1 build/images/deps/cni-binaries-version)
GO_VERSION=$(head -n 1 build/images/deps/go-version)
BGP_VERSION=$(go list -m all | grep github.com/osrg/gobgp/v3 | cut -d " " -f2 | cut -c 2-)

if [ "$BUILD_TAG" != "" ]; then
ARGS="$ARGS --build-tag $BUILD_TAG"
Expand Down

0 comments on commit 8a05cd4

Please sign in to comment.