Add maintenance toleration for chart and tiller
[ta/caas-helm.git] / SPECS / caas-helm.spec
1 # Copyright 2019 Nokia
2 #
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
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 %define COMPONENT helm
16 %define RPM_NAME caas-%{COMPONENT}
17 %define RPM_MAJOR_VERSION 2.15.2
18 %define RPM_MINOR_VERSION 1
19 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
20 %define go_version 1.12.10
21 %define binary_build_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/binary-save
22 %define docker_build_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-build
23 %define docker_save_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save
24 %define built_binaries_dir /binary-save
25 %define centos_build 191001
26
27 Name:           %{RPM_NAME}
28 Version:        %{RPM_MAJOR_VERSION}
29 Release:        %{RPM_MINOR_VERSION}%{?dist}
30 Summary:        Containers as a Service %{COMPONENT} component
31 License:        %{_platform_licence} and MIT license and BSD and Apache License and Lesser General Public License
32 BuildArch:      %{_arch}
33 Vendor:         %{_platform_vendor} and helm/helm unmodified
34 Source0:        %{name}-%{version}.tar.gz
35
36 Requires: docker-ce >= 18.09.2, rsync
37 BuildRequires: docker-ce-cli >= 18.09.2, rsync, xz, wget
38
39 %description
40 This rpm contains the %{COMPONENT} container for CaaS subsystem.
41 This container contains the %{COMPONENT} service.
42
43 %prep
44 %autosetup
45
46 %build
47 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}/helm-builder/centos-7-docker.tar.xz
48 # Build Helm binaries
49 docker build \
50   --network=host \
51   --no-cache \
52   --force-rm \
53   --build-arg HTTP_PROXY="${http_proxy}" \
54   --build-arg HTTPS_PROXY="${https_proxy}" \
55   --build-arg NO_PROXY="${no_proxy}" \
56   --build-arg http_proxy="${http_proxy}" \
57   --build-arg https_proxy="${https_proxy}" \
58   --build-arg no_proxy="${no_proxy}" \
59   --build-arg HELM_VERSION="%{version}" \
60   --build-arg go_version="%{go_version}" \
61   --build-arg binaries="%{built_binaries_dir}" \
62   --tag helm-builder:%{IMAGE_TAG} \
63   %{docker_build_dir}/helm-builder
64
65 mkdir -p %{binary_build_dir}
66 builder_container=$(docker run -id --rm --network=none --entrypoint=/bin/sh helm-builder:%{IMAGE_TAG})
67 docker cp ${builder_container}:%{built_binaries_dir}/helm   %{binary_build_dir}/
68 docker cp ${builder_container}:%{built_binaries_dir}/tiller %{binary_build_dir}/
69 docker rm -f ${builder_container}
70 docker rmi helm-builder:%{IMAGE_TAG}
71
72 # Build tiller container image
73 rsync -av %{binary_build_dir}/* %{docker_build_dir}/tiller/
74 docker build \
75   --network=host \
76   --no-cache \
77   --force-rm \
78   --build-arg HTTP_PROXY="${http_proxy}" \
79   --build-arg HTTPS_PROXY="${https_proxy}" \
80   --build-arg NO_PROXY="${no_proxy}" \
81   --build-arg http_proxy="${http_proxy}" \
82   --build-arg https_proxy="${https_proxy}" \
83   --build-arg no_proxy="${no_proxy}" \
84   --tag tiller:%{IMAGE_TAG} \
85   %{docker_build_dir}/tiller
86 mkdir -p %{docker_save_dir}/
87 docker save tiller:%{IMAGE_TAG} | xz -z -T2 > "%{docker_save_dir}/tiller:%{IMAGE_TAG}.tar"
88 docker rmi tiller:%{IMAGE_TAG}
89
90 %install
91 mkdir -p %{buildroot}/%{_caas_container_tar_path}
92 rsync -av %{docker_save_dir}/* %{buildroot}/%{_caas_container_tar_path}/
93
94 mkdir -p %{buildroot}/%{_roles_path}
95 rsync -av ansible/roles/helm %{buildroot}/%{_roles_path}/
96
97 install -D ansible/playbooks/helm.yaml %{buildroot}/%{_playbooks_path}/helm.yaml
98
99 install -D -m 0755 %{binary_build_dir}/helm %{buildroot}/usr/bin/helm
100
101 %files
102 %{_caas_container_tar_path}/tiller:%{IMAGE_TAG}.tar
103 %{_roles_path}/helm
104 %{_playbooks_path}/helm.yaml
105 /usr/bin/helm
106
107 %preun
108
109 %post
110 mkdir -p %{_postconfig_path}
111 ln -s %{_playbooks_path}/helm.yaml %{_postconfig_path}/
112
113 %postun
114 if [ $1 -eq 0 ]; then
115   rm -f %{_postconfig_path}/helm.yaml
116 fi
117
118 %clean
119 rm -rf ${buildroot}