blob: e3a3dac12ef05a828197639b86823afbc3db19cb [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.
Zack Williams1ae109e2021-07-27 11:17:04 -070011
12This development environment can use any of a number of potential mechanisms -- including KinD, kubeadm, etc.
13
Scott Bakerfab7c9e2021-07-29 17:12:16 -070014The Aether-in-a-Box script is one potential way to setup a development environment, but not the only way.
15As an alternative to the developers local machine, a remote environment can be set up, for example on
Zack Williams1ae109e2021-07-27 11:17:04 -070016cloud infrastructure such as Cloudlab.
Scott Bakerfab7c9e2021-07-29 17:12:16 -070017
Sean Condoneb95cd62021-08-04 19:44:18 +010018.. note:: When ROC is deployed it is unsecured by default, with no Authentication or Authorization.
19 To secure ROC so that the Authentication and Authorization can be tested, follow the Securing ROC
20 guide below :ref:`securing_roc`
21
Scott Bakerfab7c9e2021-07-29 17:12:16 -070022Installing Prerequisites
23------------------------
24
25Atomix and onos-operator must be installed::
26
27 # create necessary namespaces
28 kubectl create namespace micro-onos
29
30 # install atomix
31 helm -n kube-system install atomix-controller atomix/atomix-controller
32 helm -n kube-system install atomix-raft-storage atomix/atomix-raft-storage
33
34 # install the onos operator
35 helm install -n kube-system onos-operator onosproject/onos-operator
36
37
38Verify that these services were installed properly.
39You should see pods for *atomix-controller*, *atomix-raft-storage-controller*,
40*onos-operator-config*, and *onos-operator-topo*.
41Execute these commands::
42
43 kubectl -n kube-system get pods | grep -i atomix
44 kubectl -n kube-system get pods | grep -i onos
45
46
47Create a values-override.yaml
48-----------------------------
49
50Youll want to override several of the defaults in the ROC helm charts::
51
52 cat > values-override.yaml <<EOF
53 import:
Scott Bakerb46a6ed2021-08-02 14:03:10 -070054 onos-gui:
55 enabled: true
Scott Bakerfab7c9e2021-07-29 17:12:16 -070056
57 onos-gui:
Scott Bakerb46a6ed2021-08-02 14:03:10 -070058 ingress:
59 enabled: false
Scott Bakerfab7c9e2021-07-29 17:12:16 -070060
61 aether-roc-gui-v3:
Scott Bakerb46a6ed2021-08-02 14:03:10 -070062 ingress:
63 enabled: false
Scott Bakerfab7c9e2021-07-29 17:12:16 -070064 EOF
65
Zack Williams1ae109e2021-07-27 11:17:04 -070066Installing the ``aether-roc-umbrella`` Helm chart
67-------------------------------------------------
Scott Bakerfab7c9e2021-07-29 17:12:16 -070068
69Add the necessary helm repositories::
70
71 # obtain username and password from Michelle and/or ONF infra team
72 export repo_user=<username>
73 export repo_password=<password>
74 helm repo add sdran --username "$repo_user" --password "$repo_password" https://sdrancharts.onosproject.org
75
Zack Williams1ae109e2021-07-27 11:17:04 -070076``aether-roc-umbrella`` will bring up the ROC and its services::
Scott Bakerfab7c9e2021-07-29 17:12:16 -070077
78 helm -n micro-onos install aether-roc-umbrella sdran/aether-roc-umbrella -f values-override.yaml
79
80 kubectl wait pod -n micro-onos --for=condition=Ready -l type=config --timeout=300s
81
82
Sean Condonf918f642021-08-04 14:32:53 +010083.. _posting-the-mega-patch:
84
Scott Bakerfab7c9e2021-07-29 17:12:16 -070085Posting the mega-patch
86----------------------
87
88The ROC usually comes up in a blank state -- there are no Enterprises, UEs, or other artifacts present in it.
89The mega-patch is an example patch that populates the ROC with some sample enterprises, UEs, slices, etc.
90Execute the following::
91
92 # launch a port-forward for the API
93 # this will continue to run in the background
94 kubectl -n micro-onos port-forward service/aether-roc-api --address 0.0.0.0 8181:8181 &
95
96 git clone https://github.com/onosproject/aether-roc-api.git
97
98 # execute the mega-patch (it will post via CURL to localhost:8181)
99 bash ~/path/to/aether-roc-api/examples/MEGA_Patch.curl
100
101
102You may wish to customize the mega patch.
Zack Williams1ae109e2021-07-27 11:17:04 -0700103
104For example, by default the patch configures the ``sdcore-adapter`` to push to
105``sdcore-test-dummy``.
106
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700107You could configure it to push to a live aether-in-a-box core by doing something like this::
108
109 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
110
111 #apply the patch
112 ./MEGA_Patch.curl
113
114(Note that if your Aether-in-a-Box was installed on a different machine that port-forwarding may be necessary)
115
116
117Expected CURL output from a successful mega-patch post will be a UUID.
Zack Williams1ae109e2021-07-27 11:17:04 -0700118
119You can also verify that the mega-patch was successful by going into the
120``aether-roc-gui`` in a browser (see the section on useful port-forwards
121below). The GUI may open to a dashboard that is unpopulated -- you can use the
122dropdown menu (upper-right hand corner of the screen) to select an object such
123as VCS and you will see a list of VCS.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700124
125 |ROCGUI|
126
Zack Williams1ae109e2021-07-27 11:17:04 -0700127Uninstalling the ``aether-roc-umbrella`` Helm chart
128---------------------------------------------------
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700129
130To tear things back down, usually as part of a developer loop prior to redeploying again, do the following::
131
132 helm -n micro-onos del aether-roc-umbrella
133
134If the uninstall hangs or if a subsequent reinstall hangs, it could be an issue with some of the CRDs
135not getting cleaned up. The following may be useful::
136
137 # fix stuck finalizers in operator CRDs
138
139 kubectl -n micro-onos patch entities connectivity-service-v2 --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]'
140
141 kubectl -n micro-onos patch entities connectivity-service-v3 --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]'
142
143 kubectl -n micro-onos patch kind aether --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]'
144
145Useful port forwards
146--------------------
147
148Port forwarding is often necessary to allow access to ports inside of Kubernetes pods that use ClusterIP addressing.
149Note that you typically need to leave a port-forward running (you can put it in the background).
150Also, If you redeploy the ROC and/or if a pod crashes then you might have to restart a port-forward.
151The following port-forwards may be useful::
152
153 # aether-roc-api
154
155 kubectl -n micro-onos port-forward service/aether-roc-api --address 0.0.0.0 8181:8181
156
157 # aether-roc-gui
158
159 kubectl -n micro-onos port-forward service/aether-roc-gui --address 0.0.0.0 8183:80
160
161 # grafana
162
163 kubectl -n micro-onos port-forward service/aether-roc-umbrella-grafana --address 0.0.0.0 8187:80
164
165 # onos gui
166
167 kubectl -n micro-onos port-forward service/onos-gui --address 0.0.0.0 8182:80
168
Zack Williams1ae109e2021-07-27 11:17:04 -0700169``aether-roc-api`` and ``aether-roc-gui`` are in our experience the most useful two port-forwards.
170
171``aether-roc-api`` is useful to be able to POST REST API requests.
172
173``aether-roc-gui`` is useful to be able to interactively browse the current configuration.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700174
175Deploying using custom images
176-----------------------------
177
178Custom images may be used by editing the values-override.yaml file.
Zack Williams1ae109e2021-07-27 11:17:04 -0700179For example, to deploy a custom ``sdcore-adapter``::
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700180
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
Zack Williams1ae109e2021-07-27 11:17:04 -0700193The above example assumes you have published a docker images at ``my-private-repo/sdcore-adapter:my-tag``.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700194My 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.
Zack Williams1ae109e2021-07-27 11:17:04 -0700199For example, if you are using kubeadm, then you may be able to simply tag the image locally.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700200If 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
Zack Williams1ae109e2021-07-27 11:17:04 -0700221When deploying ROC with the ``aether-roc-umbrella`` chart, secure mode can be enabled by
Sean Condoneb95cd62021-08-04 19:44:18 +0100222specifying 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
Zack Williams1ae109e2021-07-27 11:17:04 -0700228The choice of OIDC issuer in this case is ``dex-ldap-umbrella``.
Sean Condoneb95cd62021-08-04 19:44:18 +0100229
Zack Williams1ae109e2021-07-27 11:17:04 -0700230``dex-ldap-umbrella``
231"""""""""""""""""""""
Sean Condoneb95cd62021-08-04 19:44:18 +0100232
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
Zack Williams1ae109e2021-07-27 11:17:04 -0700236``dex-ldap-umbrella`` is a Helm chart that combines a Dex server with an LDAP
237installation, and an LDAP administration tool. It can be deployed in to the
238same cluster namespace as ``aether-roc-umbrella``.
Sean Condoneb95cd62021-08-04 19:44:18 +0100239
240Its LDAP server is populated with 7 different users in the 2 example enterprises - *starbucks* and *acme*.
241
242When running it should be available at *http://dex-ldap-umbrella:5556/.well-known/openid-configuration*.
243
244See `dex-ldap-umbrella <https://github.com/onosproject/onos-helm-charts/tree/master/dex-ldap-umbrella#readme>`_
245for more details.
246
247As an alternative there is a public Dex server connected to the ONF Crowd server, that allows
248ONF staff to login with their own credentials:
249See `public dex <https://dex.aetherproject.org/dex/.well-known/openid-configuration>`_ for more details.
250
251.. note:: Your RBAC access to ROC will be limited by the groups you belong to in Crowd.
252
253Role Based Access Control
Zack Williams1ae109e2021-07-27 11:17:04 -0700254"""""""""""""""""""""""""
255
Sean Condoneb95cd62021-08-04 19:44:18 +0100256When secured, access to the configuration in ROC is limited by the **groups** that a user belongs to.
257
258* **AetherROCAdmin** - users in this group have full read **and** write access to all configuration.
259* *<enterprise>* - users in a group the lowercase name of an enterprise, will have **read** access to that enterprise.
260* **EnterpriseAdmin** - users in this group will have read **and** write access the enterprise they belong to.
261
262 For example in *dex-ldap-umbrella* the user *Daisy Duke* belongs to *starbucks* **and**
263 *EnterpriseAdmin* and so has read **and** write access to items linked with *starbucks* enterprise.
264
265 By comparison the user *Elmer Fudd* belongs only to *starbucks* group and so has only **read** access to items
266 linked with the *starbucks* enterprise.
267
268Requests to a Secure System
Zack Williams1ae109e2021-07-27 11:17:04 -0700269"""""""""""""""""""""""""""
270
Sean Condoneb95cd62021-08-04 19:44:18 +0100271When configuration is retrieved or updated through *aether-config*, a Bearer Token in the
Zack Williams1ae109e2021-07-27 11:17:04 -0700272form of a JSON Web Token (JWT) issued by the selected OIDC Issuer server must accompany
Sean Condoneb95cd62021-08-04 19:44:18 +0100273the request as an Authorization Header.
274
Zack Williams1ae109e2021-07-27 11:17:04 -0700275This applies to both the REST interface of ``aether-roc-api`` **and** the *gnmi* interface of
276``aether-rconfig``.
Sean Condoneb95cd62021-08-04 19:44:18 +0100277
278In the Aether ROC, a Bearer Token can be generated by logging in and selecting API Key from the
279menu. This pops up a window with a copy button, where the key can be copied.
280
281The key will expire after 24 hours.
282
283.. image:: images/aether-roc-gui-copy-api-key.png
284 :width: 580
285 :alt: Aether ROC GUI allows copying of API Key to clipboard
286
287Accessing the REST interface from a tool like Postman, should include this Auth token.
288
289.. image:: images/postman-auth-token.png
290 :width: 930
291 :alt: Postman showing Authentication Token pasted in
292
293Logging
Zack Williams1ae109e2021-07-27 11:17:04 -0700294"""""""
295
Sean Condoneb95cd62021-08-04 19:44:18 +0100296The logs of *aether-config* will contain the **username** and **timestamp** of
297any **gnmi** call when security is enabled.
298
299.. image:: images/aether-config-log.png
300 :width: 887
301 :alt: aether-config log message showing username and timestamp
302
Sean Condon435be9a2021-08-06 14:28:37 +0100303Accessing GUI from an external system
Zack Williams1ae109e2021-07-27 11:17:04 -0700304"""""""""""""""""""""""""""""""""""""
305
Sean Condon435be9a2021-08-06 14:28:37 +0100306To access the ROC GUI from a computer outside the Cluster machine using *port-forwarding* then
307it is necessary to:
308
309* Ensure that all *port-forward*'s have **--address=0.0.0.0**
310* Add to the IP address of the cluster machine to the **/etc/hosts** of the outside computer as::
311
312 <ip address of cluster> dex-ldap-umbrella aether-roc-gui
313* Verify that you can access the Dex server by its name *http://dex-ldap-umbrella:5556/.well-known/openid-configuration*
Zack Williams1ae109e2021-07-27 11:17:04 -0700314* Access the GUI through the hostname (rather than ip address) ``http://aether-roc-gui:8183``
Sean Condon435be9a2021-08-06 14:28:37 +0100315
Sean Condoneb95cd62021-08-04 19:44:18 +0100316Troubleshooting Secure Access
Zack Williams1ae109e2021-07-27 11:17:04 -0700317"""""""""""""""""""""""""""""
318
Sean Condoneb95cd62021-08-04 19:44:18 +0100319While every effort has been made to ensure that securing Aether is simple and effective,
320some difficulties may arise.
321
322One of the most important steps is to validate that the OIDC Issuer (Dex server) can be reached
323from the browser. The **well_known** URL should be available and show the important endpoints are correct.
324
325.. image:: images/dex-ldap-umbrella-well-known.png
326 :width: 580
327 :alt: Dex Well Known page
328
329If logged out of the Browser when accessing the Aether ROC GUI, accessing any page of the application should
330redirect to the Dex login page.
331
332.. image:: images/dex-ldap-login-page.png
333 :width: 493
334 :alt: Dex Login page
335
336When logged in the User details can be seen by clicking the User's name in the drop down menu.
337This shows the **groups** that the user belongs to, and can be used to debug RBAC issues.
338
339.. image:: images/aether-roc-gui-user-details.png
340 :width: 700
341 :alt: User Details page
342
343When you sign out of the ROC GUI, if you are not redirected to the Dex Login Page,
344you should check the Developer Console of the browser. The console should show the correct
Zack Williams1ae109e2021-07-27 11:17:04 -0700345OIDC issuer (Dex server), and that Auth is enabled.
Sean Condoneb95cd62021-08-04 19:44:18 +0100346
347.. image:: images/aether-roc-gui-console-loggedin.png
348 :width: 418
349 :alt: Browser Console showing correct configuration
350
Scott Bakerb46a6ed2021-08-02 14:03:10 -0700351ROC Data Model Conventions and Requirements
352-------------------------------------------
353
354The MEGA-Patch described above will bring up a fully compliant sample data model.
355However, it may be useful to bring up your own data model, customized to a different
356site of sites. This subsection documents conventions and requirements for the Aether
Zack Williams1ae109e2021-07-27 11:17:04 -0700357modeling within the ROC.
Scott Bakerb46a6ed2021-08-02 14:03:10 -0700358
359The ROC models must be configured with the following:
360
361* A default enterprise with the id `defaultent`.
362* A default ip-domain with the id `defaultent-defaultip`.
363* A default site with the id `defaultent-defaultsite`.
364 This site should be linked to the `defaultent` enterprise.
365* A default device group with the id `defaultent-defaultsite-default`.
366 This device group should be linked to the `defaultent-defaultip` ip-domain
367 and the `defaultent-defaultsite` site.
368
369Each Enterprise Site must be configured with a default device group and that default
370device group's name must end in the suffix `-default`. For example, `acme-chicago-default`.
371
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700372Some exercises to get familiar
373------------------------------
374
Zack Williams1ae109e2021-07-27 11:17:04 -07003751. Deploy the ROC and POST the mega-patch, go into the ``aether-roc-gui`` and click
376 through the VCS, DeviceGroup, and other objects to see that they were
377 created as expected.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700378
Zack Williams1ae109e2021-07-27 11:17:04 -07003792. Examine the log of the ``sdcore-adapter-v3`` container. It should be
380 attempting to push the mega-patchs changes. If you dont have a core
381 available, it may be failing the push, but you should see the attempts.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700382
Zack Williams1ae109e2021-07-27 11:17:04 -07003833. Change an object in the GUI. Watch the ``sdcore-adapter-v3`` log file and
384 see that the adapter attempts to push the change.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700385
Zack Williams1ae109e2021-07-27 11:17:04 -07003864. Try POSTing a change via the API. Observe the ``sdcore-adapter-v3`` log
387 file and see that the adapter attempts to push the change.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700388
Zack Williams1ae109e2021-07-27 11:17:04 -07003895. Deploy a 5G Aether-in-a-Box (See :doc:`Aether SD-Core Developer Guide
390 <sdcore>`), modify the mega-patch to specify the URL for the Aether-in-a-Box
391 ``webui`` container, POST the mega-patch, and observe that the changes were
392 correctly pushed via the ``sdcore-adapter-v3`` into the ``sd-core``s
393 ``webui`` container (``webui`` container log will show configuration as it
394 is received)
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700395
396.. |ROCGUI| image:: images/rocgui.png
Sean Condoneb95cd62021-08-04 19:44:18 +0100397 :width: 945
398 :alt: ROC GUI showing list of VCS