fix index and reenable link
[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. Modifications 2020 Nokia Networks
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 STEP 2 : Declare the new cloud site in AAI
54 ------------------------------------------
55
56 Declare a Complex in ONAP AAI
57 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58
59
60 A Cloud Site is located in a Building called "Complex" object
61 in ONAP AAI datamodel.
62
63 AAI REST API is used to declare the complex object.
64
65 Here is an example using "curl" tool to send the API request.
66
67 The new Complex is named "My_Complex" in this example.
68
69
70 ::
71
72   curl -X PUT \
73   https://aai.api.sparky.simpledemo.onap.org:30233/aai/v16/cloud-infrastructure/complexes/complex/My_Complex \
74   -H 'Accept: application/json' \
75   -H 'Authorization: Basic QUFJOkFBSQ==' \
76   -H 'Cache-Control: no-cache' \
77   -H 'Content-Type: application/json' \
78   -H 'Real-Time: true' \
79   -H 'X-FromAppId: jimmy-postman' \
80   -H 'X-TransactionId: 9999' \
81   -d '{
82     "physical-location-id": "My_Complex",
83     "data-center-code": "example-data-center-code-val-5556",
84     "complex-name": "My_Complex",
85     "identity-url": "example-identity-url-val-56898",
86     "physical-location-type": "example-physical-location-type-val-7608",
87     "street1": "example-street1-val-34205",
88     "street2": "example-street2-val-99210",
89     "city": "Beijing",
90     "state": "example-state-val-59487",
91     "postal-code": "100000",
92     "country": "example-country-val-94173",
93     "region": "example-region-val-13893",
94     "latitude": "39.9042",
95     "longitude": "106.4074",
96     "elevation": "example-elevation-val-30253",
97     "lata": "example-lata-val-46073"
98     }' -k
99
100
101 Check the Complexes in ONAP AAI:
102
103 ::
104
105   curl -X GET \
106     https://aai.api.sparky.simpledemo.onap.org:30233/aai/v16/cloud-infrastructure/complexes \
107     -H 'Accept: application/json' \
108     -H 'Authorization: Basic QUFJOkFBSQ==' \
109     -H 'X-FromAppId: AAI' \
110     -H 'X-TransactionId: 808b54e3-e563-4144-a1b9-e24e2ed93d4f' \
111     -H 'cache-control: no-cache' -k
112
113 Declare a Cloud Site in ONAP AAI
114 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115
116 To declare a Cloud Site, you need to use the AAI REST API.
117
118 The new Cloud site is named "K8S_Cloud_Region_Name" in this example.
119
120 The Cloud Owner is named "MyCompanyName" in this example.
121
122 parameter "complex-name" relates to the Complex you previously declared.
123
124 parameter "cloud-type" takes the value "k8s"
125
126 The following parameters specifying openstack cloud tenant are set with dummy
127 values:
128
129 * parameter "cloud-extra-info"
130 * parameter "esr-system-info-list"
131
132 The association to the complex object is set in the curl request to create the
133 k8s cloud region.
134
135 ::
136
137   curl -X PUT \
138   https://aai.api.sparky.simpledemo.onap.org:30233/aai/v16/cloud-infrastructure/cloud-regions/cloud-region/MyCompanyName/K8S_Cloud_Region_Name \
139   -H 'Accept: application/json' \
140   -H 'Authorization: Basic QUFJOkFBSQ==' \
141   -H 'Cache-Control: no-cache' \
142   -H 'Content-Type: application/json' \
143   -H 'Postman-Token: 8b9b95ae-91d6-4436-90fa-69cb4d2db99c' \
144   -H 'Real-Time: true' \
145   -H 'X-FromAppId: jimmy-postman' \
146   -H 'X-TransactionId: 9999' \
147   -d '{
148       "cloud-owner": "MyCompanyName",
149       "cloud-region-id": "K8S_Cloud_Region_Name",
150       "cloud-type": "k8s",
151       "owner-defined-type": "t1",
152       "cloud-region-version": "1.0",
153       "complex-name": "My_Complex",
154       "cloud-zone": "CloudZone",
155       "sriov-automation": false,
156       "identity-url": "",
157       "cloud-extra-info":"{\"openstack-region-id\":\"TenantRegion\"}",
158       "esr-system-info-list": {
159           "esr-system-info": [
160               {
161                 "esr-system-info-id": "55f97d59-6cc3-49df-8e69-926565f00066",
162                 "service-url": "http://10.12.25.2:5000/v3",
163                 "user-name": "demo",
164                 "password": "onapdemo",
165                 "system-type": "VIM",
166                 "ssl-insecure": true,
167                 "cloud-domain": "Default",
168                 "default-tenant": "OOF",
169                 "tenant-id": "6bbd2981b210461dbc8fe846df1a7808",
170                 "system-status": "active"
171               }
172           ]
173         },
174         "relationship-list": {
175             "relationship": [
176                 {
177                     "related-to": "complex",
178                     "relationship-label": "org.onap.relationships.inventory.LocatedIn",
179                     "related-link": "/aai/v13/cloud-infrastructure/complexes/complex/My_Complex",
180                     "relationship-data": [
181                         {
182                             "relationship-key": "complex.physical-location-id",
183                             "relationship-value": "My_Complex"
184                         }
185                     ]
186                 }
187             ]
188         }
189     }' -k
190
191
192 Check the Cloud Site creation in ONAP AAI:
193
194 ::
195
196   curl -X GET \
197     https://aai.api.sparky.simpledemo.onap.org:30233/aai/v16/cloud-infrastructure/cloud-regions \
198     -H 'Accept: application/json' \
199     -H 'Authorization: Basic QUFJOkFBSQ==' \
200     -H 'X-FromAppId: AAI' \
201     -H 'X-TransactionId: 808b54e3-e563-4144-a1b9-e24e2ed93d4f' \
202     -H 'cache-control: no-cache' -k
203
204 STEP 3 : Multicloud registration and declaration
205 ------------------------------------------------
206
207 Register k8s site in multicloud
208 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
209
210 The k8s site (K8S_Cloud_Region_Name) associated to the cloud owner
211 (MyCompanyName) shall be registered in multicloud.
212
213 ::
214
215   curl -X POST \
216   https://msb.api.discovery.simpledemo.onap.org:30283/api/multicloud-titaniumcloud/v1/MyCompanyName/K8S_Cloud_Region_Name/registry \
217   -H 'Accept: application/json' \
218   -H 'Cache-Control: no-cache' \
219   -H 'Content-Type: application/json' -k
220
221
222 The registration is successfull if the answer is : 202 Accepted.
223
224 Looking at the log of windriver multicloud pod, some errors are raised due to
225 the fact that the pod attempts to contact the dummy openstack tenant.
226 ::
227
228   kubectl -n onap logs -f onap-multicloud-multicloud-windriver-77dbc6b694-t74qm -c multicloud-windriver
229
230
231 Declare k8s connnectivity information in multicloud
232 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
233
234 ::
235
236   curl -X POST \
237   https://msb.api.discovery.simpledemo.onap.org:30283/api/multicloud-k8s/v1/v1/connectivity-info \
238   -i -F "metadata=<post.json;type=application/json" \
239   -F file=@config/config -k
240
241   # Content of post.json
242   {
243     "cloud-region" : "K8S_Cloud_Region_Name",
244     "cloud-owner" :  "MyCompanyName",
245     "other-connectivity-list" : {
246     }
247   }
248
249   #config is the .kube/config file of your k8s cloud environment
250
251 To check that the connectivity information is correctly applied:
252
253 ::
254
255   curl -i GET \
256   https://msb.api.discovery.simpledemo.onap.org:30283/api/multicloud-k8s/v1/v1/connectivity-info/K8S_Cloud_Region_Name -k