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

chore:Updated Dockerfile to include k8s crd manpulation scripts #840

Merged
merged 1 commit into from
Oct 14, 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
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ ARG TAG=main
ENV PATH="${PATH}:/usr/local/go/bin"
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/lib64/"

RUN mkdir -p /root/loxilb-io/loxilb
COPY . /root/loxilb-io/loxilb/

# Install loxilb related packages
RUN mkdir -p /opt/loxilb && \
mkdir -p /root/loxilb-io/loxilb/ && \
mkdir -p /usr/lib64/ && \
mkdir -p /opt/loxilb/cert/ && \
mkdir -p /etc/loxilb/certs/ && \
Expand Down Expand Up @@ -45,11 +47,12 @@ RUN mkdir -p /opt/loxilb && \
make && cp ./loxicmd /usr/local/sbin/loxicmd && cd - && rm -fr loxicmd && \
/usr/local/sbin/loxicmd completion bash > /etc/bash_completion.d/loxi_completion && \
# Install loxilb
git clone --recurse-submodules https://github.com/loxilb-io/loxilb /root/loxilb-io/loxilb/ && \
# git clone --recurse-submodules https://github.com/loxilb-io/loxilb /root/loxilb-io/loxilb/ && \
cd /root/loxilb-io/loxilb/ && git fetch --all --tags && git checkout $TAG && \
cd loxilb-ebpf && git fetch --all --tags && git checkout $TAG && cd .. \
go get . && if [ "$arch" = "arm64" ] ; then DOCKER_BUILDX_ARM64=true make; \
else make ;fi && cp loxilb-ebpf/utils/mkllb_bpffs.sh /usr/local/sbin/mkllb_bpffs && \
cp tools/k8s/mkllb-url /usr/local/sbin/mkllb-url && \
cp loxilb-ebpf/utils/mkllb_cgroup.sh /usr/local/sbin/mkllb_cgroup && \
cp /root/loxilb-io/loxilb/loxilb-ebpf/kernel/loxilb_dp_debug /usr/local/sbin/loxilb_dp_debug && \
cp /root/loxilb-io/loxilb/loxilb /usr/local/sbin/loxilb && \
Expand Down Expand Up @@ -89,14 +92,13 @@ ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/lib64/"

RUN apt-get update && apt-get install -y --no-install-recommends sudo wget \
libbsd-dev iproute2 tcpdump bridge-utils net-tools libllvm10 ca-certificates && \
wget https://raw.githubusercontent.com/loxilb-io/tools/refs/heads/main/k8s/mkllb-url.sh && \
chmod +x mkllb-url.sh && mv mkllb-url.sh /usr/local/sbin/mkllb-url && \
rm -rf /var/lib/apt/lists/* && apt clean

COPY --from=build /usr/lib64/libbpf* /usr/lib64/
COPY --from=build /usr/local/build/lib/* /usr/lib64
COPY --from=build /usr/local/go/bin /usr/local/go/bin
COPY --from=build /usr/local/sbin/mkllb_bpffs /usr/local/sbin/mkllb_bpffs
COPY --from=build /usr/local/sbin/mkllb-url /usr/local/sbin/mkllb-url
COPY --from=build /usr/local/sbin/mkllb_cgroup /usr/local/sbin/mkllb_cgroup
COPY --from=build /usr/local/sbin/loxilb_dp_debug /usr/local/sbin/loxilb_dp_debug
COPY --from=build /usr/local/sbin/loxicmd /usr/local/sbin/loxicmd
Expand Down
54 changes: 54 additions & 0 deletions tools/k8s/mkllb-url
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

usage() {
echo "Usage: $0 -a <ip-addr> -z <zone> -t <type>"
echo " $0 -a <ip-addr> -z <zone> -t <type> -d"
}

if [[ $# -gt 7 ]] || [[ $# -lt 6 ]]; then
usage
exit
fi

if [[ ! -f /usr/local/sbin/kubectl ]]; then
apt-get update && apt-get install -y curl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/sbin/kubectl
fi

addr=""
zone="llb"
utype="default"
cmd="apply"

while getopts a:z:t:x opt
do
case "${opt}" in
a) addr=${OPTARG};;
z) zone=${OPTARG};;
t) utype=${OPTARG};;
x) cmd="delete";;
?) usage;exit;;
esac
done

echo "============"
echo "Applying CRD"
echo "============"
echo addr $addr
echo zone $zone
echo utype $utype
echo cmd $cmd
echo "============"

cat <<EOF | kubectl ${cmd} -f -
apiVersion: "loxiurl.loxilb.io/v1"
kind: LoxiURL
metadata:
name: llb-${addr}
spec:
loxiURL: http://${addr}:11111
zone: llb
type: ${utype}
EOF
Loading