15a265c2303c4d2eef81cd7da4d412f5654980b4
[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 2021 Samsung Electronics Co., Ltd.
4
5 Offline Installer Package Build Guide
6 =====================================
7
8 This document describes how to build offline installer packages. The build process should be triggered on a host with internet connectivity. It will retrieve all artifacts required for ONAP deployment based on both - static data list files and dynamically assembled ones. The host used for the procedure in this guide should be preferably a separate build server.
9
10 Procedure was completely tested on RHEL 7.9 as it’s the default target installation platform, however with small adaptations it should be applicable also for other platforms.
11 Some discrepancies when Centos 7.9 is used are described below as well.
12
13
14 Part 1. Prerequisites
15 ---------------------
16
17 We assume that procedure is executed on RHEL 7.9 server with \~300G disc space, 16G+ RAM and internet connectivity.
18
19 Some additional software packages are required by ONAP Offline platform building tooling. In order to install them following repos have to be configured for RHEL 7.9 platform.
20
21
22
23 .. note::
24    All commands stated in this guide are meant to be run in root shell.
25
26 ::
27
28     ############
29     # RHEL 7.9 #
30     ############
31
32     # Register server
33     subscription-manager register --username <rhel licence name> --password <password> --auto-attach
34
35     # required by custom docker version recommended by ONAP
36     yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
37
38     # required by docker dependencies i.e. docker-selinux
39     subscription-manager repos --enable=rhel-7-server-extras-rpms
40
41     # epel is required by npm within blob build
42     rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
43
44 Alternatively
45
46 ::
47
48    ##############
49    # Centos 7.9 #
50    ##############
51
52    # required by custom docker version recommended by ONAP
53    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
54
55    # enable epel repo for npm and jq
56    yum install -y epel-release
57
58 Subsequent steps are the same on both platforms:
59
60 ::
61
62     # install following packages
63     yum install -y docker-ce-19.03.15 git createrepo expect nodejs npm jq
64
65     # install Python 3
66     yum install -y python36 python36-pip
67
68     # ensure docker daemon is running
69     service docker start
70
71 Then it is necessary to clone all installer and build related repositories and prepare the directory structure.
72
73 ::
74
75     # prepare the onap build directory structure
76     cd /tmp
77     git clone https://gerrit.onap.org/r/oom/offline-installer onap-offline
78     cd onap-offline
79
80     # install required pip packages for build and download scripts
81     pip3 install -r ./build/requirements.txt
82     pip3 install -r ./build/download/requirements.txt
83
84 Part 2. Download artifacts for offline installer
85 ------------------------------------------------
86
87 Generate the actual list of docker images that are defined within OOM helm charts. Run the docker-images-collector.sh script (check script for runtime dependencies) from cloned OOM repository.
88
89 At the beginning of the generated list file there is the OOM repo commit sha from which it was created - the same commit reference
90 should be used in **Part 4. Packages preparation** as *--application-repository_reference* option value.
91
92 Following example will create the list to the default path (*build/data_lists/onap_docker_images.list*):
93
94 ::
95
96     # clone the OOM repository
97     git clone https://gerrit.onap.org/r/oom -b <branch> --recurse-submodules /tmp/oom
98     #run the collector providing path the the project
99     ./build/creating_data/docker-images-collector.sh /tmp/oom/kubernetes/onap
100
101 For the list of all available options check script usage info.
102
103 .. note::  replace <branch> with OOM branch you want to build
104
105 .. note::  docker-images-collector.sh script uses oom/kubernetes/onap/resources/overrides/onap-all.yaml file to find what subsystems are enabled. By default all subsystems are enabled there. Modify the file to disable some of them if needed.
106
107 .. note:: Skip this step if you have already all necessary resources and continue with **Part 3. Populate local nexus**
108
109 .. note:: Docker images collector supports both helm v2 and v3. Please note that helm v3 support was added in Guilin release of OOM and as of Honolulu release helm v2 will be obsolete.
110
111 Create repository containing OS packages to be installed on all nodes:
112
113 ::
114
115     # run create_repo.sh script to download all required packages with their dependencies
116     # set destination directory for packages with '-d' parameter
117     # optionally use '-t' parameter to set target platform (host platform by default)
118     ./offline-installer/build/create_repo.sh -d $(pwd) -t centos|rhel|ubuntu
119
120 .. note:: If script fails due to permissions issue, it could be a problem with SeLinux. It can be fixed by running:
121     ::
122
123       # Change security context of directory
124       chcon -Rt svirt_sandbox_file_t $(pwd)
125
126 Download all required binaries and docker images. Run download.py twice (as shown below) as it does not support mixing downloading docker images to a local directory and pulling them to local docker engine cache in one run. Docker images from *infra_docker_images.list* need to be saved to resources directory while the rest of the images need to be just pulled locally:
127
128 ::
129
130         # all data lists are taken from ./build/data_lists/ folder by default
131         # all resources will be stored in expected folder structure within "../resources" folder
132         ./build/download/download.py --docker ./build/data_lists/infra_docker_images.list ../resources/offline_data/docker_images_infra \
133         --http ./build/data_lists/infra_bin_utils.list ../resources/downloads \
134         --http ./build/data_lists/kube_prometheus_stack_http.list ../resources/downloads
135
136         # second argument for --docker is not present, images are just pulled and cached
137         ./build/download/download.py --docker ./build/data_lists/rke_docker_images.list \
138         --docker ./build/data_lists/k8s_docker_images.list \
139         --docker ./build/data_lists/onap_docker_images.list \
140         --docker ./build/data_lists/kube_prometheus_stack_docker_images.list
141
142
143
144 Part 3. Populate local nexus
145 ----------------------------
146
147 In order to build nexus blob all docker images required for ONAP offline platform should be available locally (see Part 2).
148
149 .. note:: In case you skipped the Part 2 for the artifacts download, please ensure that the onap docker images are cached and copy of resources data are untarred in *./onap-offline/../resources/*
150
151 *build_nexus_blob.sh* script will run the Nexus container and configure it as docker repository. Then it will push all docker images from previously generated list to it. After that the repository container is stopped and its filesystem gets saved to resources directory.
152
153 ::
154
155         ./onap-offline/build/build_nexus_blob.sh
156
157 It will load the listed docker images, run the Nexus, configure it as npm, pypi and docker repositories. Then it will push all listed docker images to the repositories. After all is done the repository container is stopped.
158
159 .. note:: By default the script uses data lists from ./build/data_lists/ directory and saves the blob to ../resources/nexus_data.
160
161 .. note:: By default the script uses "nexus" for the container name and binds 8081 and 8082 ports. Should those names/ports be already used please check the script options on how to customize them.
162
163
164 Part 4. Packages preparation
165 ----------------------------
166
167 ONAP offline deliverable consist of 3 packages:
168
169 +---------------------------------------+------------------------------------------------------------------------------------+
170 | Package                               | Description                                                                        |
171 +=======================================+====================================================================================+
172 | sw_package.tar                        | Contains provisioning software and configuration for infrastructure and ONAP       |
173 +---------------------------------------+------------------------------------------------------------------------------------+
174 | resources_package.tar                 | Contains all binary data and config files needed to deploy infrastructure and ONAP |
175 +---------------------------------------+------------------------------------------------------------------------------------+
176 | aux_package.tar                       | Contains auxiliary input files that can be added to ONAP                           |
177 +---------------------------------------+------------------------------------------------------------------------------------+
178
179 All packages can be created using build/package.py script. Beside of archiving files gathered in the previous steps, script also builds docker images used on infra server.
180
181 From onap-offline directory run:
182
183 ::
184
185   ./build/package.py <helm charts repo> --build-version <version> --application-repository_reference <commit/tag/branch> --output-dir <target\_dir> --resources-directory <target\_dir>
186
187 For example:
188
189 ::
190
191   ./build/package.py https://gerrit.onap.org/r/oom --application-repository_reference <branch> --output-dir /tmp/packages --resources-directory /tmp/resources
192
193 .. note::  replace <branch> by branch you want to build
194
195 Above command should produce following tar files in the target directory:
196
197 ::
198
199   sw_package.tar
200   resources_package.tar
201   aux_package.tar
202