Skip to content

Commit

Permalink
feat: Add supports for dual-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
carezkh committed Jan 12, 2023
1 parent d7d5162 commit 4b04033
Show file tree
Hide file tree
Showing 13 changed files with 743 additions and 95 deletions.
8 changes: 6 additions & 2 deletions build/virt-prerunner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ RUN go mod download
COPY cmd/ cmd/
COPY pkg/ pkg/
RUN --mount=type=cache,target=/root/.cache/go-build go build -a cmd/virt-prerunner/main.go
RUN --mount=type=cache,target=/root/.cache/go-build go build -o rad -a cmd/route-advertisement-daemon/main.go

FROM alpine
FROM alpine:3.17

RUN apk add --no-cache curl screen dnsmasq cdrkit iptables iproute2 qemu-virtiofsd dpkg util-linux s6-overlay nmap-ncat
RUN apk add --no-cache curl screen dnsmasq kea-dhcp6 cdrkit iptables ip6tables iproute2 qemu-virtiofsd dpkg util-linux s6-overlay nmap-ncat

RUN set -eux; \
mkdir /var/lib/cloud-hypervisor; \
Expand All @@ -40,6 +41,7 @@ COPY build/virt-prerunner/cloud-hypervisor-finish.sh /etc/s6-overlay/s6-rc.d/clo
RUN touch /etc/s6-overlay/s6-rc.d/user/contents.d/cloud-hypervisor

COPY --from=builder /workspace/main /usr/bin/virt-prerunner
COPY --from=builder /workspace/rad /usr/bin/rad
COPY build/virt-prerunner/virt-prerunner-type /etc/s6-overlay/s6-rc.d/virt-prerunner/type
COPY build/virt-prerunner/virt-prerunner-up /etc/s6-overlay/s6-rc.d/virt-prerunner/up
COPY build/virt-prerunner/virt-prerunner-run.sh /etc/s6-overlay/scripts/virt-prerunner-run.sh
Expand All @@ -50,5 +52,7 @@ ENTRYPOINT ["/init"]

COPY build/virt-prerunner/iptables-wrapper /sbin/iptables-wrapper
RUN update-alternatives --install /sbin/iptables iptables /sbin/iptables-wrapper 100
COPY build/virt-prerunner/ip6tables-wrapper /sbin/ip6tables-wrapper
RUN update-alternatives --install /sbin/ip6tables ip6tables /sbin/ip6tables-wrapper 100

ADD build/virt-prerunner/virt-init-volume.sh /usr/bin/virt-init-volume
17 changes: 17 additions & 0 deletions build/virt-prerunner/ip6tables-wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

set +e

ip6tables-legacy -nvL

if [ $? -eq 0 ]
then
mode=legacy
else
mode=nft
fi

update-alternatives --install /sbin/ip6tables ip6tables "/sbin/ip6tables-${mode}" 100
update-alternatives --set ip6tables "/sbin/ip6tables-${mode}" > /dev/null

exec "$0" "$@"
Loading

0 comments on commit 4b04033

Please sign in to comment.