Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: build ipv6-hp-bpf in pipeline #2769

Merged
merged 9 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .pipelines/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ stages:
name: "$(BUILD_POOL_NAME_DEFAULT)"
steps:
- script: |
make ipv6-hp-bpf-lib
make all-binaries-platforms
name: "BuildAllPlatformBinaries"
displayName: "Build all platform binaries"
Expand Down Expand Up @@ -249,6 +250,10 @@ stages:
name: cns
os: windows
os_version: ltsc2022
ipv6_hp_bpf_linux_amd64:
arch: amd64
name: ipv6-hp-bpf
os: linux
npm_linux_amd64:
arch: amd64
name: npm
Expand Down Expand Up @@ -289,6 +294,10 @@ stages:
arch: arm64
name: cns
os: linux
ipv6_hp_bpf_linux_arm64:
arch: arm64
name: ipv6-hp-bpf
os: linux
npm_linux_arm64:
arch: arm64
name: npm
Expand Down Expand Up @@ -362,6 +371,9 @@ stages:
name: cns
os_versions: ltsc2019 ltsc2022
platforms: linux/amd64 linux/arm64 windows/amd64
ipv6_hp_bpf:
name: ipv6-hp-bpf
platforms: linux/amd64 linux/arm64
npm:
name: npm
os_versions: ltsc2022
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ steps:
kubectl apply -f test/integration/manifests/cilium/v${DIR}/cilium-operator/files

export CILIUM_VERSION_TAG=${CILIUM_DUALSTACK_VERSION}
export IPV6_HP_BPF_VERSION=$(make ipv6-hp-bpf-version)
echo "install Cilium ${CILIUM_DUALSTACK_VERSION} onto Overlay Cluster"
envsubst '${CILIUM_VERSION_TAG},${CILIUM_IMAGE_REGISTRY}' < test/integration/manifests/cilium/v${DIR}/cilium-agent/templates/daemonset.yaml | kubectl apply -f -
envsubst '${CILIUM_VERSION_TAG},${CILIUM_IMAGE_REGISTRY},${IPV6_HP_BPF_VERSION}' < test/integration/manifests/cilium/v${DIR}/cilium-agent/templates/daemonset-dualstack.yaml | kubectl apply -f -
envsubst '${CILIUM_VERSION_TAG},${CILIUM_IMAGE_REGISTRY}' < test/integration/manifests/cilium/v${DIR}/cilium-operator/templates/deployment.yaml | kubectl apply -f -
kubectl get po -owide -A
name: "installCilium"
Expand Down
34 changes: 31 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ CNM_ARCHIVE_NAME = azure-vnet-cnm-$(GOOS)-$(GOARCH)-$(ACN_VERSION).$(ARCHIVE_EXT
CNS_ARCHIVE_NAME = azure-cns-$(GOOS)-$(GOARCH)-$(CNS_VERSION).$(ARCHIVE_EXT)
NPM_ARCHIVE_NAME = azure-npm-$(GOOS)-$(GOARCH)-$(NPM_VERSION).$(ARCHIVE_EXT)
AZURE_IPAM_ARCHIVE_NAME = azure-ipam-$(GOOS)-$(GOARCH)-$(AZURE_IPAM_VERSION).$(ARCHIVE_EXT)
IPV6_HP_BPF_ARCHIVE_NAME = ipv6-hp-bpf-$(GOOS)-$(GOARCH)-$(IPV6_HP_BPF_VERSION).$(ARCHIVE_EXT)

# Image info file names.
CNI_IMAGE_INFO_FILE = azure-cni-$(CNI_VERSION).txt
Expand All @@ -127,8 +128,8 @@ all-binaries-platforms: ## Make all platform binaries

# OS specific binaries/images
ifeq ($(GOOS),linux)
all-binaries: acncli azure-cni-plugin azure-cns azure-npm azure-ipam
all-images: npm-image cns-image cni-manager-image
all-binaries: acncli azure-cni-plugin azure-cns azure-npm azure-ipam ipv6-hp-bpf
all-images: npm-image cns-image cni-manager-image ipv6-hp-bpf-image
else
all-binaries: azure-cni-plugin azure-cns azure-npm
all-images:
Expand Down Expand Up @@ -185,7 +186,17 @@ azure-ipam-binary:
# Build the ipv6-hp-bpf binary.
ipv6-hp-bpf-binary:
cd $(IPV6_HP_BPF_DIR) && CGO_ENABLED=0 go generate ./...
cd $(IPV6_HP_BPF_DIR)/cmd/ipv6-hp-bpf && CGO_ENABLED=0 go build -v -o $(IPV6_HP_BPF_BUILD_DIR)$(EXE_EXT) -ldflags "-X main.version=$(IPV6_HP_BPF_VERSION)" -gcflags="-dwarflocationlists=true"
cd $(IPV6_HP_BPF_DIR)/cmd/ipv6-hp-bpf && CGO_ENABLED=0 go build -v -o $(IPV6_HP_BPF_BUILD_DIR)/ipv6-hp-bpf$(EXE_EXT) -ldflags "-X main.version=$(IPV6_HP_BPF_VERSION)" -gcflags="-dwarflocationlists=true"

# Libraries for ipv6-hp-bpf
ipv6-hp-bpf-lib:
ifeq ($(GOARCH),amd64)
sudo apt-get update && sudo apt-get install -y llvm clang linux-libc-dev linux-headers-generic libbpf-dev libc6-dev nftables iproute2 gcc-multilib
for dir in /usr/include/x86_64-linux-gnu/*; do sudo ln -sfn "$$dir" /usr/include/$$(basename "$$dir"); done
else ifeq ($(GOARCH),arm64)
sudo apt-get update && sudo apt-get install -y llvm clang linux-libc-dev linux-headers-generic libbpf-dev libc6-dev nftables iproute2 gcc-aarch64-linux-gnu
for dir in /usr/include/aarch64-linux-gnu/*; do sudo ln -sfn "$$dir" /usr/include/$$(basename "$$dir"); done
endif

# Build the Azure CNM binary.
cnm-binary:
Expand Down Expand Up @@ -623,6 +634,23 @@ azure-ipam-skopeo-archive: ## export tar archive of azure-ipam multiplat contain
IMAGE=$(AZURE_IPAM_IMAGE) \
TAG=$(AZURE_IPAM_VERSION)

ipv6-hp-bpf-manifest-build: ## build ipv6-hp-bpf multiplat container manifest.
$(MAKE) manifest-build \
PLATFORMS="$(PLATFORMS)" \
IMAGE=$(IPV6_HP_BPF_IMAGE) \
TAG=$(IPV6_HP_BPF_VERSION) \
OS_VERSIONS="$(OS_VERSIONS)"

ipv6-hp-bpf-manifest-push: ## push ipv6-hp-bpf multiplat container manifest
$(MAKE) manifest-push \
IMAGE=$(IPV6_HP_BPF_IMAGE) \
TAG=$(IPV6_HP_BPF_VERSION)

ipv6-hp-bpf-skopeo-archive: ## export tar archive of ipv6-hp-bpf multiplat container manifest.
$(MAKE) manifest-skopeo-archive \
IMAGE=$(IPV6_HP_BPF_IMAGE) \
TAG=$(IPV6_HP_BPF_VERSION)

cni-manifest-build: ## build cni multiplat container manifest.
$(MAKE) manifest-build \
PLATFORMS="$(PLATFORMS)" \
Expand Down
File renamed without changes.
45 changes: 29 additions & 16 deletions bpf-prog/ipv6-hp-bpf/linux.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,44 @@ FROM mcr.microsoft.com/oss/go/microsoft/golang:1.21 AS builder
ARG VERSION
ARG DEBUG
ARG OS
ARG ARCH
WORKDIR /bpf-prog/ipv6-hp-bpf
COPY ./bpf-prog/ipv6-hp-bpf .
COPY ./bpf-prog/ipv6-hp-bpf/cmd/ipv6-hp-bpf/*.go /bpf-prog/ipv6-hp-bpf/
COPY ./bpf-prog/ipv6-hp-bpf/include/helper.h /bpf-prog/ipv6-hp-bpf/include/helper.h
RUN apt-get update && apt-get install -y llvm clang linux-libc-dev linux-headers-generic libbpf-dev libc6-dev gcc-multilib nftables iproute2
RUN for dir in /usr/include/x86_64-linux-gnu/*; do ln -s "$dir" /usr/include/$(basename "$dir"); done
RUN apt-get update && apt-get install -y llvm clang linux-libc-dev linux-headers-generic libbpf-dev libc6-dev nftables iproute2
RUN mkdir -p /tmp/lib
RUN if [ "$ARCH" = "arm64" ]; then \
apt-get install -y gcc-aarch64-linux-gnu && \
ARCH=aarch64-linux-gnu && \
cp /lib/"$ARCH"/ld-linux-aarch64.so.1 /tmp/lib/ && \
for dir in /usr/include/"$ARCH"/*; do ln -s "$dir" /usr/include/$(basename "$dir"); done; \
elif [ "$ARCH" = "amd64" ]; then \
apt-get install -y gcc-multilib && \
ARCH=x86_64-linux-gnu && \
cp /lib/"$ARCH"/ld-linux-x86-64.so.2 /tmp/lib/ && \
for dir in /usr/include/"$ARCH"/*; do ln -s "$dir" /usr/include/$(basename "$dir"); done; \
fi && \
ln -sfn /usr/include/"$ARCH"/asm /usr/include/asm && \
cp /lib/"$ARCH"/libnftables.so.1 /tmp/lib/ && \
cp /lib/"$ARCH"/libedit.so.2 /tmp/lib/ && \
cp /lib/"$ARCH"/libc.so.6 /tmp/lib/ && \
cp /lib/"$ARCH"/libmnl.so.0 /tmp/lib/ && \
cp /lib/"$ARCH"/libnftnl.so.11 /tmp/lib/ && \
cp /lib/"$ARCH"/libxtables.so.12 /tmp/lib/ && \
cp /lib/"$ARCH"/libjansson.so.4 /tmp/lib/ && \
cp /lib/"$ARCH"/libgmp.so.10 /tmp/lib/ && \
cp /lib/"$ARCH"/libtinfo.so.6 /tmp/lib/ && \
cp /lib/"$ARCH"/libbsd.so.0 /tmp/lib/ && \
cp /lib/"$ARCH"/libmd.so.0 /tmp/lib/
ENV C_INCLUDE_PATH=/usr/include/bpf
RUN if [ "$DEBUG" = "true" ]; then echo "\n#define DEBUG" >> /bpf-prog/ipv6-hp-bpf/include/helper.h; fi
RUN GOOS=$OS CGO_ENABLED=0 go generate ./...
RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/ipv6-hp-bpf -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" .

FROM mcr.microsoft.com/cbl-mariner/distroless/minimal:2.0
FROM mcr.microsoft.com/cbl-mariner/distroless/minimal:2.0 AS final
COPY --from=builder /go/bin/ipv6-hp-bpf /ipv6-hp-bpf
COPY --from=builder /usr/sbin/nft /usr/sbin/nft
COPY --from=builder /sbin/ip /sbin/ip
COPY --from=builder /lib/x86_64-linux-gnu/libnftables.so.1 /lib/x86_64-linux-gnu/
COPY --from=builder /lib/x86_64-linux-gnu/libedit.so.2 /lib/x86_64-linux-gnu/
COPY --from=builder /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/
COPY --from=builder /lib/x86_64-linux-gnu/libmnl.so.0 /lib/x86_64-linux-gnu/
COPY --from=builder /lib/x86_64-linux-gnu/libnftnl.so.11 /lib/x86_64-linux-gnu/
COPY --from=builder /lib/x86_64-linux-gnu/libxtables.so.12 /lib/x86_64-linux-gnu/
COPY --from=builder /lib/x86_64-linux-gnu/libjansson.so.4 /lib/x86_64-linux-gnu/
COPY --from=builder /lib/x86_64-linux-gnu/libgmp.so.10 /lib/x86_64-linux-gnu/
COPY --from=builder /lib/x86_64-linux-gnu/libtinfo.so.6 /lib/x86_64-linux-gnu/
COPY --from=builder /lib/x86_64-linux-gnu/libbsd.so.0 /lib/x86_64-linux-gnu/
COPY --from=builder /lib64/ld-linux-x86-64.so.2 /lib64/
COPY --from=builder /lib/x86_64-linux-gnu/libmd.so.0 /lib/x86_64-linux-gnu/
CMD ["/ipv6-hp-bpf"]
COPY --from=builder /tmp/lib/* /lib
CMD ["/ipv6-hp-bpf"]
Loading
Loading