From 0e1a56c7663a9f2c773fa9f628e0263a03aeadf2 Mon Sep 17 00:00:00 2001
From: Raphael Defosseux <raphael.defosseux@eurecom.fr>
Date: Wed, 21 Oct 2020 15:59:27 +0200
Subject: [PATCH] DOC: 1st draft for OC build / deployment

Signed-off-by: Raphael Defosseux <raphael.defosseux@eurecom.fr>
---
 openshift/README.md      | 94 +++++++++++++++++++++++++++++++++++++++-
 openshift/oc_init_enb.sh |  5 ---
 openshift/oc_init_gnb.sh |  5 ---
 openshift/oc_init_ran.sh |  5 ---
 4 files changed, 93 insertions(+), 16 deletions(-)
 delete mode 100644 openshift/oc_init_enb.sh
 delete mode 100644 openshift/oc_init_gnb.sh
 delete mode 100644 openshift/oc_init_ran.sh

diff --git a/openshift/README.md b/openshift/README.md
index 2493db98c7..b7409ab945 100644
--- a/openshift/README.md
+++ b/openshift/README.md
@@ -12,4 +12,96 @@
   </tr>
 </table>
 
-TO BE DONE.
+-----
+
+**CAUTION: this is experimental. Still a lot to be done.**
+
+-----
+
+# 1. Build pre-requisites #
+
+To build our RAN images, we SHALL use the `codeready-builder-for-rhel-8-x86_64-rpms` repository with all the proper development libraries.
+
+This repository is not directly accessible from the UBI RHEL8 image (`registry.access.redhat.com/ubi8/ubi:latest`).
+
+So we need to copy from a register RHEL8 machine certificates and subsccription manager configuration files.
+
+SO on a `RHEL8` physical machine (or a virtual machine) connected to the OpenShift Cluster, recover the entitlement and the RH subscription manager configs:
+
+```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
+```
+
+These configmaps and secret will be shared by all the build configs in your OC project. No need to do it each time.
+
+**CAUTION: 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**.
+
+```bash
+oc delete secret etc-pki-entitlement
+oc delete cm rhsm-conf
+oc delete cm rhsm-ca
+```
+
+**LAST POINT: your OC project SHALL be `oai`.**
+
+# 2. Build the Builder shared image #
+
+In our Eurecom/OSA environment we need to pass a GIT proxy.
+
+2 things are impacted by this situation:
+
+*  In `openshift/oai-ran-rh8-build-config.yml` file
+   * `httpProxy: http://proxy.eurecom.fr:8080` 
+   * `httpsProxy: https://proxy.eurecom.fr:8080`
+*  Add a environment variable to the build config
+
+```bash
+oc apply -f openshift/oai-ran-rh8-image-stream.yml
+oc apply -f openshift/oai-ran-rh8-build-config.yml
+oc set env bc/oai-ran-rhel8-build-config NEEDED_GIT_PROXY=http://proxy.eurecom.fr:8080
+oc start-build oai-ran-rhel8-build-config --follow
+```
+
+In case you do NOT require a GIT proxy: **you SHALL remove the 2 lines in `openshift/oai-ran-rh8-build-config.yml` file.**
+
+And no need to add a `NEEDED_GIT_PROXY` variable to the build config.
+
+```bash
+oc apply -f openshift/oai-ran-rh8-image-stream.yml
+oc apply -f openshift/modified-oai-ran-rh8-build-config.yml
+oc start-build oai-ran-rhel8-build-config --follow
+```
+
+After a while it should be successful.
+
+# 3. Build an OAI target image #
+
+For the example the eNB:
+
+```bash
+oc apply -f openshift/oai-enb-rh8-image-stream.yml
+oc apply -f openshift/oai-enb-rh8-build-config.yml
+oc start-build oai-enb-rh8-build-config --follow
+```
+
+**CAUTION: if you are pushing modifications to the branch you are using, it won't be taken into account besides the Dockerfile.**
+
+**Because the source files are copied during the shared image creation.**
+
+**Only way to regenerate images w/ modified source code is to re-start from step #2.**
+
+# 4. Deployment using HELM charts #
+
+**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/
+```
diff --git a/openshift/oc_init_enb.sh b/openshift/oc_init_enb.sh
deleted file mode 100644
index 6154363cd9..0000000000
--- a/openshift/oc_init_enb.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-oc apply -f openshift/oai-enb-image-stream.yml
-oc apply -f openshift/oai-enb-build-config.yml
-oc set env bc/oai-enb-build-config NEEDED_GIT_PROXY=http://proxy.eurecom.fr:8080
-oc start-build oai-enb-build-config --follow
diff --git a/openshift/oc_init_gnb.sh b/openshift/oc_init_gnb.sh
deleted file mode 100644
index e7a570bb43..0000000000
--- a/openshift/oc_init_gnb.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-oc apply -f openshift/oai-gnb-image-stream.yml
-oc apply -f openshift/oai-gnb-build-config.yml
-oc set env bc/oai-gnb-build-config NEEDED_GIT_PROXY=http://proxy.eurecom.fr:8080
-oc start-build oai-gnb-build-config --follow
diff --git a/openshift/oc_init_ran.sh b/openshift/oc_init_ran.sh
deleted file mode 100644
index 57dbb662e8..0000000000
--- a/openshift/oc_init_ran.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-oc apply -f openshift/oai-ran-image-stream.yml
-oc apply -f openshift/oai-ran-build-config.yml
-oc set env bc/oai-ran-build-config NEEDED_GIT_PROXY=http://proxy.eurecom.fr:8080
-oc start-build oai-ran-build-config --follow
-- 
2.26.2