Merge "[GENERAL] Add Andreas Geissler as committer."
[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 Create repository containing OS packages to be installed on all nodes:
110
111 ::
112
113     # run create_repo.sh script to download all required packages with their dependencies
114     # set destination directory for packages with '-d' parameter
115     # optionally use '-t' parameter to set target platform (host platform by default)
116     ./offline-installer/build/create_repo.sh -d $(pwd) -t centos|rhel|ubuntu
117
118 .. note:: If script fails due to permissions issue, it could be a problem with SeLinux. It can be fixed by running:
119     ::
120
121       # Change security context of directory
122       chcon -Rt svirt_sandbox_file_t $(pwd)
123
124 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:
125
126 ::
127
128         # all data lists are taken from ./build/data_lists/ folder by default
129         # all resources will be stored in expected folder structure within "../resources" folder
130         ./build/download/download.py --docker ./build/data_lists/infra_docker_images.list ../resources/offline_data/docker_images_infra \
131         --http ./build/data_lists/infra_bin_utils.list ../resources/downloads \
132         --http ./build/data_lists/kube_prometheus_stack_http.list ../resources/downloads
133
134         # second argument for --docker is not present, images are just pulled and cached
135         ./build/download/download.py --docker ./build/data_lists/rke_docker_images.list \
136         --docker ./build/data_lists/k8s_docker_images.list \
137         --docker ./build/data_lists/onap_docker_images.list \
138         --docker ./build/data_lists/kube_prometheus_stack_docker_images.list
139
140
141
142 Part 3. Populate local nexus
143 ----------------------------
144
145 In order to build nexus blob all docker images required for ONAP offline platform should be available locally (see Part 2).
146
147 .. 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/*
148
149 *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.
150
151 ::
152
153         ./onap-offline/build/build_nexus_blob.sh
154
155 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.
156
157 .. note:: By default the script uses data lists from ./build/data_lists/ directory and saves the blob to ../resources/nexus_data.
158
159 .. 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.
160
161
162 Part 4. Packages preparation
163 ----------------------------
164
165 ONAP offline deliverable consist of 3 packages:
166
167 +---------------------------------------+------------------------------------------------------------------------------------+
168 | Package                               | Description                                                                        |
169 +=======================================+====================================================================================+
170 | sw_package.tar                        | Contains provisioning software and configuration for infrastructure and ONAP       |
171 +---------------------------------------+------------------------------------------------------------------------------------+
172 | resources_package.tar                 | Contains all binary data and config files needed to deploy infrastructure and ONAP |
173 +---------------------------------------+------------------------------------------------------------------------------------+
174 | aux_package.tar                       | Contains auxiliary input files that can be added to ONAP                           |
175 +---------------------------------------+------------------------------------------------------------------------------------+
176
177 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.
178
179 From onap-offline directory run:
180
181 ::
182
183   ./build/package.py <helm charts repo> --build-version <version> --application-repository_reference <commit/tag/branch> --output-dir <target\_dir> --resources-directory <target\_dir>
184
185 For example:
186
187 ::
188
189   ./build/package.py https://gerrit.onap.org/r/oom --application-repository_reference <branch> --output-dir /tmp/packages --resources-directory /tmp/resources
190
191 .. note::  replace <branch> by branch you want to build
192
193 Above command should produce following tar files in the target directory:
194
195 ::
196
197   sw_package.tar
198   resources_package.tar
199   aux_package.tar
200