/
Dockerfile.fedora.dev
106 lines (89 loc) · 3.74 KB
/
Dockerfile.fedora.dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#
# This Dockerfile builds the development image of Kubernetes OVN CNI networking
# stack. It provides the OVN-Kubernetes CNI plugin (OVN-Kubernetes) and all the
# required binaries from OVN and OVS. By default OVN and OVS binaries are built
# using the master branch of the respective projects.
#
# NOTE:
# 1) Binaries are built using the version specified using OVN-BRANCH,
# OVS-BRANCH args below in the Dockerfile. By default the branch is set to
# master, so it will build OVN and OVS binaries from the master branch code.
# Please change the branch name if image needs to be build with different
# branch.
#
# 2) This image is only for development environment, so please DO NOT DEPLOY
# this image in any production environment.
#
FROM fedora:39 AS ovnbuilder
USER root
ENV PYTHONDONTWRITEBYTECODE yes
# Install tools that are required for building ovs/ovn.
RUN INSTALL_PKGS=" \
python3-pip python3-pyyaml bind-utils procps-ng openssl numactl-libs firewalld-filesystem \
libpcap hostname util-linux\
python3-openvswitch python3-pyOpenSSL \
autoconf automake libtool g++ gcc fedora-packager rpmdevtools \
unbound unbound-devel groff python3-sphinx graphviz openssl openssl-devel \
libbpf-devel libxdp-devel numactl-devel \
checkpolicy libcap-ng-devel selinux-policy-devel" && \
dnf install --best --refresh -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
dnf clean all && rm -rf /var/cache/dnf/*
# Clone OVS Source Code.
ARG OVS_REPO=https://github.com/openvswitch/ovs.git
ARG OVS_BRANCH=master
WORKDIR /root
RUN git clone $OVS_REPO --single-branch --branch=$OVS_BRANCH
# Build OVS rpms.
WORKDIR /root/ovs
RUN ./boot.sh
RUN ./configure
RUN make rpm-fedora
RUN rm rpm/rpmbuild/RPMS/x86_64/*debug*
RUN rm rpm/rpmbuild/RPMS/x86_64/*devel*
RUN git log -n 1
# Clone OVN Source Code.
ARG OVN_REPO=https://github.com/ovn-org/ovn.git
ARG OVN_BRANCH=main
WORKDIR /root
RUN git clone $OVN_REPO --single-branch --branch=$OVN_BRANCH
# Build OVN rpms.
WORKDIR /root/ovn/
RUN ./boot.sh
RUN ./configure --with-ovs-source=/root/ovs/
RUN make rpm-fedora
RUN rm rpm/rpmbuild/RPMS/x86_64/*debug*
RUN rm rpm/rpmbuild/RPMS/x86_64/*docker*
RUN git log -n 1
# Build the final image
FROM fedora:39
# Install needed dependencies.
RUN INSTALL_PKGS=" \
iptables iproute iputils hostname unbound-libs kubernetes-client kmod" && \
dnf install --best --refresh -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
dnf clean all && rm -rf /var/cache/dnf/*
RUN mkdir -p /var/run/openvswitch
# Install openvswitch and ovn rpms built in previous stages.
COPY --from=ovnbuilder /root/ovn/rpm/rpmbuild/RPMS/x86_64/*rpm ./
COPY --from=ovnbuilder /root/ovs/rpm/rpmbuild/RPMS/x86_64/*rpm ./
COPY --from=ovnbuilder /root/ovs/rpm/rpmbuild/RPMS/noarch/*rpm ./
RUN dnf install -y *.rpm && rm -f *.rpm
# Install ovn-kubernetes binaries built in previous stage.
RUN mkdir -p /usr/libexec/cni/
COPY ovnkube /usr/bin/
COPY ovn-kube-util /usr/bin/
COPY ovndbchecker /usr/bin/
COPY hybrid-overlay-node /usr/bin
COPY ovnkube-identity /usr/bin/
COPY ovn-k8s-cni-overlay /usr/libexec/cni/ovn-k8s-cni-overlay
# ovnkube.sh is the entry point. This script examines environment
# variables to direct operation and configure ovn.
COPY ovnkube.sh /root/
COPY ovndb-raft-functions.sh /root/
COPY iptables-scripts /usr/sbin/
RUN getent group openvswitch >/dev/null || groupadd -r openvswitch
RUN getent passwd openvswitch >/dev/null || useradd -r -g openvswitch -d / -s /sbin/nologin -c "Open vSwitch Daemons" openvswitch
LABEL io.k8s.display-name="ovn-kubernetes-master" \
io.k8s.description="OVN based Kubernetes CNI Plugin stack. Image contains latest code of all the components in the stack (OVN-kubernetes, OVN, OVS)." \
maintainer="Anil Vishnoi (vishnoianil@gmail.com)"
WORKDIR /root
ENTRYPOINT /root/ovnkube.sh