c6cdac359ebc2a0e3ba3e304ecbfb46fdf3c0496
[nonrtric.git] / service-exposure / README.md
1 #
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2022 Nordix Foundation.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
19 #
20 This collection of files represent rapp service exposure prototyping in O-RAN.
21 Prerequisites: Istio should be installed on your cluster with the demo profile.
22   istioctl install --set profile=demo
23 Please refer to the istio documentation for more information.
24 The deployments have been implemented and tested using minikube.
25 If you are not using minikube, references to "minikube ip" should be changed to the appropiate value for you host.
26 To replicate these tests you will need to setup the various host path referenced in the yaml files on your own machine.
27
28 chartmuseum.yaml:             path: /var/chartmuseum/charts
29 keycloak.yaml:                path: /auth/realms/master
30 keycloak.yaml:                path: /var/keycloak/certs
31 postgres.yaml:                path: "/var/keycloak/data2"
32 postgres.yaml:                path: /tmp
33 rapps-keycloak-mgr.yaml:      path: /var/rapps/certs
34
35 or change them to match your own setup.
36
37 The certs directory contains 2 shell scripts for creating the server and client certs: server_certs.sh and client_certs.sh
38 Certs generated by the server_certs.sh script: rootCA.crt, tls.crt and tls.key go in the "/var/keycloak/certs" directory
39 Certs generated by the client_certs.sh script: client.crt, client.key, client_pub.key and rootCA.crt go in the "/var/rapps/certs" directory
40
41 Create the istio-nonrtric namespace and enable it for istio injection
42
43    kubectl create ns istio-nonrtric
44
45    kubectl label namespace istio-nonrtric istio-injection=enabled
46
47
48 All go programs need to be built prior to running the Dockerfiles
49
50    go build rapps-helm-installer.go
51    go build rapps-keycloak-mgr.go
52    go build rapps-istio-mgr.go
53    go build rapps-rapp-provider.go
54    go build rapps-rapp-invoker.go
55    go build rapps-webhook.go
56    go build rapps-jwt.go
57    go build rapps-rapp-helloworld-provider.go
58    go build rapps-rapp-helloworld-invoker1.go
59    go build rapps-rapp-helloworld-invoker2.go
60
61 Once the go programs have been compile you then need to build a docker image for each of them.
62
63    docker build -f Dockerfile_rim . -t <tag prefix>/rapps-istio-mgr
64    docker build -f Dockerfile_rkm . -t <tag prefix>/rapps-keycloak-mgr
65    docker build -f Dockerfile_rhi . -t <tag prefix>/rapps-helm-installer
66    docker build -f Dockerfile_wh . -t <tag prefix>/rapps-webhook
67    docker build -f Dockerfile_jwt . -t <tag prefix>/rapps-jwt
68    docker build -f Dockerfile_rhwp  . -t <tag prefix>/rapps-rapp-helloworld-provider
69    docker build -f Dockerfile_rhwi1  . -t <tag prefix>/rapps-rapp-helloworld-invoker1
70    docker build -f Dockerfile_rhwi2  . -t <tag prefix>/rapps-rapp-helloworld-invoker2
71
72 Image references in the yaml files/helm charts should be changed to match your own tagged images.
73
74 You will need to package your rapp charts and copy them to the /var/chartmuseum/charts directory before starting.
75
76    cd charts/
77    helm package rapp-provider
78    scp -i $(minikube ssh-key) rapp-provider-0.1.0.tgz docker@$(minikube ip):/var/chartmuseum/charts
79
80    helm package rapp-invoker
81    scp -i $(minikube ssh-key) rapp-invoker-0.1.0.tgz docker@$(minikube ip):/var/chartmuseum/charts
82
83
84 Start keycloak and postgres in the default namespace with istio injection:
85
86    istioctl kube-inject -f postgres.yaml | kubectl apply -f -
87    istioctl kube-inject -f keycloak.yaml | kubectl apply -f -
88 or use the keycloak.sh deploy script
89
90 To start the management pods run:
91
92    start_pods.sh
93
94 Once all pods have been started a list of running pods is displayed at the end of the script:
95 NAME                                                         READY   STATUS    RESTARTS   AGE
96 chartmuseum-deployment-7b8cd4c9d4-nd7dk                      1/1     Running   0          9s
97 jwt-proxy-admission-controller-deployment-66797fb6df-mlk8t   1/1     Running   0          8s
98 keycloak-846ff979bc-ndvdf                                    2/2     Running   0          2m16s
99 postgres-78b4b9d95-nqjkj                                     2/2     Running   0          2m29s
100 rapps-helm-installer-deployment-67476694-n5r24               1/1     Running   0          8s
101 rapps-istio-mgr-deployment-67c67647b6-p5s2k                  1/1     Running   0          8s
102 rapps-keycloak-mgr-deployment-7464f87575-54h9x               1/1     Running   0          8s
103
104 Get the node port for the helm installer that corresponds to port 80
105
106    kubectl get svc rapps-helm-installer
107    NAME                   TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
108    rapps-helm-installer   NodePort   10.96.58.211   <none>        80:31570/TCP   8m9s
109
110 Once these pods are up and running run:
111    curl http://<minikube ip>:<helm installer node port>/install?chart=<rapp chart name>
112    to install your rapp
113
114    e.g. curl http://192.168.49.2:31570/install?chart=rapp-hello-world-provider
115         Successfully installed release: rapp-provider
116
117    Alternativley use the deploy_rapp.sh script
118    e.g. ./deploy_rapp.sh rapp-helloworld-provider
119    Note: The line export host= should be changed to the appropaite ip for the host you are running on.
120
121 This will setup keycloak realm + client, istio policies and deploy your chart.
122
123 You should install both the provider and the invoker to see the pods communicating.
124
125 Check the invoker logs to see the test message:
126
127    kubectl logs rapp-invoker-758468d7d4-njmdn  -n istio-nonrtric
128    Received response for rapp-provider get request - Hello World!
129
130 If you want to test using the rp_test.sh file, the client_secret field needs be changed to match the secret for you keycloak client.
131 You can find this in the keycloak-mgr log.
132
133 To uninstall run:
134    curl http://<minikube ip>:<helm installer node port>/uninstall?chart=<rapp chart name>
135    e.g. curl http://192.168.49.2:31570/uninstall?chart=rapp-invoker
136         Successfully uninstalled release: rapp-invoker
137
138    Alternativley use the undeploy_rapp.sh script
139    e.g. ./undeploy_rapp.sh rapp-helloworld-provider
140
141 To stop the management pods and provider/invoker pods at the same time run:
142    stop_pods.sh
143
144 Remove postgres and keycloak with the following commands:
145    kubectl delete -f keycloak.yaml
146    kubectl delete -f postgres.yaml
147
148    or use ./keycloak.sh undeploy