8ada5e3c53f3898c6080f142067a2769c7ae23b2
[oom/offline-installer.git] / docs / BuildGuide.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. Copyright 2019 Samsung Electronics Co., Ltd.
4
5 OOM ONAP Offline Installer Package Build Guide
6 =============================================================
7
8 This document is describing procedure for building offline installer packages. It is supposed to be triggered on server with internet connectivity and will download all artifacts required for ONAP deployment based on our static lists. The server used for the procedure in this guide is preferred to be separate build server.
9
10 Procedure was completely tested on RHEL 7.6 as it’s tested target platform, however with small adaptations it should be applicable also for other platforms.
11 Some discrepancies when Centos 7.6 is used are described below as well.
12
13 Part 1. Preparations
14 --------------------
15
16 We assume that procedure is executed on RHEL 7.6 server with \~300G disc space, 16G+ RAM and internet connectivity
17
18 Some additional sw packages are required by ONAP Offline platform building tooling. in order to install them
19 following repos has to be configured for RHEL 7.6 platform.
20
21
22
23 ::
24
25     ############
26     # RHEL 7.6 #
27     ############
28
29     # Register server
30     subscription-manager register --username <rhel licence name> --password <password> --auto-attach
31
32     # required by special centos docker recommended by ONAP
33     yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
34
35     # required by docker dependencies i.e. docker-selinux
36     subscription-manager repos --enable=rhel-7-server-extras-rpms
37
38     # epel is required by npm within blob build
39     rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
40
41 Alternatively
42
43 ::
44
45    ToDo: newer download scripts needs to be verified on Centos with ONAP Dublin
46
47    ##############
48    # Centos 7.6 #
49    ##############
50
51    # required by special centos docker recommended by ONAP
52    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
53
54    # enable epel repo for npm and jq
55    yum install -y epel-release
56
57 Subsequent steps are the same on both platforms:
58
59 ::
60
61     # install following packages
62     yum install -y docker-ce-18.09.5 python-pip git createrepo expect nodejs npm jq
63
64     # install Python 3 (download scripts don't support Python 2 anymore)
65     yum install -y python36 python36-pip
66
67     # twine package is needed by nexus blob build script
68     pip install twine
69
70     # docker daemon must be running on host
71     service docker start
72
73 Then it is necessary to clone all installer and build related repositories and prepare the directory structure.
74
75 ::
76
77     # prepare the onap build directory structure
78     cd /tmp
79     git clone https://gerrit.onap.org/r/oom/offline-installer onap-offline
80     cd onap-offline
81
82     # install required pip packages for build and download scripts
83     pip3 install -r ./build/requirements.txt
84     pip3 install -r ./build/download/requirements.txt
85
86 Part 2. Download artifacts for offline installer
87 ------------------------------------------------
88
89 .. note:: Skip this step if you have already all necessary resources and continue with Part 3. Populate local nexus
90
91 It's possible to download all artifacts in single ./download.py execution. Recently we improved reliability of download scripts
92 so one might try following command to download most of the required artifacts in single shot.
93
94 ::
95
96         # following arguments are provided
97         # all data lists are taken in ./build/data_lists/ folder
98         # all resources will be stored in expected folder structure within ../resources folder
99         # for more details refer to Appendix 1.
100
101         ./build/download/download.py --docker ./build/data_lists/infra_docker_images.list ../resources/offline_data/docker_images_infra \
102         --docker ./build/data_lists/rke_docker_images.list ../resources/offline_data/docker_images_for_nexus \
103         --docker ./build/data_lists/onap_docker_images.list ../resources/offline_data/docker_images_for_nexus \
104         --git ./build/data_lists/onap_git_repos.list ../resources/git-repo \
105         --npm ./build/data_lists/onap_npm.list ../resources/offline_data/npm_tar \
106         --rpm ./build/data_lists/onap_rpm.list ../resources/pkg/rhel \
107         --pypi ./build/data_lists/onap_pip_packages.list ../resources/offline_data/pypi \
108         --http ./build/data_lists/infra_bin_utils.list ../resources/downloads
109
110
111 Alternatively, step-by-step procedure is described in Appendix 1.
112
113 This concludes SW download part required for ONAP offline platform creating.
114
115 Part 3. Populate local nexus
116 ----------------------------
117
118 Prerequisites:
119
120 - All data lists and resources which are pushed to local nexus repository are available
121 - Following ports are not occupied buy another service: 80, 8081, 8082, 10001
122 - There's no docker container called "nexus"
123
124 .. note:: In case you skipped the Part 2 for the artifacts download, please ensure that the copy of resources data are untarred in *./onap-offline/../resources/*
125
126 Whole nexus blob data will be created by running script build_nexus_blob.sh.
127 It will load the listed docker images, run the Nexus, configure it as npm, pypi
128 and docker repositories. Then it will push all listed npm and pypi packages and
129 docker images to the repositories. After all is done the repository container
130 is stopped.
131
132 .. note:: build_nexus_blob.sh script is using docker, npm and pip data lists for building nexus blob. Unfortunatelly we now have 2 different docker data lists (RKE & ONAP). So we need to merge them as visible from following snippet. This problem will be fixed in OOM-1890
133
134 You can run the script as following example:
135
136 ::
137
138         # merge RKE and ONAP app data lists
139         cat ./build/data_lists/rke_docker_images.list >> ./build/data_lists/onap_docker_images.list
140
141         ./build/build_nexus_blob.sh
142
143 .. note:: in current release scope we aim to maintain just single example data lists set, tags used in previous releases are not needed. Datalists are also covering latest versions verified by us despite user is allowed to build data lists on his own.
144
145 Once the Nexus data blob is created, the docker images and npm and pypi
146 packages can be deleted to reduce the package size as they won't be needed in
147 the installation time:
148
149 E.g.
150
151 ::
152
153     rm -f /tmp/resources/offline_data/docker_images_for_nexus/*
154     rm -rf /tmp/resources/offline_data/npm_tar
155     rm -rf /tmp/resources/offline_data/pypi
156
157 Part 4. Packages preparation
158 --------------------------------------------------------
159
160 ONAP offline deliverable consist of 3 packages:
161
162 +---------------------------------------+------------------------------------------------------------------------------+
163 | Package                               | Description                                                                  |
164 +=======================================+==============================================================================+
165 | sw_package.tar                        | Contains installation software and configuration for infrastructure and ONAP |
166 +---------------------------------------+------------------------------------------------------------------------------+
167 | resources_package.tar                 | Contains all input files  needed to deploy infrastructure and ONAP           |
168 +---------------------------------------+------------------------------------------------------------------------------+
169 | aux_package.tar                       | Contains auxiliary input files that can be added to ONAP                     |
170 +---------------------------------------+------------------------------------------------------------------------------+
171
172 All packages can be created using script build/package.py. Beside of archiving files gathered in the previous steps, script also builds installer software and apply patch over application repository to make it usable without internet access.
173
174 From onap-offline directory run:
175
176 ::
177
178   ./build/package.py <helm charts repo> --application-repository_reference <commit/tag/branch> --application-patch_file <patchfile> --output-dir <target\_dir> --resources-directory <target\_dir>
179
180 For example:
181
182 ::
183
184   ./build/package.py https://gerrit.onap.org/r/oom --application-repository_reference master --application-patch_file ./patches/onap.patch --output-dir ../packages --resources-directory ../resources
185
186
187 In the target directory you should find tar files:
188
189 ::
190
191   sw_package.tar
192   resources_package.tar
193   aux_package.tar
194
195
196 Appendix 1. Step-by-step download procedure
197 -------------------------------------------
198
199 **Step 1 - docker images**
200
201 ::
202
203         # This step will parse all 3 docker datalists (offline infrastructure images, rke k8s images & onap images)
204         # and start building onap offline platform in /tmp/resources folder
205
206         ./build/download/download.py --docker ./build/data_lists/infra_docker_images.list ../resources/offline_data/docker_images_infra \
207         --docker ./build/data_lists/rke_docker_images.list ../resources/offline_data/docker_images_for_nexus \
208         --docker ./build/data_lists/onap_docker_images.list ../resources/offline_data/docker_images_for_nexus
209
210
211 **Step 2 - git repos**
212
213 ::
214
215         # Following step will download all git repos
216         ./build/download/download.py --git ./build/data_lists/onap_git_repos.list ../resources/git-repo
217
218
219 **Step 3 - npm packages**
220
221 ::
222
223         # Following step will download all npm packages
224         ./build/download/download.py --npm ./build/data_lists/onap_npm.list ../resources/offline_data/npm_tar
225
226 **Step 4 - binaries**
227
228 ::
229
230        # Following step will download rke, kubectl and helm binaries
231        ./build/download/download.py --http ./build/data_lists/infra_bin_utils.sh ../resources/downloads
232
233 **Step 5 - rpms**
234
235 ::
236
237       # Following step will download all rpms and create repo
238       ./build/download/download.py --rpm ./build/data_lists/onap_rpm.list ../resources/pkg/rhel
239
240       createrepo ../resources/pkg/rhel
241
242 **Step 6 - pip packages**
243
244 ::
245
246       # Following step will download all pip packages
247       ./build/download/download.py --pypi ./build/data_lists/onap_pip_packages.list ../resources/offline_data/pypi
248