README.md 4.64 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<table style="border-collapse: collapse; border: none;">
  <tr style="border-collapse: collapse; border: none;">
    <td style="border-collapse: collapse; border: none;">
      <a href="http://www.openairinterface.org/">
         <img src="../doc/images/oai_final_logo.png" alt="" border=3 height=50 width=150>
         </img>
      </a>
    </td>
    <td style="border-collapse: collapse; border: none; vertical-align: center;">
      <b><font size = "5">OpenShift Build and Usage Procedures</font></b>
    </td>
  </tr>
</table>

Robert Schmidt's avatar
Robert Schmidt committed
15
# 1. Introduction
16

Robert Schmidt's avatar
Robert Schmidt committed
17
## General
18

Robert Schmidt's avatar
Robert Schmidt committed
19 20 21
What follows is a tutorial on how to build images on an OpenShift cluster in a three-step process
(base image, build artifact image, target image). Note that all image
streams/build configs assume the OC project/namespace `oaicicd-ran`.
22

Robert Schmidt's avatar
Robert Schmidt committed
23 24 25
If you want to regenerate images from modified sources, you have to rebuild
the ran-build image. If you reinstalled dependencies, you have to restart from
ran-base.
26

Robert Schmidt's avatar
Robert Schmidt committed
27 28 29 30
You first need to login. Do:
```bash
oc login -u <username> -p <password> --server <url>
```
31

Robert Schmidt's avatar
Robert Schmidt committed
32
## RHEL8 Entitlements
33

Robert Schmidt's avatar
Robert Schmidt committed
34
To build the RAN images, we use the `codeready-builder-for-rhel-8-x86_64-rpms` repository with all the proper development libraries.
35
This repository is not directly accessible from the UBI RHEL8 image (`registry.access.redhat.com/ubi8/ubi:latest`).
Robert Schmidt's avatar
Robert Schmidt committed
36
Therefore, we need to copy certificates and subscription manager configuration files from a registered RHEL8 machine.
37

Robert Schmidt's avatar
Robert Schmidt committed
38
on a `RHEL8` physical machine (or a virtual machine) connected to the OpenShift Cluster, recover the entitlement and the RH subscription manager configs:
39 40 41 42 43 44 45 46

```bash
oc create configmap rhsm-conf --from-file /etc/rhsm/rhsm.conf
oc create configmap rhsm-ca --from-file /etc/rhsm/ca/redhat-uep.pem

oc create secret generic etc-pki-entitlement --from-file /etc/pki/entitlement/{NUMBER_ON_YOUR_COMPUTER}.pem --from-file /etc/pki/entitlement/{NUMBER_ON_YOUR_COMPUTER}-key.pem
```

Robert Schmidt's avatar
Robert Schmidt committed
47 48 49 50
These configmaps and secret will be shared by all the build configs in your OC
project. No need to do it each time.  However, these files expire every month
or so. If you have done a build on your OC project and try again a few weeks
later, you may need to re-copy them. (The CI recopies them every time.)
51 52 53 54 55 56 57

```bash
oc delete secret etc-pki-entitlement
oc delete cm rhsm-conf
oc delete cm rhsm-ca
```

Robert Schmidt's avatar
Robert Schmidt committed
58
# 2. Build of `base` shared image
59

Robert Schmidt's avatar
Robert Schmidt committed
60 61 62 63 64 65 66
Create an image stream and build config that specify image properties and build parameters, then start the build:

```bash
oc create -f openshift/ran-base-is.yaml
oc create -f openshift/ran-base-bc.yaml
oc start-build ran-base --from-file=<oai-repo-directory> --follow
```
67

Robert Schmidt's avatar
Robert Schmidt committed
68
The `--from-file=<oai-repo-directory>` uploads the repository (from which the
69 70
build is done) as a binary blob. It is therefore possible to make merges or
other (local) modifications and build an image.
71

Robert Schmidt's avatar
Robert Schmidt committed
72
# 3. Build of `build` shared image
73

Robert Schmidt's avatar
Robert Schmidt committed
74
The same as for the `base` image.
75 76

```bash
Robert Schmidt's avatar
Robert Schmidt committed
77 78 79
oc create -f openshift/ran-build-is.yaml
oc create -f openshift/ran-build-bc.yaml
oc start-build ran-build --from-file=<oai-repo-directory> --follow
80 81
```

Robert Schmidt's avatar
Robert Schmidt committed
82
# 4. Build of a target image
83

Robert Schmidt's avatar
Robert Schmidt committed
84
The same as for the `base` image:
85 86

```bash
Robert Schmidt's avatar
Robert Schmidt committed
87 88 89
oc create -f openshift/oai-gnb-is.yaml
oc create -f openshift/oai-gnb-bc.yaml
oc start-build oai-gnb --from-file=<oai-repo-directory> --follow
90 91
```

Robert Schmidt's avatar
Robert Schmidt committed
92
# 5. Retrieval of Build Container Images and Build Artifacts
93

Robert Schmidt's avatar
Robert Schmidt committed
94 95
Build artifacts, such as build logs, can be retrieved by checking the logs of
the individual build steps. For example, for the `ran-build` step, you can do:
96
```bash
Robert Schmidt's avatar
Robert Schmidt committed
97
oc logs ran-build-1-build
98
```
Robert Schmidt's avatar
Robert Schmidt committed
99 100
where `ran-build-1-build` is the name of the `ran-build` build (type `oc get
pods` to get a list of all pods).
101

Robert Schmidt's avatar
Robert Schmidt committed
102 103 104 105 106 107 108 109
It is also possible to retrieve the build logs from a running pod. Currently,
this is only used for the `ran-base` step (the others using a python script to
scrape it from stdout):
```bash
oc create -f openshift/ran-base-log-retrieval.yaml
oc rsync ran-base-log-retrieval:/oai-ran/cmake_targets/log cmake_targets/log/ran-base
oc delete -f openshift/ran-base-log-retrieval.yaml
```
110

Robert Schmidt's avatar
Robert Schmidt committed
111 112 113 114 115 116 117 118
The images are uploaded into the OpenShift image registry. To download, login
using podman, then pull an image:
```bash
oc whoami -t | sudo podman login -u <username> --password-stdin <url> --tls-verify=false
sudo podman pull <url>/oaicicd-ran/<image>:<tag> --tls-verify=false
sudo podman logout <url>
```
The `<image>` could be `oai-gnb`, and the `<tag>` `ci-temp`.
119

Robert Schmidt's avatar
Robert Schmidt committed
120
# 6. Deployment using HELM Charts
121 122 123 124 125 126 127 128 129 130 131

**CAUTION: even more experimental.**

Helm charts are located in another repository:

```bash
git clone https://github.com/OPENAIRINTERFACE/openair-k8s.git
cd openair-k8s
git checkout helm-deployment-S6a-S1C-S1U-in-network-18-with-enb
helm install mme /path-to-your-cloned/openair-k8s/charts/oai-mme/
```