|
| 1 | +# syntax = docker/dockerfile:experimental |
| 2 | +FROM ubuntu:22.04 as ovs-builder |
| 3 | + |
| 4 | +ARG ARCH |
| 5 | +ARG DEBIAN_FRONTEND=noninteractive |
| 6 | +ENV SRC_DIR='/usr/src' |
| 7 | + |
| 8 | +RUN apt update && apt install build-essential git libnuma-dev autoconf curl \ |
| 9 | + python3 libmnl-dev libpcap-dev libtool libcap-ng-dev libssl-dev pkg-config \ |
| 10 | + python3-six libunbound-dev libunwind-dev dh-make fakeroot debhelper dh-python \ |
| 11 | + flake8 python3-sphinx graphviz groff wget -y |
| 12 | + |
| 13 | +RUN cd /usr/src/ && \ |
| 14 | + git clone -b branch-2.16 --depth=1 https://github.com/openvswitch/ovs.git && \ |
| 15 | + cd ovs && \ |
| 16 | + # do not strip the binary |
| 17 | + sed -i 89d debian/rules && \ |
| 18 | + sed -i s/--enable-shared//g debian/rules && \ |
| 19 | + sed -i 10d debian/automake.mk && \ |
| 20 | + sed -i 10d debian/automake.mk && \ |
| 21 | + rm debian/libopenvswitch.install debian/libopenvswitch-dev.install && \ |
| 22 | + # ofproto: Fix re-creation of tunnel backing interfaces on restart. |
| 23 | + curl -s https://github.com/openvswitch/ovs/commit/8661abd4c41a89116fbd4e4d210e73165cedd323.patch | git apply && \ |
| 24 | + # dpif-netlink.: fix ofpbuf memory leak |
| 25 | + curl -s https://github.com/kubeovn/ovs/commit/c57d7a24cf72a55193aee9bcc2d0425e9477a45b.patch | git apply && \ |
| 26 | + # fix memleak |
| 27 | + curl -s https://github.com/kubeovn/ovs/commit/2dc8e7aa202818952b2fa80b47298604530c9de0.patch | git apply && \ |
| 28 | + # fix log file descriptor leak in monitor process |
| 29 | + curl -s https://github.com/kubeovn/ovs/commit/918d6dc79634bec760054ee53f7628186315bcfb.patch | git apply && \ |
| 30 | + # increase election timer |
| 31 | + curl -s https://github.com/kubeovn/ovs/commit/22ea22c40b46ee5adeae977ff6cfca81b3ff25d7.patch | git apply && \ |
| 32 | + # add fdb update logging |
| 33 | + curl -s https://github.com/kubeovn/ovs/commit/8c2f28b778129161bbf8f0738fa41d385860d5bc.patch | git apply && \ |
| 34 | + # fdb: fix mac learning in environments with hairpin enabled |
| 35 | + curl -s https://github.com/kubeovn/ovs/commit/1cb138aaf2fdf922d75a587e4e9cf610d38f9fee.patch | git apply && \ |
| 36 | + # ovsdb-tool: add optional server id parameter for "join-cluster" command |
| 37 | + curl -s https://github.com/kubeovn/ovs/commit/2e2ec1161cadbec79786d63fde9475053d996586.patch | git apply && \ |
| 38 | + ./boot.sh && \ |
| 39 | + rm -rf .git && \ |
| 40 | + CONFIGURE_OPTS='' && \ |
| 41 | + if [ "$ARCH" = "amd64" ]; then CONFIGURE_OPTS='CFLAGS="-fno-omit-frame-pointer -fno-common"'; fi && \ |
| 42 | + DATAPATH_CONFIGURE_OPTS='--prefix=/usr --with-debug' EXTRA_CONFIGURE_OPTS=$CONFIGURE_OPTS DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary |
| 43 | + |
| 44 | +RUN dpkg -i /usr/src/python3-openvswitch*.deb /usr/src/libopenvswitch*.deb |
| 45 | + |
| 46 | +RUN cd /usr/src/ && git clone -b branch-21.06 --depth=1 https://github.com/ovn-org/ovn.git && \ |
| 47 | + cd ovn && \ |
| 48 | + # do not strip the binary |
| 49 | + sed -i 67d debian/rules && \ |
| 50 | + sed -i 14d debian/ovn-common.install && \ |
| 51 | + # fix ssl listen address |
| 52 | + curl -s https://github.com/kubeovn/ovn/commit/62d4969877712c26fe425698d898b440f91b44bf.patch | git apply && \ |
| 53 | + # expr.c: Use expr_destroy and expr_clone instead of free and xmemdup. |
| 54 | + curl -s https://github.com/ovn-org/ovn/commit/4b4cadcfabbc79f7d69c213be2b37e5e8634201c.patch | git apply && \ |
| 55 | + # treewide: bump ovs and fix problematic loops |
| 56 | + curl -s https://github.com/kubeovn/ovn/commit/8146578592200c7b732bca8ab43be05a84e34269.patch | git apply && \ |
| 57 | + # ovn-controller: Add a generic way to check if the daemon started recently. |
| 58 | + curl -s https://github.com/kubeovn/ovn/commit/a8ebd69d8a759c06f49102226192174c32fbb15b.patch | git apply && \ |
| 59 | + # patch.c: Avoid patch interface deletion & recreation during restart. |
| 60 | + curl -s https://github.com/kubeovn/ovn/commit/e24734913d25c0bffdf1cfd79e14ef43d01e1019.patch | git apply && \ |
| 61 | + # do not send multicast packets to conntrack |
| 62 | + curl -s https://github.com/kubeovn/ovn/commit/8f4e4868377afb5e980856755b9f6394f8b649e2.patch | git apply && \ |
| 63 | + # do not send traffic that not designate to svc to conntrack |
| 64 | + curl -s https://github.com/kubeovn/ovn/commit/23a87cabb76fbdce5092a6b3d3b56f3fa8dd61f5.patch | git apply && \ |
| 65 | + # Add EXTRA_CONFIGURE_OPTS for debian build |
| 66 | + curl -s https://github.com/kubeovn/ovn/commit/89ca60989df4af9a96cc6024e04f99b9b77bad22.patch | git apply && \ |
| 67 | + # fix ipv6 svc |
| 68 | + curl -s https://github.com/kubeovn/ovn/commit/aeafa43fc51be8ea1c7abfbe779c69205c1c5aa4.patch | git apply && \ |
| 69 | + # change hash type from dp_hash to hash with field src_ip |
| 70 | + curl -s https://github.com/kubeovn/ovn/commit/71f831b9cc5a6dc923af4ca90286857e2cf8b1d3.patch | git apply && \ |
| 71 | + # fix reaching resubmit limit in underlay |
| 72 | + curl -s https://github.com/kubeovn/ovn/commit/0f6fe4202001c0950dc689179e7a4ad9554a51fa.patch | git apply && \ |
| 73 | + sed -i s/--enable-shared//g debian/rules && \ |
| 74 | + sed -i 's/OVN/ovn/g' debian/changelog && \ |
| 75 | + rm -rf .git && \ |
| 76 | + ./boot.sh && \ |
| 77 | + CONFIGURE_OPTS='' && \ |
| 78 | + if [ "$ARCH" = "amd64" ]; then CONFIGURE_OPTS='--with-debug CFLAGS="-fno-omit-frame-pointer -fno-common"'; fi && \ |
| 79 | + OVSDIR=/usr/src/ovs EXTRA_CONFIGURE_OPTS=$CONFIGURE_OPTS DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary |
| 80 | + |
| 81 | +RUN mkdir /packages/ && \ |
| 82 | + cp /usr/src/libopenvswitch*.deb /packages && \ |
| 83 | + cp /usr/src/openvswitch-*.deb /packages && \ |
| 84 | + cp /usr/src/python3-openvswitch*.deb /packages && \ |
| 85 | + cp /usr/src/ovn-*.deb /packages && \ |
| 86 | + cd /packages && rm -f *dbg* *datapath* *docker* *vtep* *ipsec* *test* *dev* |
| 87 | + |
| 88 | +FROM ubuntu:22.04 |
| 89 | + |
| 90 | +ARG DEBIAN_FRONTEND=noninteractive |
| 91 | +RUN apt update && apt upgrade -y && apt install ca-certificates python3 hostname libunwind8 netbase \ |
| 92 | + ethtool iproute2 ncat libunbound-dev procps libatomic1 kmod iptables \ |
| 93 | + tcpdump ipset curl uuid-runtime openssl inetutils-ping arping ndisc6 \ |
| 94 | + logrotate dnsutils net-tools nmap valgrind -y --no-install-recommends && \ |
| 95 | + rm -rf /var/lib/apt/lists/* && \ |
| 96 | + cd /usr/sbin && \ |
| 97 | + ln -sf /usr/sbin/iptables-legacy iptables && \ |
| 98 | + ln -sf /usr/sbin/ip6tables-legacy ip6tables && \ |
| 99 | + rm -rf /etc/localtime |
| 100 | + |
| 101 | +RUN mkdir -p /var/run/openvswitch && \ |
| 102 | + mkdir -p /var/run/ovn && \ |
| 103 | + mkdir -p /etc/cni/net.d && \ |
| 104 | + mkdir -p /opt/cni/bin |
| 105 | + |
| 106 | +ARG ARCH |
| 107 | +ENV CNI_VERSION=v1.2.0 |
| 108 | +RUN curl -sSf -L --retry 5 https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-linux-${ARCH}-${CNI_VERSION}.tgz | tar -xz -C . ./loopback ./portmap ./macvlan |
| 109 | + |
| 110 | +ENV KUBE_VERSION="v1.24.12" |
| 111 | + |
| 112 | +RUN curl -L https://dl.k8s.io/${KUBE_VERSION}/kubernetes-client-linux-${ARCH}.tar.gz | tar -xz -C . && cp ./kubernetes/client/bin/kubectl /usr/bin/kubectl \ |
| 113 | + && chmod +x /usr/bin/kubectl && rm -rf ./kubernetes |
| 114 | + |
| 115 | +RUN --mount=type=bind,target=/packages,from=ovs-builder,source=/packages \ |
| 116 | + dpkg -i /packages/libopenvswitch*.deb && \ |
| 117 | + dpkg -i /packages/openvswitch-*.deb && \ |
| 118 | + dpkg -i /packages/python3-openvswitch*.deb &&\ |
| 119 | + dpkg -i --ignore-depends=openvswitch-switch,openvswitch-common /packages/ovn-*.deb |
| 120 | + |
| 121 | +ARG ARCH |
| 122 | +ENV DUMB_INIT_VERSION="1.2.5" |
| 123 | +RUN dump_arch="x86_64"; \ |
| 124 | + if [ "$ARCH" = "arm64" ]; then dump_arch="aarch64"; fi; \ |
| 125 | + curl -sSf -L --retry 5 -o /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_${dump_arch} && \ |
| 126 | + chmod +x /usr/bin/dumb-init |
| 127 | + |
| 128 | +COPY *.sh /kube-ovn/ |
| 129 | +COPY kubectl-ko /kube-ovn/kubectl-ko |
| 130 | +COPY 01-kube-ovn.conflist /kube-ovn/01-kube-ovn.conflist |
| 131 | +COPY logrotate/* /etc/logrotate.d/ |
| 132 | +COPY grace_stop_ovn_controller /usr/share/ovn/scripts/grace_stop_ovn_controller |
| 133 | + |
| 134 | +WORKDIR /kube-ovn |
| 135 | + |
| 136 | +RUN rm -f /usr/bin/nc &&\ |
| 137 | + rm -f /usr/bin/netcat |
| 138 | + |
| 139 | +COPY kube-ovn /kube-ovn/kube-ovn |
| 140 | +COPY kube-ovn-cmd /kube-ovn/kube-ovn-cmd |
| 141 | +COPY kube-ovn-webhook /kube-ovn/kube-ovn-webhook |
| 142 | +RUN ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-controller && \ |
| 143 | + ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-daemon && \ |
| 144 | + ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-monitor && \ |
| 145 | + ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-pinger && \ |
| 146 | + ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-speaker && \ |
| 147 | + ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-controller-healthcheck |
| 148 | + |
| 149 | +ENTRYPOINT ["/usr/bin/dumb-init", "--"] |
0 commit comments