blob: 5c05d951e2d1b067478574374c0a07cbc15cf696 [file] [log] [blame]
Scott Bakerfab7c9e2021-07-29 17:12:16 -07001.. vim: syntax=rst
2
Scott Bakerf07ec232022-03-08 12:20:24 -08003.. _roc-developer-guide:
4
Scott Bakerfab7c9e2021-07-29 17:12:16 -07005Aether ROC Developer Guide
6==========================
7
8Background / Development Environment
9------------------------------------
10
11This document assumes familiarity with Kubernetes and Helm, and that a Kubernetes/Helm development
12environment has already been deployed in the developer’s work environment.
Zack Williams1ae109e2021-07-27 11:17:04 -070013
14This development environment can use any of a number of potential mechanisms -- including KinD, kubeadm, etc.
15
Scott Bakerfab7c9e2021-07-29 17:12:16 -070016The Aether-in-a-Box script is one potential way to setup a development environment, but not the only way.
17As an alternative to the developer’s local machine, a remote environment can be set up, for example on
Zack Williams1ae109e2021-07-27 11:17:04 -070018cloud infrastructure such as Cloudlab.
Scott Bakerfab7c9e2021-07-29 17:12:16 -070019
Sean Condoneb95cd62021-08-04 19:44:18 +010020.. note:: When ROC is deployed it is unsecured by default, with no Authentication or Authorization.
21 To secure ROC so that the Authentication and Authorization can be tested, follow the Securing ROC
22 guide below :ref:`securing_roc`
23
Scott Bakerfab7c9e2021-07-29 17:12:16 -070024Installing Prerequisites
25------------------------
26
27Atomix and onos-operator must be installed::
28
29 # create necessary namespaces
30 kubectl create namespace micro-onos
31
Andy Bavier4c425412021-08-27 14:39:38 -070032 # add repos
33 helm repo add atomix https://charts.atomix.io
34 helm repo add onosproject https://charts.onosproject.org
35 helm repo update
36
Scott Bakerfab7c9e2021-07-29 17:12:16 -070037 # install atomix
SeanCondon909d55b2022-04-25 17:59:46 +010038 export ATOMIX_CONTROLLER_VERSION=0.6.9
Sean Condon257687f2021-08-23 11:13:20 +010039 helm -n kube-system install atomix-controller atomix/atomix-controller --version $ATOMIX_CONTROLLER_VERSION
SeanCondon909d55b2022-04-25 17:59:46 +010040 export ATOMIX_RAFT_VERSION=0.1.26
Sean Condon70dcf702021-08-24 10:57:29 +010041 helm -n kube-system install atomix-raft-storage atomix/atomix-raft-storage --version $ATOMIX_RAFT_VERSION
Scott Bakerfab7c9e2021-07-29 17:12:16 -070042
43 # install the onos operator
SeanCondon909d55b2022-04-25 17:59:46 +010044 ONOS_OPERATOR_VERSION=0.5.3
Sean Condon257687f2021-08-23 11:13:20 +010045 helm install -n kube-system onos-operator onosproject/onos-operator --version $ONOS_OPERATOR_VERSION
Scott Bakerfab7c9e2021-07-29 17:12:16 -070046
Sean Condon257687f2021-08-23 11:13:20 +010047.. note:: The ROC is sensitive to the versions of Atomix and onos-operator installed. The values
Sean Condon8d55a1e2021-11-11 12:49:00 +000048 shown above are correct for the 1.4.42- versions of the *aether-roc-umbrella*.
Sean Condon257687f2021-08-23 11:13:20 +010049
50.. list-table:: ROC support component version matrix
Sean Condon70dcf702021-08-24 10:57:29 +010051 :widths: 40 20 20 20
Sean Condon257687f2021-08-23 11:13:20 +010052 :header-rows: 1
53
54 * - ROC Version
55 - Atomix Controller
56 - Atomix Raft
57 - Onos Operator
Sean Condon70dcf702021-08-24 10:57:29 +010058 * - 1.2.25-1.2.45
Sean Condon257687f2021-08-23 11:13:20 +010059 - 0.6.7
60 - 0.1.8
61 - 0.4.8
Zack Williams90578fa2021-11-04 11:57:23 -070062 * - 1.3.0-1.3.10
Sean Condon70dcf702021-08-24 10:57:29 +010063 - 0.6.8
64 - 0.1.9
Sean Condon1df1fcf2021-09-20 09:45:39 +010065 - 0.4.10
Zack Williams90578fa2021-11-04 11:57:23 -070066 * - 1.3.11-,1.4.0-
67 - 0.6.8
68 - 0.1.14
69 - 0.4.12
Sean Condon8d55a1e2021-11-11 12:49:00 +000070 * - 1.4.42-
71 - 0.6.8
72 - 0.1.15
73 - 0.4.14
Scott Baker6bd3d192022-03-03 14:50:38 -080074 * - 2.0.29-
75 - 0.6.8
76 - 0.1.16
77 - 0.5.1
SeanCondon909d55b2022-04-25 17:59:46 +010078 * - 2.1.8-
79 - 0.6.9
80 - 0.1.26
81 - 0.5.3
Scott Bakerfab7c9e2021-07-29 17:12:16 -070082
83Verify that these services were installed properly.
84You should see pods for *atomix-controller*, *atomix-raft-storage-controller*,
SeanCondon909d55b2022-04-25 17:59:46 +010085*onos-operator-app*, and *onos-operator-topo*.
Scott Bakerfab7c9e2021-07-29 17:12:16 -070086Execute these commands::
87
Sean Condon257687f2021-08-23 11:13:20 +010088 helm -n kube-system list
Scott Bakerfab7c9e2021-07-29 17:12:16 -070089 kubectl -n kube-system get pods | grep -i atomix
90 kubectl -n kube-system get pods | grep -i onos
91
Scott Bakerfab7c9e2021-07-29 17:12:16 -070092Create a values-override.yaml
93-----------------------------
94
95You’ll want to override several of the defaults in the ROC helm charts::
96
97 cat > values-override.yaml <<EOF
SeanCondon909d55b2022-04-25 17:59:46 +010098 aether-roc-gui-v2-1:
Scott Bakerb46a6ed2021-08-02 14:03:10 -070099 ingress:
100 enabled: false
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700101 EOF
102
Zack Williams1ae109e2021-07-27 11:17:04 -0700103Installing the ``aether-roc-umbrella`` Helm chart
104-------------------------------------------------
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700105
106Add the necessary helm repositories::
107
Scott Baker6bd3d192022-03-03 14:50:38 -0800108 helm repo add aether https://charts.aetherproject.org
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700109
Zack Williams1ae109e2021-07-27 11:17:04 -0700110``aether-roc-umbrella`` will bring up the ROC and its services::
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700111
Sean Condon1df1fcf2021-09-20 09:45:39 +0100112 helm -n micro-onos install aether-roc-umbrella aether/aether-roc-umbrella -f values-override.yaml
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700113
114 kubectl wait pod -n micro-onos --for=condition=Ready -l type=config --timeout=300s
115
116
Sean Condonf918f642021-08-04 14:32:53 +0100117.. _posting-the-mega-patch:
118
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700119Posting the mega-patch
120----------------------
121
122The ROC usually comes up in a blank state -- there are no Enterprises, UEs, or other artifacts present in it.
123The mega-patch is an example patch that populates the ROC with some sample enterprises, UEs, slices, etc.
SeanCondon909d55b2022-04-25 17:59:46 +0100124
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700125Execute the following::
126
127 # launch a port-forward for the API
128 # this will continue to run in the background
SeanCondon909d55b2022-04-25 17:59:46 +0100129
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700130 kubectl -n micro-onos port-forward service/aether-roc-api --address 0.0.0.0 8181:8181 &
131
SeanCondon909d55b2022-04-25 17:59:46 +0100132 curl http://localhost:8181/targets
133 # It should show a list of the configure enterprises: [{"name":"defaultent"},{"name":"acme"},{"name":"starbucks"}
134
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700135 git clone https://github.com/onosproject/aether-roc-api.git
136
137 # execute the mega-patch (it will post via CURL to localhost:8181)
Scott Bakerae024102022-02-23 10:55:28 -0800138 bash ~/path/to/aether-roc-api/examples/MEGA_Patch_20.curl
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700139
SeanCondon909d55b2022-04-25 17:59:46 +0100140.. note:: To configure Aether-In-a-Box - no port-forward is necessary - use the URL *http://<hostname>:31194/aether-roc-api/*
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700141
142You may wish to customize the mega patch.
Zack Williams1ae109e2021-07-27 11:17:04 -0700143
144For example, by default the patch configures the ``sdcore-adapter`` to push to
145``sdcore-test-dummy``.
146
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700147You could configure it to push to a live aether-in-a-box core by doing something like this::
148
SeanCondon909d55b2022-04-25 17:59:46 +0100149 sed -i 's^http://aether-roc-umbrella-sdcore-test-dummy/v1/config/5g^http://webui.omec.svc.cluster.local:9089/config^g' MEGA_Patch_21.curl
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700150
151 #apply the patch
Scott Bakerae024102022-02-23 10:55:28 -0800152 ./MEGA_Patch_20.curl
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700153
154(Note that if your Aether-in-a-Box was installed on a different machine that port-forwarding may be necessary)
155
156
157Expected CURL output from a successful mega-patch post will be a UUID.
Zack Williams1ae109e2021-07-27 11:17:04 -0700158
159You can also verify that the mega-patch was successful by going into the
160``aether-roc-gui`` in a browser (see the section on useful port-forwards
161below). The GUI may open to a dashboard that is unpopulated -- you can use the
162dropdown menu (upper-right hand corner of the screen) to select an object such
Scott Bakerae024102022-02-23 10:55:28 -0800163as Slice and you will see a list of slices.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700164
165 |ROCGUI|
166
SeanCondon909d55b2022-04-25 17:59:46 +0100167Adding new Enterprises
168----------------------
169
170Enterprises are stored in `onos-topo` outside of `onos-config` are are usually only created by system administrators
171during the onboarding of new customers (tenants) on Aether.
172
173There is currently no way of adding new Enterprises through the ROC GUI or the ROC API - it can be
174done in the 2 ways in the following sections.
175
176Enterprises are specified as Entities using CRDs, and the `onos-operator` ensures that these are created
177as `entitites` inside `onos-topo`.
178
179To check that the current list of enterprises (as CRDs), the following command may be used::
180
181 kubectl -n micro-onos get entities
182
183and to check that the `onos-operator` does indeed take effect, the ROC API endpoint `/targets` can be used to list the
184`enterprises`.
185
186Another option is to use the `onos-cli` pod to query `onos-topo` directly::
187
188 kubectl -n micro-onos exec deployment/onos-cli -- onos topo get entities -v
189
190Adding new Enterprises through Helm Chart
191^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
192
193To have an entity added at **start up of the cluster** it can be added through the Helm Chart in the `values.yaml`
194under `enterprises`. e.g.::
195
196 enterprises:
197 - id: starbucks
198 name: Starbucks Enterprise
199 lat: 52.5150
200 long: 13.3885
201
202This will load the `enterprise` as an Entity CRD through the `onos-operator`.
203
204Adding new Enterprises through `onos-topo`
205^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
206
207New `enterprises` can be added to a live running system through the `onos-topo` command line (bypassing
208the `onos-operator`). For example::
209
210 kubectl -n micro-onos exec deployment/onos-cli -- \
211 onos topo create entity new-enterprise \
212 -a onos.topo.Configurable='{"address”:”sdcore-adapter-v2-1:5150”,”version”:”2.1.x”,”type”:”aether”}' \
213 -a onos.topo.TLSOptions='{"insecure":true}' \
214 -a onos.topo.Asset='{"name”:”New Enterprise”}' \
215 -a onos.topo.MastershipState='{}' \
216 -k aether
217
Zack Williams1ae109e2021-07-27 11:17:04 -0700218Uninstalling the ``aether-roc-umbrella`` Helm chart
219---------------------------------------------------
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700220
221To tear things back down, usually as part of a developer loop prior to redeploying again, do the following::
222
223 helm -n micro-onos del aether-roc-umbrella
224
225If the uninstall hangs or if a subsequent reinstall hangs, it could be an issue with some of the CRDs
226not getting cleaned up. The following may be useful::
227
Sean Condon8d55a1e2021-11-11 12:49:00 +0000228 # fix stuck finalizers in operator CRDs
Scott Baker6bd3d192022-03-03 14:50:38 -0800229 kubectl -n micro-onos patch entities connectivity-service-v2 --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]' && \
SeanCondon909d55b2022-04-25 17:59:46 +0100230 kubectl -n micro-onos patch entities starbucks --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]' && \
231 kubectl -n micro-onos patch entities acme-v2 --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]' && \
232 kubectl -n micro-onos patch entities defult-ent --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]' && \
Sean Condon8d55a1e2021-11-11 12:49:00 +0000233 kubectl -n micro-onos patch entities plproxy-amp --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]' && \
234 kubectl -n micro-onos patch entities plproxy-acc --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]' && \
235 kubectl -n micro-onos patch kind plproxy --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]' && \
236 kubectl -n micro-onos patch kind aether --type json --patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]'
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700237
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700238
239Useful port forwards
240--------------------
241
242Port forwarding is often necessary to allow access to ports inside of Kubernetes pods that use ClusterIP addressing.
243Note that you typically need to leave a port-forward running (you can put it in the background).
244Also, If you redeploy the ROC and/or if a pod crashes then you might have to restart a port-forward.
SeanCondon909d55b2022-04-25 17:59:46 +0100245
246.. note:: With Aether-In-a-Box no port-forward is necessary - the GUI can be accessed
247 at ``http://<hostname>:31194`` and the API at ``http://<hostname>:31194/aether-roc-api/``
248
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700249The following port-forwards may be useful::
250
251 # aether-roc-api
252
253 kubectl -n micro-onos port-forward service/aether-roc-api --address 0.0.0.0 8181:8181
254
255 # aether-roc-gui
256
SeanCondon909d55b2022-04-25 17:59:46 +0100257 kubectl -n micro-onos port-forward service/aether-roc-gui-v2-1 --address 0.0.0.0 8183:80
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700258
259 # grafana
260
261 kubectl -n micro-onos port-forward service/aether-roc-umbrella-grafana --address 0.0.0.0 8187:80
262
Zack Williams1ae109e2021-07-27 11:17:04 -0700263``aether-roc-api`` and ``aether-roc-gui`` are in our experience the most useful two port-forwards.
264
265``aether-roc-api`` is useful to be able to POST REST API requests.
266
267``aether-roc-gui`` is useful to be able to interactively browse the current configuration.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700268
Sean Condon257687f2021-08-23 11:13:20 +0100269.. note:: Internally the ``aether-roc-gui`` operates a Reverse Proxy on the ``aether-roc-api``. This
270 means that if you have done a ``port-forward`` to ``aether-roc-gui`` say on port ``8183`` there's no
271 need to do another on the ``aether-roc-api`` instead you can access the API on
272 ``http://localhost:8183/aether-roc-api``
273
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700274Deploying using custom images
275-----------------------------
276
277Custom images may be used by editing the values-override.yaml file.
Zack Williams1ae109e2021-07-27 11:17:04 -0700278For example, to deploy a custom ``sdcore-adapter``::
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700279
SeanCondon909d55b2022-04-25 17:59:46 +0100280 sdcore-adapter-v2-1:
Scott Baker6bd3d192022-03-03 14:50:38 -0800281 prometheusEnabled: false
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700282 image:
Scott Baker6bd3d192022-03-03 14:50:38 -0800283 repository: my-private-repo/sdcore-adapter
284 tag: my-tag
285 pullPolicy: Always
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700286
Zack Williams1ae109e2021-07-27 11:17:04 -0700287The above example assumes you have published a docker images at ``my-private-repo/sdcore-adapter:my-tag``.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700288My particular workflow is to deploy a local-docker registry and push my images to that.
289Please do not publish ONF images to a public repository unless the image is intended to be public.
290Several ONF repositories are private, and therefore their docker artifacts should also be private.
291
292There are alternatives to using a private docker repository.
Zack Williams1ae109e2021-07-27 11:17:04 -0700293For example, if you are using kubeadm, then you may be able to simply tag the image locally.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700294If you’re using KinD, then you can push a local image to into the kind cluster::
295
296 kind load docker-image sdcore-adapter:my-tag
297
Scott Bakerabcfc6e2021-09-08 22:37:51 -0700298Developing using a custom onos-config
299-------------------------------------
300
Scott Baker6bd3d192022-03-03 14:50:38 -0800301The onos-config helm chart is responsible for loading model plugins at runtime. You can override which
302plugins it loads, and optionally override the image for onos-config as well. For example::
Scott Bakerabcfc6e2021-09-08 22:37:51 -0700303
Scott Baker6bd3d192022-03-03 14:50:38 -0800304 onos-config:
305 image:
306 tag: mytag
307 repository: mydockeraccount/onos-config
308 modelPlugins:
SeanCondon909d55b2022-04-25 17:59:46 +0100309 - name: aether-2
310 image: onosproject/aether-2.0.x:2.0.3-aether-2.0.x
311 endpoint: localhost
312 port: 5152
313 - name: aether-2-1
314 image: onosproject/aether-2.1.x:2.1.3-aether-2.1.x
315 endpoint: localhost
316 port: 5153
Scott Bakerabcfc6e2021-09-08 22:37:51 -0700317
Scott Baker6bd3d192022-03-03 14:50:38 -0800318In the above example, the onos-config image will be pulled from `mydockeraccount`, and it will install
319two plugins for v2 and v4 models, from that same docker account.
Scott Bakerabcfc6e2021-09-08 22:37:51 -0700320
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700321Inspecting logs
322---------------
323
324Most of the relevant Kubernetes pods are in the micro-onos namespace.
325The names may change from deployment to deployment, so start by getting a list of pods::
326
327 kubectl -n micro-onos get pods
328
329Then you can inspect a specific pod/container::
330
SeanCondon909d55b2022-04-25 17:59:46 +0100331 kubectl -n micro-onos logs deployment/sdcore-adapter-v2-1
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700332
Sean Condoneb95cd62021-08-04 19:44:18 +0100333.. _securing_roc:
334
335Securing ROC
336------------
337
Sean Condon9e182f62021-12-06 17:35:53 -0800338keycloak-dev.onlab.us
339^^^^^^^^^^^^^^^^^^^^^
340Keycloak is an Open Source Identity and Access Management for Modern Applications and
341Services. It can be used as an OIDC Issuer than can act as a front end to several authentication systems
342e.g. LDAP, Crowd, Google, GitHub
343
Zack Williams1ae109e2021-07-27 11:17:04 -0700344When deploying ROC with the ``aether-roc-umbrella`` chart, secure mode can be enabled by
Sean Condoneb95cd62021-08-04 19:44:18 +0100345specifying an OpenID Connect (OIDC) issuer like::
346
Andy Baviere86261e2021-09-21 11:05:18 -0700347 helm -n micro-onos install aether-roc-umbrella aether/aether-roc-umbrella \
Sean Condon9e182f62021-12-06 17:35:53 -0800348 --set onos-config.openidc.issuer=https://keycloak-dev.onlab.us/auth/realms/master \
349 --set aether-roc-api.openidc.issuer=https://keycloak-dev.onlab.us/auth/realms/master \
SeanCondon909d55b2022-04-25 17:59:46 +0100350 --set aether-roc-gui-v2-1.openidc.issuer=https://keycloak-dev.onlab.us/auth/realms/master \
Sean Condon9e182f62021-12-06 17:35:53 -0800351 --set prom-label-proxy-acc.config.openidc.issuer=https://keycloak-dev.onlab.us/auth/realms/master \
352 --set prom-label-proxy-amp.config.openidc.issuer=https://keycloak-dev.onlab.us/auth/realms/master
Sean Condoneb95cd62021-08-04 19:44:18 +0100353
Sean Condon9e182f62021-12-06 17:35:53 -0800354The choice of OIDC issuer in this case is the **development** Keycloak server at https://keycloak-dev.onlab.us
Sean Condoneb95cd62021-08-04 19:44:18 +0100355
Sean Condon9e182f62021-12-06 17:35:53 -0800356Its LDAP server is populated with 7 different users in the 2 example enterprises - *starbucks* and *acme*.
Sean Condon948aeaa2021-09-29 12:08:30 +0100357
Sean Condon9e182f62021-12-06 17:35:53 -0800358+------------------+----------+-------------+-----------------+-----------------+-----------------+-----------+------+
359| User | login | mixedGroup: | charactersGroup | AetherROCAdmin | EnterpriseAdmin | starbucks | acme |
360+==================+==========+=============+=================+=================+=================+===========+======+
361| Alice Admin | alicea | ✓ | | ✓ | | | |
362+------------------+----------+-------------+-----------------+-----------------+-----------------+-----------+------+
363| Bob Cratchit | bobc | ✓ | ✓ | | | | |
364+------------------+----------+-------------+-----------------+-----------------+-----------------+-----------+------+
365| Charlie Brown | charlieb | | ✓ | | | | |
366+------------------+----------+-------------+-----------------+-----------------+-----------------+-----------+------+
367| Daisy Duke | daisyd | | ✓ | | ✓ | ✓ | |
368+------------------+----------+-------------+-----------------+-----------------+-----------------+-----------+------+
369| Elmer Fudd | elmerf | | ✓ | | | ✓ | |
370+------------------+----------+-------------+-----------------+-----------------+-----------------+-----------+------+
371| Fred Flintstone | fredf | | ✓ | | ✓ | | ✓ |
372+------------------+----------+-------------+-----------------+-----------------+-----------------+-----------+------+
373| Gandalf The Grey | gandalfg | | ✓ | | | | ✓ |
374+------------------+----------+-------------+-----------------+-----------------+-----------------+-----------+------+
375
376.. note:: all users have the same password - please contact `aether-roc <https://onf-internal.slack.com/archives/C01S7BVC1FX>`_ slack group if you need it
377
378.. note:: Because of the SSO feature of Keycloak you will need to explicitly logout of Keycloak to change users.
379 To login as 2 separate users at the same time, use a private browser window for one.
380
381Running your own Keycloak Server
382^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
383
384It is also possible to run your own own Keycloak server inside of Kubernetes.
Sean Condon948aeaa2021-09-29 12:08:30 +0100385
386``keycloak-389-umbrella`` is a Helm chart that combines a Keycloak server with an LDAP
Sean Condon8d55a1e2021-11-11 12:49:00 +0000387installation (389 Directory Server), and an LDAP administration tool. It can be deployed (with name ``k3u`` in to the
388same cluster namespace as ``aether-roc-umbrella``::
Sean Condon948aeaa2021-09-29 12:08:30 +0100389
Sean Condon8d55a1e2021-11-11 12:49:00 +0000390 helm -n micro-onos install k3u onosproject/keycloak-389-umbrella
391
Sean Condon8d55a1e2021-11-11 12:49:00 +0000392To make the deployment available with the hostname ``k3u-keycloak`` requires:
393
394#. a port forward like ``kubectl -n micro-onos port-forward service/k3u-keycloak --address=0.0.0.0 5557:80``
395#. editing your ``/etc/hosts`` file (on the machine where your browser runs) so that the name ``k3u-keycloak`` points
396 to the IP address of the machine where the ``port-forward`` runs (usually ``localhost``).
Sean Condon948aeaa2021-09-29 12:08:30 +0100397
398When running it should be available at *http://k3u-keycloak:5557/auth/realms/master/.well-known/openid-configuration*.
399
Sean Condon8d55a1e2021-11-11 12:49:00 +0000400.. note:: You can access the Keycloak management page from *http://k3u-keycloak:5557/auth/admin* but you must
Sean Condon9e182f62021-12-06 17:35:53 -0800401 login as `admin`. Because of the SSO feature of Keycloak this will affect your Aether ROC GUI login too.
Sean Condon8d55a1e2021-11-11 12:49:00 +0000402 To login as 2 separate users at the same time, use a private browser window for one.
403
Sean Condon9e182f62021-12-06 17:35:53 -0800404.. note:: Services inside the cluster (e.g. onos-config) should set the issuer to *https://k3u-keycloak:80/auth/realms/master*
405 on port 80, while the aether-roc-gui should use port 5557
406
407As any OIDC server can work with ROC you can alternately use ``dex-ldap-umbrella``
408(`deprecated <https://github.com/onosproject/onos-helm-charts/tree/master/dex-ldap-umbrella>`_).
409
Sean Condon948aeaa2021-09-29 12:08:30 +0100410See `keycloak-389-umbrella <https://github.com/onosproject/onos-helm-charts/tree/master/keycloak-389-umbrella#readme>`_
411for more details.
412
Sean Condon9e182f62021-12-06 17:35:53 -0800413Production Environment
414^^^^^^^^^^^^^^^^^^^^^^
415In a production environment, the public Aether Keycloak (with its LDAP server populated with real Aether users and groups) should be used.
Sean Condon948aeaa2021-09-29 12:08:30 +0100416See `public keycloak <https://keycloak.opennetworking.org/auth/realms/master/.well-known/openid-configuration>`_ for more details.
417
418.. note:: Your RBAC access to ROC will be limited by the groups you belong to in its LDAP store.
419
Sean Condoneb95cd62021-08-04 19:44:18 +0100420Role Based Access Control
Sean Condon9e182f62021-12-06 17:35:53 -0800421^^^^^^^^^^^^^^^^^^^^^^^^^
Zack Williams1ae109e2021-07-27 11:17:04 -0700422
Sean Condoneb95cd62021-08-04 19:44:18 +0100423When secured, access to the configuration in ROC is limited by the **groups** that a user belongs to.
424
425* **AetherROCAdmin** - users in this group have full read **and** write access to all configuration.
426* *<enterprise>* - users in a group the lowercase name of an enterprise, will have **read** access to that enterprise.
427* **EnterpriseAdmin** - users in this group will have read **and** write access the enterprise they belong to.
428
Sean Condon948aeaa2021-09-29 12:08:30 +0100429 For example in *keycloak-389-umbrella* the user *Daisy Duke* belongs to *starbucks* **and**
Sean Condoneb95cd62021-08-04 19:44:18 +0100430 *EnterpriseAdmin* and so has read **and** write access to items linked with *starbucks* enterprise.
431
432 By comparison the user *Elmer Fudd* belongs only to *starbucks* group and so has only **read** access to items
433 linked with the *starbucks* enterprise.
434
435Requests to a Secure System
Sean Condon9e182f62021-12-06 17:35:53 -0800436^^^^^^^^^^^^^^^^^^^^^^^^^^^
Zack Williams1ae109e2021-07-27 11:17:04 -0700437
Sean Condoneb95cd62021-08-04 19:44:18 +0100438When configuration is retrieved or updated through *aether-config*, a Bearer Token in the
Zack Williams1ae109e2021-07-27 11:17:04 -0700439form of a JSON Web Token (JWT) issued by the selected OIDC Issuer server must accompany
Sean Condoneb95cd62021-08-04 19:44:18 +0100440the request as an Authorization Header.
441
Zack Williams1ae109e2021-07-27 11:17:04 -0700442This applies to both the REST interface of ``aether-roc-api`` **and** the *gnmi* interface of
Sean Condon8d55a1e2021-11-11 12:49:00 +0000443``aether-config``.
Sean Condoneb95cd62021-08-04 19:44:18 +0100444
445In the Aether ROC, a Bearer Token can be generated by logging in and selecting API Key from the
446menu. This pops up a window with a copy button, where the key can be copied.
447
Sean Condon8d55a1e2021-11-11 12:49:00 +0000448Alternatively with Keycloak a Token may be requested programmatically through the Keycloak API::
449
Sean Condon9e182f62021-12-06 17:35:53 -0800450 curl --location --request POST 'https://keycloak-dev.onlab.us/auth/realms/master/protocol/openid-connect/token' \
Sean Condon8d55a1e2021-11-11 12:49:00 +0000451 --header 'Content-Type: application/x-www-form-urlencoded' \
452 --data-urlencode 'grant_type=password' \
453 --data-urlencode 'client_id=aether-roc-gui' \
454 --data-urlencode 'username=alicea' \
455 --data-urlencode 'password=password' \
Scott Baker6bd3d192022-03-03 14:50:38 -0800456 --data-urlencode 'scope=openid profile email groups' | jq "{access_token}"
Sean Condon8d55a1e2021-11-11 12:49:00 +0000457
458
Sean Condoneb95cd62021-08-04 19:44:18 +0100459The key will expire after 24 hours.
460
461.. image:: images/aether-roc-gui-copy-api-key.png
462 :width: 580
463 :alt: Aether ROC GUI allows copying of API Key to clipboard
464
465Accessing the REST interface from a tool like Postman, should include this Auth token.
466
467.. image:: images/postman-auth-token.png
468 :width: 930
469 :alt: Postman showing Authentication Token pasted in
470
471Logging
Zack Williams1ae109e2021-07-27 11:17:04 -0700472"""""""
473
Sean Condoneb95cd62021-08-04 19:44:18 +0100474The logs of *aether-config* will contain the **username** and **timestamp** of
475any **gnmi** call when security is enabled.
476
477.. image:: images/aether-config-log.png
478 :width: 887
479 :alt: aether-config log message showing username and timestamp
480
Sean Condon435be9a2021-08-06 14:28:37 +0100481Accessing GUI from an external system
Zack Williams1ae109e2021-07-27 11:17:04 -0700482"""""""""""""""""""""""""""""""""""""
483
Sean Condon435be9a2021-08-06 14:28:37 +0100484To access the ROC GUI from a computer outside the Cluster machine using *port-forwarding* then
485it is necessary to:
486
487* Ensure that all *port-forward*'s have **--address=0.0.0.0**
488* Add to the IP address of the cluster machine to the **/etc/hosts** of the outside computer as::
489
Sean Condon948aeaa2021-09-29 12:08:30 +0100490 <ip address of cluster> k3u-keycloak aether-roc-gui
Sean Condon9e182f62021-12-06 17:35:53 -0800491* Verify that you can access the Keycloak server by its name *https://keycloak-dev.onlab.us/auth/realms/master/.well-known/openid-configuration*
Zack Williams1ae109e2021-07-27 11:17:04 -0700492* Access the GUI through the hostname (rather than ip address) ``http://aether-roc-gui:8183``
Sean Condon435be9a2021-08-06 14:28:37 +0100493
Sean Condoneb95cd62021-08-04 19:44:18 +0100494Troubleshooting Secure Access
Zack Williams1ae109e2021-07-27 11:17:04 -0700495"""""""""""""""""""""""""""""
496
Sean Condoneb95cd62021-08-04 19:44:18 +0100497While every effort has been made to ensure that securing Aether is simple and effective,
498some difficulties may arise.
499
Sean Condon948aeaa2021-09-29 12:08:30 +0100500One of the most important steps is to validate that the OIDC Issuer (Keycloak server) can be reached
Sean Condoneb95cd62021-08-04 19:44:18 +0100501from the browser. The **well_known** URL should be available and show the important endpoints are correct.
502
Sean Condon948aeaa2021-09-29 12:08:30 +0100503.. image:: images/keycloak-389-umbrella-well-known.png
Sean Condoneb95cd62021-08-04 19:44:18 +0100504 :width: 580
Sean Condon948aeaa2021-09-29 12:08:30 +0100505 :alt: Keycloak Well Known page
Sean Condoneb95cd62021-08-04 19:44:18 +0100506
507If logged out of the Browser when accessing the Aether ROC GUI, accessing any page of the application should
Sean Condon948aeaa2021-09-29 12:08:30 +0100508redirect to the Keycloak login page.
Sean Condoneb95cd62021-08-04 19:44:18 +0100509
Sean Condon948aeaa2021-09-29 12:08:30 +0100510.. image:: images/keycloak-ldap-login-page.png
Sean Condoneb95cd62021-08-04 19:44:18 +0100511 :width: 493
Sean Condon948aeaa2021-09-29 12:08:30 +0100512 :alt: Keycloak Login page
Sean Condoneb95cd62021-08-04 19:44:18 +0100513
514When logged in the User details can be seen by clicking the User's name in the drop down menu.
515This shows the **groups** that the user belongs to, and can be used to debug RBAC issues.
516
517.. image:: images/aether-roc-gui-user-details.png
518 :width: 700
519 :alt: User Details page
520
Sean Condon948aeaa2021-09-29 12:08:30 +0100521When you sign out of the ROC GUI, if you are not redirected to the Keycloak Login Page,
Sean Condoneb95cd62021-08-04 19:44:18 +0100522you should check the Developer Console of the browser. The console should show the correct
Sean Condon948aeaa2021-09-29 12:08:30 +0100523OIDC issuer (Keycloak server), and that Auth is enabled.
Sean Condoneb95cd62021-08-04 19:44:18 +0100524
525.. image:: images/aether-roc-gui-console-loggedin.png
526 :width: 418
527 :alt: Browser Console showing correct configuration
528
Sean Condon8d55a1e2021-11-11 12:49:00 +0000529Keycloak installation issues
530^^^^^^^^^^^^^^^^^^^^^^^^^^^^
531
532The ``fedorea-389ds`` pod may restart a couple of times before it finally reaches running.
533There are 2 post install jobs that take some time to start. Overall allow 3 minutes for startup.
534
535Some users are finding that the Fedora pod will never reach a running state on resource
536constrained machines. This issue is being investigated.
537
538
Scott Bakerb46a6ed2021-08-02 14:03:10 -0700539ROC Data Model Conventions and Requirements
540-------------------------------------------
541
542The MEGA-Patch described above will bring up a fully compliant sample data model.
543However, it may be useful to bring up your own data model, customized to a different
544site of sites. This subsection documents conventions and requirements for the Aether
Zack Williams1ae109e2021-07-27 11:17:04 -0700545modeling within the ROC.
Scott Bakerb46a6ed2021-08-02 14:03:10 -0700546
547The ROC models must be configured with the following:
548
549* A default enterprise with the id `defaultent`.
Scott Bakerb46a6ed2021-08-02 14:03:10 -0700550* A default site with the id `defaultent-defaultsite`.
Scott Bakerae024102022-02-23 10:55:28 -0800551 This site should be within the `defaultent` enterprise.
552 This site is used by ``subscriber-proxy`` to place detected SIM Cards that cannot
553 be matched to an existing site.
Scott Bakerb46a6ed2021-08-02 14:03:10 -0700554
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700555Some exercises to get familiar
556------------------------------
557
Zack Williams1ae109e2021-07-27 11:17:04 -07005581. Deploy the ROC and POST the mega-patch, go into the ``aether-roc-gui`` and click
Scott Bakerae024102022-02-23 10:55:28 -0800559 through the Slice, DeviceGroup, and other objects to see that they were
Zack Williams1ae109e2021-07-27 11:17:04 -0700560 created as expected.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700561
Scott Baker6bd3d192022-03-03 14:50:38 -08005622. Examine the log of the ``sdcore-adapter-v2`` container. It should be
Zack Williams1ae109e2021-07-27 11:17:04 -0700563 attempting to push the mega-patch’s changes. If you don’t have a core
564 available, it may be failing the push, but you should see the attempts.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700565
Scott Baker6bd3d192022-03-03 14:50:38 -08005663. Change an object in the GUI. Watch the ``sdcore-adapter-v2`` log file and
Zack Williams1ae109e2021-07-27 11:17:04 -0700567 see that the adapter attempts to push the change.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700568
Scott Baker6bd3d192022-03-03 14:50:38 -08005694. Try POSTing a change via the API. Observe the ``sdcore-adapter-v2`` log
Zack Williams1ae109e2021-07-27 11:17:04 -0700570 file and see that the adapter attempts to push the change.
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700571
Andy Bavierf73c3d22021-08-30 10:29:06 -07005725. Deploy a 5G Aether-in-a-Box (See :doc:`Setting Up Aether-in-a-Box
573 <aiab>`), modify the mega-patch to specify the URL for the Aether-in-a-Box
Zack Williams1ae109e2021-07-27 11:17:04 -0700574 ``webui`` container, POST the mega-patch, and observe that the changes were
Scott Baker6bd3d192022-03-03 14:50:38 -0800575 correctly pushed via the ``sdcore-adapter-v2`` into the ``sd-core``’s
Zack Williams1ae109e2021-07-27 11:17:04 -0700576 ``webui`` container (``webui`` container log will show configuration as it
577 is received)
Scott Bakerfab7c9e2021-07-29 17:12:16 -0700578
579.. |ROCGUI| image:: images/rocgui.png
Sean Condoneb95cd62021-08-04 19:44:18 +0100580 :width: 945
Scott Bakerae024102022-02-23 10:55:28 -0800581 :alt: ROC GUI showing list of Slices