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 kubernetes
16 %define RPM_NAME caas-%{COMPONENT}
17 %define RPM_MAJOR_VERSION 1.16.2
18 %define RPM_MINOR_VERSION 2
19 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
20 %define KUBERNETESPAUSE_VERSION 3.1
22 %define go_version 1.12.10
23 %define ceph_version 12.2.5
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 docker_save_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save
27 %define built_binaries_dir /binary-save
28 %define centos_build 191001
31 Version: %{RPM_MAJOR_VERSION}
32 Release: %{RPM_MINOR_VERSION}%{?dist}
33 Summary: Containers as a Service %{COMPONENT} component
34 License: %{_platform_licence} and Apache License and GNU General Public License v2.0 only and GNU Lesser General Public License v2.1 only and MIT license and BSD and MIT license and ISC License and Creative Commons Attribution ShareAlike 4.0 International and Mozilla Public License and COMMON DEVELOPMENT AND DISTRIBUTION LICENSE and Lesser General Public License and Creative Commons - Public Domain and Creative Commons Public License and BSD 3-Clause License
36 Vendor: %{_platform_vendor} and kubernetes/kubernetes unmodified
37 Source0: %{name}-%{version}.tar.gz
39 Requires: docker-ce >= 18.09.2, rsync
40 BuildRequires: docker-ce-cli >= 18.09.2, xz, wget
42 # more info at: https://fedoraproject.org/wiki/Packaging:Debuginfo No build ID note in Flannel
43 %global debug_package %{nil}
46 This rpm contains the %{COMPONENT} container for CaaS subsystem.
47 This container contains the %{COMPONENT} service.
52 # Build Kubernetes binaries
54 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}/kubernetes-builder/centos-7-docker.tar.xz
60 --build-arg HTTP_PROXY="${http_proxy}" \
61 --build-arg HTTPS_PROXY="${https_proxy}" \
62 --build-arg NO_PROXY="${no_proxy}" \
63 --build-arg http_proxy="${http_proxy}" \
64 --build-arg https_proxy="${https_proxy}" \
65 --build-arg no_proxy="${no_proxy}" \
66 --build-arg KUBERNETES_VERSION="%{version}" \
67 --build-arg go_version="%{go_version}" \
68 --build-arg binaries="%{built_binaries_dir}" \
69 --tag kubernetes-builder:%{IMAGE_TAG} \
70 %{docker_build_dir}/kubernetes-builder
72 builder_container=$(docker run -id --rm --network=none --entrypoint=/bin/sh kubernetes-builder:%{IMAGE_TAG})
73 mkdir -p %{binary_build_dir}
74 docker cp ${builder_container}:%{built_binaries_dir}/kubelet %{binary_build_dir}/
75 docker cp ${builder_container}:%{built_binaries_dir}/kubectl %{binary_build_dir}/
76 docker cp ${builder_container}:%{built_binaries_dir}/kube-apiserver %{binary_build_dir}/
77 docker cp ${builder_container}:%{built_binaries_dir}/kube-controller-manager %{binary_build_dir}/
78 docker cp ${builder_container}:%{built_binaries_dir}/kube-proxy %{binary_build_dir}/
79 docker cp ${builder_container}:%{built_binaries_dir}/kube-scheduler %{binary_build_dir}/
80 mkdir -p %{binary_build_dir}/cni
82 docker rm -f ${builder_container}
83 docker rmi kubernetes-builder:%{IMAGE_TAG}
85 # Build hyperkube container image
86 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}/hyperkube/centos-7-docker.tar.xz
87 rsync -av %{binary_build_dir}/kube-apiserver %{docker_build_dir}/hyperkube/
88 rsync -av %{binary_build_dir}/kube-controller-manager %{docker_build_dir}/hyperkube/
89 rsync -av %{binary_build_dir}/kube-proxy %{docker_build_dir}/hyperkube/
90 rsync -av %{binary_build_dir}/kube-scheduler %{docker_build_dir}/hyperkube/
95 --build-arg HTTP_PROXY="${http_proxy}" \
96 --build-arg HTTPS_PROXY="${https_proxy}" \
97 --build-arg NO_PROXY="${no_proxy}" \
98 --build-arg http_proxy="${http_proxy}" \
99 --build-arg https_proxy="${https_proxy}" \
100 --build-arg no_proxy="${no_proxy}" \
101 --build-arg ceph_version="%{ceph_version}" \
102 --tag hyperkube:%{IMAGE_TAG} \
103 %{docker_build_dir}/hyperkube
104 mkdir -p %{docker_save_dir}
105 docker save hyperkube:%{IMAGE_TAG} | xz -z -T2 > "%{docker_save_dir}/hyperkube:%{IMAGE_TAG}.tar"
106 docker rmi hyperkube:%{IMAGE_TAG}
108 # Build kubernetes pause container image
113 --build-arg HTTP_PROXY="${http_proxy}" \
114 --build-arg HTTPS_PROXY="${https_proxy}" \
115 --build-arg NO_PROXY="${no_proxy}" \
116 --build-arg http_proxy="${http_proxy}" \
117 --build-arg https_proxy="${https_proxy}" \
118 --build-arg no_proxy="${no_proxy}" \
119 --build-arg KUBERNETESPAUSE_VERSION="%{KUBERNETESPAUSE_VERSION}" \
120 --tag kubernetespause:%{KUBERNETESPAUSE_VERSION} \
121 %{docker_build_dir}/kubernetespause
122 mkdir -p %{docker_save_dir}
123 docker save kubernetespause:%{KUBERNETESPAUSE_VERSION} | xz -z -T2 > "%{docker_save_dir}/kubernetespause:%{KUBERNETESPAUSE_VERSION}.tar"
124 docker rmi kubernetespause:%{KUBERNETESPAUSE_VERSION}
127 mkdir -p %{buildroot}/%{_caas_container_tar_path}
128 rsync -av %{docker_save_dir}/* %{buildroot}/%{_caas_container_tar_path}/
130 mkdir -p %{buildroot}/%{_roles_path}
131 rsync -av ansible/roles/* %{buildroot}/%{_roles_path}/
133 mkdir -p %{buildroot}/%{_playbooks_path}/
134 rsync -av ansible/playbooks/* %{buildroot}/%{_playbooks_path}/
136 mkdir -p %{buildroot}/usr/bin/
137 install -D -m 0755 %{binary_build_dir}/kubectl %{buildroot}/usr/bin/kubectl
138 install -D -m 0755 %{binary_build_dir}/kubelet %{buildroot}/usr/bin/kubelet
140 mkdir -p %{buildroot}/%{_playbooks_path}/
141 rsync -av ansible/playbooks/* %{buildroot}/%{_playbooks_path}/
144 %{_caas_container_tar_path}/*.tar
153 mkdir -p %{_postconfig_path}
154 ln -s %{_playbooks_path}/bootstrap_kube_proxy.yaml %{_postconfig_path}/
155 ln -s %{_playbooks_path}/bootstrap_kubelet.yaml %{_postconfig_path}/
156 ln -s %{_playbooks_path}/kube_master.yaml %{_postconfig_path}/
157 ln -s %{_playbooks_path}/kube_secret_key_creation.yaml %{_postconfig_path}/
158 ln -s %{_playbooks_path}/kube_secret_key_distribution.yaml %{_postconfig_path}/
159 ln -s %{_playbooks_path}/kube_token_creation.yaml %{_postconfig_path}/
160 ln -s %{_playbooks_path}/kube_token_distribution.yaml %{_postconfig_path}/
161 ln -s %{_playbooks_path}/kubernetes_ceph.yaml %{_postconfig_path}/
162 ln -s %{_playbooks_path}/master_kube_proxy.yaml %{_postconfig_path}/
163 ln -s %{_playbooks_path}/master_kubelet.yaml %{_postconfig_path}/
164 ln -s %{_playbooks_path}/service_account_creation.yaml %{_postconfig_path}/
165 ln -s %{_playbooks_path}/service_account_distribution.yaml %{_postconfig_path}/
166 ln -s %{_playbooks_path}/set_nodes_label.yaml %{_postconfig_path}/
169 if [ $1 -eq 0 ]; then
170 rm -f %{_postconfig_path}/bootstrap_kube_proxy.yaml
171 rm -f %{_postconfig_path}/bootstrap_kubelet.yaml
172 rm -f %{_postconfig_path}/kube_master.yaml
173 rm -f %{_postconfig_path}/kube_secret_key_creation.yaml
174 rm -f %{_postconfig_path}/kube_secret_key_distribution.yaml
175 rm -f %{_postconfig_path}/kube_token_creation.yaml
176 rm -f %{_postconfig_path}/kube_token_distribution.yaml
177 rm -f %{_postconfig_path}/kubernetes_ceph.yaml
178 rm -f %{_postconfig_path}/master_kube_proxy.yaml
179 rm -f %{_postconfig_path}/master_kubelet.yaml
180 rm -f %{_postconfig_path}/service_account_creation.yaml
181 rm -f %{_postconfig_path}/service_account_distribution.yaml
182 rm -f %{_postconfig_path}/set_nodes_label.yaml