3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 %define COMPONENT danm
16 %define RPM_NAME caas-%{COMPONENT}
17 %define RPM_MAJOR_VERSION 4.1.0
18 %define RPM_MINOR_VERSION 1
19 %define DANM_VERSION 93b46c01682b492efec9c4661990d89976d2e3e5
20 %define CNI_VERSION 0.8.1
21 %define go_version 1.12.10
22 %define SRIOV_VERSION 9e4c973b2ac517c64867e33d61aee152d70dc330
23 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
24 %define binary_build_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/binary-save
25 %define docker_build_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-build
26 %define build_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/build
27 %define built_binaries_dir /binary-save
28 %define danm_components danm fakeipam
29 %define cnis flannel sriov
30 %define centos_build 191001
32 %define CNI_PLUGINS_ARCH arm64
34 %define CNI_PLUGINS_ARCH amd64
38 Version: %{RPM_MAJOR_VERSION}
39 Release: %{RPM_MINOR_VERSION}%{?dist}
40 Summary: Containers as a Service %{COMPONENT} component
41 License: %{_platform_license} and BSD 3-Clause License
42 URL: https://github.com/nokia/danm
44 Vendor: %{_platform_vendor} and Nokia and Others unmodified
45 Source0: %{name}-%{version}.tar.gz
47 Requires: docker-ce >= 18.09.2, iputils, rsync
48 BuildRequires: docker-ce-cli >= 18.09.2, curl, wget
50 # more info at: https://fedoraproject.org/wiki/Packaging:Debuginfo No build ID note in Flannel
51 %global debug_package %{nil}
54 This RPM contains the DANM and related CNI binaries for CaaS subsystem.
60 mkdir -p %{binary_build_dir}/cni
61 curl -fsSL -k https://github.com/containernetworking/plugins/releases/download/v%{CNI_VERSION}/cni-plugins-linux-%{CNI_PLUGINS_ARCH}-v%{CNI_VERSION}.tgz | tar zx --strip-components=1 -C %{binary_build_dir}/cni
64 wget --progress=dot:giga http://artifacts.ci.centos.org/sig-cloudinstance/centos-7-%{centos_build}/%{_arch}/centos-7-%{_arch}-docker.tar.xz -O %{docker_build_dir}/danm-builder/centos-7-docker.tar.xz
69 --build-arg HTTP_PROXY="${http_proxy}" \
70 --build-arg HTTPS_PROXY="${https_proxy}" \
71 --build-arg NO_PROXY="${no_proxy}" \
72 --build-arg http_proxy="${http_proxy}" \
73 --build-arg https_proxy="${https_proxy}" \
74 --build-arg no_proxy="${no_proxy}" \
75 --build-arg DANM_VERSION="%{DANM_VERSION}" \
76 --build-arg go_version="%{go_version}" \
77 --build-arg binaries="%{built_binaries_dir}" \
78 --build-arg components="%{danm_components}" \
79 --tag danm-builder:%{IMAGE_TAG} \
80 %{docker_build_dir}/danm-builder/
82 builder_container=$(docker run -id --rm --network=none --entrypoint=/bin/sh danm-builder:%{IMAGE_TAG})
83 mkdir -p %{binary_build_dir}/danm
84 for component in %{danm_components}; do
85 docker cp ${builder_container}:%{built_binaries_dir}/${component} %{binary_build_dir}/danm/
87 docker rm -f ${builder_container}
88 docker rmi danm-builder:%{IMAGE_TAG}
91 wget --progress=dot:giga http://artifacts.ci.centos.org/sig-cloudinstance/centos-7-%{centos_build}/%{_arch}/centos-7-%{_arch}-docker.tar.xz -O %{docker_build_dir}/cni-builder/centos-7-docker.tar.xz
96 --build-arg HTTP_PROXY="${http_proxy}" \
97 --build-arg HTTPS_PROXY="${https_proxy}" \
98 --build-arg NO_PROXY="${no_proxy}" \
99 --build-arg http_proxy="${http_proxy}" \
100 --build-arg https_proxy="${https_proxy}" \
101 --build-arg no_proxy="${no_proxy}" \
102 --build-arg go_version="%{go_version}" \
103 --build-arg SRIOV_VERSION="%{SRIOV_VERSION}" \
104 --build-arg binaries="%{built_binaries_dir}" \
105 --tag cni-builder:%{IMAGE_TAG} \
106 %{docker_build_dir}/cni-builder/
108 builder_container=$(docker run -id --rm --network=none --entrypoint=/bin/sh cni-builder:%{IMAGE_TAG})
109 mkdir -p %{binary_build_dir}/built_cnis
110 for cni in %{cnis}; do
111 docker cp ${builder_container}:%{built_binaries_dir}/${cni} %{binary_build_dir}/built_cnis/
113 docker rm -f ${builder_container}
114 docker rmi cni-builder:%{IMAGE_TAG}
117 git clone https://github.com/nokia/danm.git %{build_dir}/danm
119 git checkout %{DANM_VERSION}
122 mkdir -p %{buildroot}/etc/cni/net.d/
123 rsync -av cni-config/00-danm.conf %{buildroot}/etc/cni/net.d/00-danm.conf
124 rsync -av cni-config/flannel.conf %{buildroot}/etc/cni/net.d/flannel.conf
126 mkdir -p %{buildroot}/opt/cni/bin/
127 # Generic CNI plugins
128 # Don't use the standard ipvlan binary \
129 # Don't use portmap, quick fix for CVE-2019-9946 \
131 --chmod=go+rx,u+rwx \
134 %{binary_build_dir}/cni/* %{buildroot}/opt/cni/bin
136 for component in %{danm_components}; do
137 install -D -m 0755 %{binary_build_dir}/danm/${component} %{buildroot}/opt/cni/bin/${component}
140 for cni in %{cnis}; do
141 install -D -m 0755 %{binary_build_dir}/built_cnis/${cni} %{buildroot}/opt/cni/bin/${cni}
145 mkdir -p %{buildroot}/%{_caas_danm_crd_path}
146 rsync -av %{build_dir}/danm/integration/crds/production/ %{buildroot}/%{_caas_danm_crd_path}
151 /etc/cni/net.d/00-danm.conf
152 /etc/cni/net.d/flannel.conf
156 /%{_caas_danm_crd_path}