Add a k8s cloud site to ONAP
[doc.git] / docs / guides / onap-operator / cloud_site / k8s / index.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0
2 .. International License.  http://creativecommons.org/licenses/by/4.0
3 .. Copyright 2017 AT&T Intellectual Property.  All rights reserved.
4
5
6 Adding a Kubernetes (K8S) Cloud Site to ONAP
7 ============================================
8
9 The following guide describes how to configure ONAP to be able to instantiate
10 a service in a new cloud site based on Kubernetes.
11
12 There are three major steps to configure a new k8s cloud site.
13
14 * Declare the new cloud site within SO
15 * Declare the new cloud site (or new Region Name) in AAI
16 * Multicloud registration and declaration
17
18 In this guideline the following parameters/values will be used
19
20 * Complex Name: My_Complex
21 * Region Name: K8S_Cloud_Region_Name
22 * Openstack Tenant Region Value: TenantRegion
23 * Cloud Owner: MyCompanyName
24
25 STEP 1 : Declare the new cloud site within SO
26 ---------------------------------------------
27
28 Add new k8s cloud site in mariadb database
29 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30
31 In a Unix Terminal, to get the pod id that is providing
32 the MariaDB database:
33
34 ::
35
36   kubectl -n onap get pod | grep mariadb-galera
37
38 To connect to this pod
39 (in this example, the SO pod id is "onap-mariadb-galera-mariadb-galera-0"):
40
41 ::
42
43   kubectl -n onap exec -ti onap-mariadb-galera-mariadb-galera-0 sh
44
45 Then modify the data in the MariaDB:
46
47 ::
48
49   mysql --user=so_admin --password=so_Admin123
50   USE catalogdb
51   INSERT INTO cloud_sites(ID, REGION_ID, IDENTITY_SERVICE_ID, CLOUD_VERSION, CLLI, ORCHESTRATOR) values("K8S_Cloud_Region_Name", "K8S_Cloud_Region_Name", "DEFAULT_KEYSTONE", "2.5", "My_Complex", "multicloud");
52
53 ONAP SO VNF Adapter Rest API endpoint version shall be set to version "v2"
54 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55
56 in a unix terminal:
57
58 to find the right config map name:
59
60 ::
61
62   kubectl -n onap get configmap | grep so-so-bpmn-infra-app-configmap
63
64
65 to edit and change the configmap:
66
67 ::
68
69   kubectl -n onap edit configmap onap-so-so-bpmn-infra-app-configmap
70
71 in the section "vnf", modify the rest endpoint:
72
73 ::
74
75            vnf:
76              endpoint: http://so-openstack-adapter.onap:8087/services/VnfAdapter
77              rest:
78   -            endpoint: http://so-openstack-adapter.onap:8087/services/rest/v1/vnfs
79   +            endpoint: http://so-openstack-adapter.onap:8087/services/rest/v2/vnfs
80            volume-groups:
81              rest:
82                endpoint: http://so-openstack-adapter.onapg:8087/services/rest/v1/volume-groups
83
84
85 Having modified the configmap, it is necessary to delete the pod bpmn-infra in
86 order it takes the modification into account.
87
88 to find the right pod name:
89
90 ::
91
92   kubectl get po -n onap |grep bpmn-infra
93
94
95 You need to find the pod that is similar to the following pod id:
96
97 "onap-so-so-bpmn-infra-79fdf6f9d5-t8qr4"
98
99
100 to delete the pod:
101
102 ::
103
104   kubectl -n onap delete onap-so-so-bpmn-infra-79fdf6f9d5-t8qr4
105
106
107 Then, wait for the pod to restart. To check:
108
109 ::
110
111   kubectl -n onap get po | grep so-so
112
113 STEP 2 : Declare the new cloud site in AAI
114 ------------------------------------------
115
116 Declare a Complex in ONAP AAI
117 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118
119
120 A Cloud Site is located in a Building called "Complex" object
121 in ONAP AAI datamodel.
122
123 AAI REST API is used to declare the complex object.
124
125 Here is an example using "curl" tool to send the API request.
126
127 The new Complex is named "My_Complex" in this example.
128
129
130 ::
131
132   curl -X PUT \
133   https://aai.api.sparky.simpledemo.onap.org:30233/aai/v16/cloud-infrastructure/complexes/complex/My_Complex \
134   -H 'Accept: application/json' \
135   -H 'Authorization: Basic QUFJOkFBSQ==' \
136   -H 'Cache-Control: no-cache' \
137   -H 'Content-Type: application/json' \
138   -H 'Real-Time: true' \
139   -H 'X-FromAppId: jimmy-postman' \
140   -H 'X-TransactionId: 9999' \
141   -d '{
142     "physical-location-id": "My_Complex",
143     "data-center-code": "example-data-center-code-val-5556",
144     "complex-name": "My_Complex",
145     "identity-url": "example-identity-url-val-56898",
146     "physical-location-type": "example-physical-location-type-val-7608",
147     "street1": "example-street1-val-34205",
148     "street2": "example-street2-val-99210",
149     "city": "Beijing",
150     "state": "example-state-val-59487",
151     "postal-code": "100000",
152     "country": "example-country-val-94173",
153     "region": "example-region-val-13893",
154     "latitude": "39.9042",
155     "longitude": "106.4074",
156     "elevation": "example-elevation-val-30253",
157     "lata": "example-lata-val-46073"
158     }' -k
159
160
161 Check the Complexes in ONAP AAI:
162
163 ::
164
165   curl -X GET \
166     https://aai.api.sparky.simpledemo.onap.org:30233/aai/v16/cloud-infrastructure/complexes \
167     -H 'Accept: application/json' \
168     -H 'Authorization: Basic QUFJOkFBSQ==' \
169     -H 'X-FromAppId: AAI' \
170     -H 'X-TransactionId: 808b54e3-e563-4144-a1b9-e24e2ed93d4f' \
171     -H 'cache-control: no-cache' -k
172
173 Declare a Cloud Site in ONAP AAI
174 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
175
176 To declare a Cloud Site, you need to use the AAI REST API.
177
178 The new Cloud site is named "K8S_Cloud_Region_Name" in this example.
179
180 The Cloud Owner is named "MyCompanyName" in this example.
181
182 parameter "complex-name" relates to the Complex you previously declared.
183
184 parameter "cloud-type" takes the value "k8s"
185
186 The following parameters specifying openstack cloud tenant are set with dummy
187 values:
188
189 * parameter "cloud-extra-info"
190 * parameter "esr-system-info-list"
191
192 The association to the complex object is set in the curl request to create the
193 k8s cloud region.
194
195 ::
196
197   curl -X PUT \
198   https://aai.api.sparky.simpledemo.onap.org:30233/aai/v16/cloud-infrastructure/cloud-regions/cloud-region/MyCompanyName/K8S_Cloud_Region_Name \
199   -H 'Accept: application/json' \
200   -H 'Authorization: Basic QUFJOkFBSQ==' \
201   -H 'Cache-Control: no-cache' \
202   -H 'Content-Type: application/json' \
203   -H 'Postman-Token: 8b9b95ae-91d6-4436-90fa-69cb4d2db99c' \
204   -H 'Real-Time: true' \
205   -H 'X-FromAppId: jimmy-postman' \
206   -H 'X-TransactionId: 9999' \
207   -d '{
208       "cloud-owner": "MyCompanyName",
209       "cloud-region-id": "K8S_Cloud_Region_Name",
210       "cloud-type": "k8s",
211       "owner-defined-type": "t1",
212       "cloud-region-version": "1.0",
213       "complex-name": "My_Complex",
214       "cloud-zone": "CloudZone",
215       "sriov-automation": false,
216       "identity-url": "",
217       "cloud-extra-info":"{\"openstack-region-id\":\"TenantRegion\"}"
218       "esr-system-info-list": {
219           "esr-system-info": [
220               {
221                 "esr-system-info-id": "55f97d59-6cc3-49df-8e69-926565f00066",
222                 "service-url": "http://10.12.25.2:5000/v3",
223                 "user-name": "demo",
224                 "password": "onapdemo",
225                 "system-type": "VIM",
226                 "ssl-insecure": true,
227                 "cloud-domain": "Default",
228                 "default-tenant": "OOF",
229                 "tenant-id": "6bbd2981b210461dbc8fe846df1a7808",
230                 "system-status": "active"
231               }
232           ]
233         },
234         "relationship-list": {
235             "relationship": [
236                 {
237                     "related-to": "complex",
238                     "relationship-label": "org.onap.relationships.inventory.LocatedIn",
239                     "related-link": "/aai/v13/cloud-infrastructure/complexes/complex/My_Complex",
240                     "relationship-data": [
241                         {
242                             "relationship-key": "complex.physical-location-id",
243                             "relationship-value": "My_Complex"
244                         }
245                     ]
246                 }
247             ]
248         }
249     }' -k
250
251
252 Check the Cloud Site creation in ONAP AAI:
253
254 ::
255
256   curl -X GET \
257     https://aai.api.sparky.simpledemo.onap.org:30233/aai/v16/cloud-infrastructure/cloud-regions \
258     -H 'Accept: application/json' \
259     -H 'Authorization: Basic QUFJOkFBSQ==' \
260     -H 'X-FromAppId: AAI' \
261     -H 'X-TransactionId: 808b54e3-e563-4144-a1b9-e24e2ed93d4f' \
262     -H 'cache-control: no-cache' -k
263
264 STEP 3 : Multicloud registration and declaration
265 ------------------------------------------------
266
267 Register k8s site in multicloud
268 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
269
270 The k8s site (K8S_Cloud_Region_Name) associated to the cloud owner
271 (MyCompanyName) shall be registered in multicloud.
272
273 ::
274
275   curl -X POST \
276   https://msb.api.discovery.simpledemo.onap.org:30283/api/multicloud-titaniumcloud/v1/MyCompanyName/K8S_Cloud_Region_Name/registry \
277   -H 'Accept: application/json' \
278   -H 'Cache-Control: no-cache' \
279   -H 'Content-Type: application/json' -k
280
281
282 The registration is successfull if the answer is : 202 Accepted.
283
284 Looking at the log of windriver multicloud pod, some errors are raised due to
285 the fact that the pod attempts to contact the dummy openstack tenant.
286 ::
287
288   kubectl -n onap logs -f onap-multicloud-multicloud-windriver-77dbc6b694-t74qm -c multicloud-windriver
289
290
291 Declare k8s connnectivity information in multicloud
292 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
293
294 ::
295
296   curl -X POST \
297   https://msb.api.discovery.simpledemo.onap.org:30283/api/multicloud-k8s/v1/v1/connectivity-info \
298   -i -F "metadata=<post.json;type=application/json" \
299   -F file=@config/config -k
300
301   # Content of post.json
302   {
303     "cloud-region" : "K8S_Cloud_Region_Name",
304     "cloud-owner" :  "MyCompanyName",
305     "other-connectivity-list" : {
306     }
307   }
308
309   #config is the .kube/config file of your k8s cloud environment
310
311 To check that the connectivity information is correctly applied:
312
313 ::
314
315   curl -i GET \
316   https://msb.api.discovery.simpledemo.onap.org:30283/api/multicloud-k8s/v1/v1/connectivity-info/K8S_Cloud_Region_Name -k