blob: 3b1391df55da1ff7f2aff81077c85afcfad21a55 [file] [log] [blame]
Scott Bakerfab7c9e2021-07-29 17:12:16 -07001.. vim: syntax=rst
2
3Aether ROC Developer Guide
4==========================
5
6Background / Development Environment
7------------------------------------
8
9This document assumes familiarity with Kubernetes and Helm, and that a Kubernetes/Helm development
10environment has already been deployed in the developers work environment.
11This development environment can use any of a number of potential mechanisms -- including KinD, Kubeadm, etc.
12The Aether-in-a-Box script is one potential way to setup a development environment, but not the only way.
13As an alternative to the developers local machine, a remote environment can be set up, for example on
14cloud infrastructure such as cloudlab.
15
Sean Condoneb95cd62021-08-04 19:44:18 +010016.. note:: When ROC is deployed it is unsecured by default, with no Authentication or Authorization.
17 To secure ROC so that the Authentication and Authorization can be tested, follow the Securing ROC
18 guide below :ref:`securing_roc`
19
Scott Bakerfab7c9e2021-07-29 17:12:16 -070020Installing Prerequisites
21------------------------
22
23Atomix and onos-operator must be installed::
24
25 # create necessary namespaces
26 kubectl create namespace micro-onos
27
28 # install atomix
29 helm -n kube-system install atomix-controller atomix/atomix-controller
30 helm -n kube-system install atomix-raft-storage atomix/atomix-raft-storage
31
32 # install the onos operator
33 helm install -n kube-system onos-operator onosproject/onos-operator
34
35
36Verify that these services were installed properly.
37You should see pods for *atomix-controller*, *atomix-raft-storage-controller*,
38*onos-operator-config*, and *onos-operator-topo*.
39Execute these commands::
40
41 kubectl -n kube-system get pods | grep -i atomix
42 kubectl -n kube-system get pods | grep -i onos
43
44
45Create a values-override.yaml
46-----------------------------
47
48Youll want to override several of the defaults in the ROC helm charts::
49
50 cat > values-override.yaml <<EOF
51 import:
52 onos-gui:
53 enabled: true
54
55 onos-gui:
56 ingress:
57 enabled: false
58
59 sdcore-adapter-v3:
60 prometheusEnabled: false
61
62 sdcore-exporter:
63 prometheusEnabled: false
64
65 onos-exporter:
66 prometheusEnabled: false
67
68 aether-roc-gui-v3:
69 ingress:
70 enabled: false
71 EOF
72
73Installing the Aether-Roc-Umbrella Helm chart
74---------------------------------------------
75
76Add the necessary helm repositories::
77
78 # obtain username and password from Michelle and/or ONF infra team
79 export repo_user=<username>
80 export repo_password=<password>
81 helm repo add sdran --username "$repo_user" --password "$repo_password" https://sdrancharts.onosproject.org
82
83Aether-Roc-Umbrella will bring up the ROC and its services::
84
85 helm -n micro-onos install aether-roc-umbrella sdran/aether-roc-umbrella -f values-override.yaml
86
87 kubectl wait pod -n micro-onos --for=condition=Ready -l type=config --timeout=300s
88
89
Sean Condonf918f642021-08-04 14:32:53 +010090.. _posting-the-mega-patch:
91
Scott Bakerfab7c9e2021-07-29 17:12:16 -070092Posting the mega-patch
93----------------------
94
95The ROC usually comes up in a blank state -- there are no Enterprises, UEs, or other artifacts present in it.
96The mega-patch is an example patch that populates the ROC with some sample enterprises, UEs, slices, etc.
97Execute the following::
98
99 # launch a port-forward for the API
100 # this will continue to run in the background
101 kubectl -n micro-onos port-forward service/aether-roc-api --address 0.0.0.0 8181:8181 &
102
103 git clone https://github.com/onosproject/aether-roc-api.git
104
105 # execute the mega-patch (it will post via CURL to localhost:8181)
106 bash ~/path/to/aether-roc-api/examples/MEGA_Patch.curl
107
108
109You may wish to customize the mega patch.
110For example, by default the patch configures the sdcore-adapter to push to sdcore-test-dummy.
111You could configure it to push to a live aether-in-a-box core by doing something like this::
112
113 sed -i 's^http://aether-roc-umbrella-sdcore-test-dummy/v1/config/5g^http://webui.omec.svc.cluster.local:9089/config^g' MEGA_Patch.curl
114
115 #apply the patch
116 ./MEGA_Patch.curl
117
118(Note that if your Aether-in-a-Box was installed on a different machine that port-forwarding may be necessary)
119
120
121Expected CURL output from a successful mega-patch post will be a UUID.
122You can also verify that the mega-patch was successful by going into the aether-roc-gui in a browser
123(see the section on useful port-forwards below). The GUI may open to a dashboard that is unpopulated -- you
124can use the dropdown menu (upper-right hand corner of the screen) to select an object such as VCS and you
125will see a list of VCS.
126
127 |ROCGUI|
128
129Uninstalling the Aether-Roc-Umbrella Helm chart
130-----------------------------------------------
131
132To tear things back down, usually as part of a developer loop prior to redeploying again, do the following::
133
134 helm -n micro-onos del aether-roc-umbrella
135
136If the uninstall hangs or if a subsequent reinstall hangs, it could be an issue with some of the CRDs
137not getting cleaned up. The following may be useful::
138
139 # fix stuck finalizers in operator CRDs
140
141 kubectl -n micro-onos patch entities connectivity-service-v2 --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]'
142
143 kubectl -n micro-onos patch entities connectivity-service-v3 --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]'
144
145 kubectl -n micro-onos patch kind aether --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]'
146
147Useful port forwards
148--------------------
149
150Port forwarding is often necessary to allow access to ports inside of Kubernetes pods that use ClusterIP addressing.
151Note that you typically need to leave a port-forward running (you can put it in the background).
152Also, If you redeploy the ROC and/or if a pod crashes then you might have to restart a port-forward.
153The following port-forwards may be useful::
154
155 # aether-roc-api
156
157 kubectl -n micro-onos port-forward service/aether-roc-api --address 0.0.0.0 8181:8181
158
159 # aether-roc-gui
160
161 kubectl -n micro-onos port-forward service/aether-roc-gui --address 0.0.0.0 8183:80
162
163 # grafana
164
165 kubectl -n micro-onos port-forward service/aether-roc-umbrella-grafana --address 0.0.0.0 8187:80
166
167 # onos gui
168
169 kubectl -n micro-onos port-forward service/onos-gui --address 0.0.0.0 8182:80
170
171Aether-roc-api and aether-roc-gui are in our experience the most useful two port-forwards.
172Aether-roc-api is useful to be able to POST REST API requests.
173Aether-roc-gui is useful to be able to interactively browse the current configuration.
174
175Deploying using custom images
176-----------------------------
177
178Custom images may be used by editing the values-override.yaml file.
179For example, to deploy a custom sdcore-adapter::
180
181 sdcore-adapter-v3:
182
183 prometheusEnabled: false
184
185 image:
186
187 repository: my-private-repo/sdcore-adapter
188
189 tag: my-tag
190
191 pullPolicy: Always
192
193The above example assumes you have published a docker images at my-private-repo/sdcore-adapter:my-tag.
194My particular workflow is to deploy a local-docker registry and push my images to that.
195Please do not publish ONF images to a public repository unless the image is intended to be public.
196Several ONF repositories are private, and therefore their docker artifacts should also be private.
197
198There are alternatives to using a private docker repository.
199For example, if you are using kubadm, then you may be able to simply tag the image locally.
200If youre using KinD, then you can push a local image to into the kind cluster::
201
202 kind load docker-image sdcore-adapter:my-tag
203
204Inspecting logs
205---------------
206
207Most of the relevant Kubernetes pods are in the micro-onos namespace.
208The names may change from deployment to deployment, so start by getting a list of pods::
209
210 kubectl -n micro-onos get pods
211
212Then you can inspect a specific pod/container::
213
214 kubectl -n micro-onos logs sdcore-adapter-v3-7468cc58dc-ktctz sdcore-adapter-v3
215
Sean Condoneb95cd62021-08-04 19:44:18 +0100216.. _securing_roc:
217
218Securing ROC
219------------
220
221When deploying ROC with the **aether-roc-umbrella** chart, secure mode can be enabled by
222specifying an OpenID Connect (OIDC) issuer like::
223
224 helm -n micro-onos install aether-roc-umbrella sdran/aether-roc-umbrella \
225 --set onos-config.openidc.issuer=http://dex-ldap-umbrella:5556 \
226 --set aether-roc-gui-v3.openidc.issuer=http://dex-ldap-umbrella:5556
227
228The choice of OIDC issuer in this case is **dex-ldap-umbrella**
229
230dex-ldap-umbrella
231~~~~~~~~~~~~~~~~~
232
233Dex is a cloud native OIDC Issuer than can act as a front end to several authentication systems
234e.g. LDAP, Crowd, Google, GitHub
235
236Dex-LDAP-Umbrella is a Helm chart that combines a Dex server with an LDAP installation, and an
237LDAP administration tool. It can be deployed in to the same cluster namespace as **aether-roc-umbrella**.
238
239Its LDAP server is populated with 7 different users in the 2 example enterprises - *starbucks* and *acme*.
240
241When running it should be available at *http://dex-ldap-umbrella:5556/.well-known/openid-configuration*.
242
243See `dex-ldap-umbrella <https://github.com/onosproject/onos-helm-charts/tree/master/dex-ldap-umbrella#readme>`_
244for more details.
245
246As an alternative there is a public Dex server connected to the ONF Crowd server, that allows
247ONF staff to login with their own credentials:
248See `public dex <https://dex.aetherproject.org/dex/.well-known/openid-configuration>`_ for more details.
249
250.. note:: Your RBAC access to ROC will be limited by the groups you belong to in Crowd.
251
252Role Based Access Control
253~~~~~~~~~~~~~~~~~~~~~~~~~
254When secured, access to the configuration in ROC is limited by the **groups** that a user belongs to.
255
256* **AetherROCAdmin** - users in this group have full read **and** write access to all configuration.
257* *<enterprise>* - users in a group the lowercase name of an enterprise, will have **read** access to that enterprise.
258* **EnterpriseAdmin** - users in this group will have read **and** write access the enterprise they belong to.
259
260 For example in *dex-ldap-umbrella* the user *Daisy Duke* belongs to *starbucks* **and**
261 *EnterpriseAdmin* and so has read **and** write access to items linked with *starbucks* enterprise.
262
263 By comparison the user *Elmer Fudd* belongs only to *starbucks* group and so has only **read** access to items
264 linked with the *starbucks* enterprise.
265
266Requests to a Secure System
267~~~~~~~~~~~~~~~~~~~~~~~~~~~
268When configuration is retrieved or updated through *aether-config*, a Bearer Token in the
269form of a Json Web Token (JWT) issued by the selected OIDC Issuer server must accompany
270the request as an Authorization Header.
271
272This applies to both the REST interface of *aether-roc-api* **and** the *gnmi* interface of
273*aether-rconfig*.
274
275In the Aether ROC, a Bearer Token can be generated by logging in and selecting API Key from the
276menu. This pops up a window with a copy button, where the key can be copied.
277
278The key will expire after 24 hours.
279
280.. image:: images/aether-roc-gui-copy-api-key.png
281 :width: 580
282 :alt: Aether ROC GUI allows copying of API Key to clipboard
283
284Accessing the REST interface from a tool like Postman, should include this Auth token.
285
286.. image:: images/postman-auth-token.png
287 :width: 930
288 :alt: Postman showing Authentication Token pasted in
289
290Logging
291~~~~~~~
292The logs of *aether-config* will contain the **username** and **timestamp** of
293any **gnmi** call when security is enabled.
294
295.. image:: images/aether-config-log.png
296 :width: 887
297 :alt: aether-config log message showing username and timestamp
298
299Troubleshooting Secure Access
300~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
301While every effort has been made to ensure that securing Aether is simple and effective,
302some difficulties may arise.
303
304One of the most important steps is to validate that the OIDC Issuer (Dex server) can be reached
305from the browser. The **well_known** URL should be available and show the important endpoints are correct.
306
307.. image:: images/dex-ldap-umbrella-well-known.png
308 :width: 580
309 :alt: Dex Well Known page
310
311If logged out of the Browser when accessing the Aether ROC GUI, accessing any page of the application should
312redirect to the Dex login page.
313
314.. image:: images/dex-ldap-login-page.png
315 :width: 493
316 :alt: Dex Login page
317
318When logged in the User details can be seen by clicking the User's name in the drop down menu.
319This shows the **groups** that the user belongs to, and can be used to debug RBAC issues.
320
321.. image:: images/aether-roc-gui-user-details.png
322 :width: 700
323 :alt: User Details page
324
325When you sign out of the ROC GUI, if you are not redirected to the Dex Login Page,
326you should check the Developer Console of the browser. The console should show the correct
327OIDC issuer (dex server), and that Auth is enabled.
328
329.. image:: images/aether-roc-gui-console-loggedin.png
330 :width: 418
331 :alt: Browser Console showing correct configuration
332
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700333Some exercises to get familiar
334------------------------------
335
3361) Deploy the ROC and POST the mega-patch, go into the aether-roc-GUI and click through the VCS, DeviceGroup, and
337other objects to see that they were created as expected.
338
3392) Examine the log of the sdcore-adapter-v3 container.
340It should be attempting to push the mega-patch’s changes.
341If you don’t have a core available, it may be failing the push, but you should see the attempts.
342
3433) Change an object in the GUI.
344Watch the sdcore-adapter-v3 log file and see that the adapter attempts to push the change.
345
3464) Try POSTing a change via the API.
347Observe the sdcore-adapter-v3 log file and see that the adapter attempts to push the change.
348
3495) Deploy a 5G Aether-in-a-Box (See sd-core developer guide), modify the mega-patch to specify the URL for the
350Aether-in-a-Box webui container, POST the mega-patch, and observe that the changes were correctly pushed via the
351sdcore-adapter-v3 into the sd-core’s webui container (webui container log will show configuration as it is
352received)
353
354.. |ROCGUI| image:: images/rocgui.png
Sean Condoneb95cd62021-08-04 19:44:18 +0100355 :width: 945
356 :alt: ROC GUI showing list of VCS