1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. SPDX-License-Identifier: CC-BY-4.0
3 .. Copyright (C) 2021-2022 Wind River Systems, Inc.
5 INF O2 Service User Guide
6 =========================
8 This guide will introduce the process that make INF O2 interface work
11 - Assume you have an O2 service with INF platform environment, and you
12 have the token of the O2 service.
16 export OAM_IP=<INF_OAM_IP>
17 export SMO_TOKEN_DATA=<TOKEN of O2 Service>
19 - Discover INF platform inventory
21 - INF platform auto-discovery
23 After you installed the INF O2 service, it will automatically
24 discover the INF through the parameters that you give from the
25 “*o2service-override.yaml*”
27 The below command can get the INF platform information as O-Cloud
32 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/" \
33 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}"
37 The INF platform is a standalone environment, it has one resource
38 pool. If the INF platform is a distributed cloud environment, the
39 central cloud will be one resource pool, and each of the sub-cloud
40 will be a resource pool. All the resources that belong to the
41 cloud will be organized into the resource pool.
43 Get the resource pool information through this interface
48 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/resourcePools" \
49 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}"
51 # export the first resource pool id
52 export resourcePoolId=`curl -k -X 'GET' "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/resourcePools" -H 'accept: application/json' -H "Authorization: Bearer $SMO_TOKEN_DATA" 2>/dev/null | jq .[0].resourcePoolId | xargs echo`
54 echo ${resourcePoolId} # check the exported resource pool id
58 Resource type defined what type is the specified resource, like a
59 physical machine, memory, or CPU
61 Show all resource type
66 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/resourceTypes" \
67 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}"
71 Get the list of all resources, the value of *resourcePoolId* from
72 the result of the resource pool interface
77 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/resourcePools/${resourcePoolId}/resources" \
78 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}"
80 To get the detail of one resource, need to export one specific
81 resource id that wants to check
85 # export the first resource id in the resource pool
86 export resourceId=`curl -k -X 'GET' "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/resourcePools/${resourcePoolId}/resources" -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" 2>/dev/null | jq .[0].resourceId | xargs echo`
88 echo ${resourceId} # check the exported resource id
90 # Get the detail of one specific resource
92 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/resourcePools/${resourcePoolId}/resources/${resourceId}" \
93 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}"
95 - Deployment manager services endpoint
97 The Deployment Manager Service (DMS) related to this IMS
98 information you can use the below API to check
103 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers" \
104 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}"
106 - Provisioning INF platform with SMO endpoint configuration
108 Assume you have an SMO, and prepare the configuration of the INF
109 platform with the SMO endpoint address before the O2 service
110 installation. This provisioning of the INF O2 service will make a
111 request from the INF O2 service to SMO while the O2 service
112 installing, which make SMO know the O2 service is working.
114 After you installed the INF O2 service, it will automatically
115 register the SMO through the parameters that you give from the
120 export OCLOUD_GLOBAL_ID=<Ocloud global UUID defined by SMO>
121 export SMO_REGISTER_URL=<SMO Register URL for O2 service>
123 cat <<EOF > o2app.conf
126 ocloud_global_id = ${OCLOUD_GLOBAL_ID}
127 smo_register_url = ${SMO_REGISTER_URL}
130 - Subscribe to the INF platform resource change notification
132 Assume you have an SMO, and the SMO has an API that can receive
135 - Create a subscription to the INF O2 IMS
139 export SMO_SUBSCRIBE_CALLBACK=<The Callback URL for SMO Subscribe resource>
140 export SMO_CONSUMER_SUBSCRIPTION_ID=<The Subscription ID of the SMO Consumer>
143 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/subscriptions" \
144 -H 'accept: application/json' \
145 -H 'Content-Type: application/json' \
146 -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
148 "callback": "'${SMO_SUBSCRIBE_CALLBACK}'",
149 "consumerSubscriptionId": "'${SMO_CONSUMER_SUBSCRIPTION_ID}'",
153 - Handle resource change notification
155 When the SMO callback API gets the notification that the resource
156 of INF platform changing, use the URL to get the latest resource
157 information to update its database
159 - Subscribe to the INF platform alarm change notification
161 Assume you have an SMO, and the SMO has an API that can receive
164 - Create an alarm subscription to the INF O2 IMS
168 export SMO_SUBSCRIBE_CALLBACK=<The Callback URL for SMO Subscribe alarm>
169 export SMO_CONSUMER_SUBSCRIPTION_ID=<The Subscription ID of the SMO Consumer>
172 "https://${OAM_IP}:30205/o2ims-infrastructureMonitoring/v1/alarmSubscriptions" \
173 -H 'accept: application/json' \
174 -H 'Content-Type: application/json' \
175 -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
177 "callback": "'${SMO_SUBSCRIBE_CALLBACK}'",
178 "consumerSubscriptionId": "'${SMO_CONSUMER_SUBSCRIPTION_ID}'",
182 - Handle alarm change notification
184 When the SMO callback API gets the alarm of the INF platform, use
185 the URL to get the latest alarm event record information to get
188 - Use Kubernetes Control Client through O2 DMS profile
190 Assume you have the kubectl command tool on your local Linux
193 And install the ‘jq’ command for your Linux bash terminal. If you are
194 using Ubuntu, you can follow the below command to install it.
198 # install the 'jq' command
199 sudo apt-get install -y jq
201 # install 'kubectl' command
202 sudo apt-get install -y apt-transport-https
203 echo "deb http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main" | \
204 sudo tee -a /etc/apt/sources.list.d/kubernetes.list
205 gpg --keyserver keyserver.ubuntu.com --recv-keys 836F4BEB
206 gpg --export --armor 836F4BEB | sudo apt-key add -
208 sudo apt-get install -y kubectl
210 We need to get the Kubernetes profile to set up the kubectl command
213 Get the DMS Id in the INF O2 service, and set it into bash
218 # Get all DMS ID, and print them with command
219 dmsIDs=$(curl -k -s -X 'GET' \
220 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers" \
221 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
222 | jq --raw-output '.[]["deploymentManagerId"]')
223 for i in $dmsIDs;do echo ${i};done;
225 # Choose one DMS and set it to bash environment, here I set the first one
226 export dmsID=$(curl -k -s -X 'GET' \
227 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers" \
228 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
229 | jq --raw-output '.[0]["deploymentManagerId"]')
231 echo ${dmsID} # check the exported DMS Id
233 The profile of the ‘kubectl’ need the cluster name, I assume it is
236 It also needs the server endpoint address, username, and authority,
237 and for the environment that has Certificate Authority validation, it
238 needs the CA data to be set up.
242 CLUSTER_NAME="o2dmsk8s1" # set the cluster name
244 K8S_SERVER=$(curl -k -s -X 'GET' \
245 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers/${dmsID}?profile=native_k8sapi" \
246 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
247 | jq --raw-output '.["extensions"]["profileData"]["cluster_api_endpoint"]')
248 K8S_CA_DATA=$(curl -k -s -X 'GET' \
249 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers/${dmsID}?profile=native_k8sapi" \
250 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
251 | jq --raw-output '.["extensions"]["profileData"]["cluster_ca_cert"]')
253 K8S_USER_NAME=$(curl -k -s -X 'GET' \
254 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers/${dmsID}?profile=native_k8sapi" \
255 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
256 | jq --raw-output '.["extensions"]["profileData"]["admin_user"]')
257 K8S_USER_CLIENT_CERT_DATA=$(curl -k -s -X 'GET' \
258 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers/${dmsID}?profile=native_k8sapi" \
259 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
260 | jq --raw-output '.["extensions"]["profileData"]["admin_client_cert"]')
261 K8S_USER_CLIENT_KEY_DATA=$(curl -k -s -X 'GET' \
262 "https://${OAM_IP}:30205/o2ims-infrastructureInventory/v1/deploymentManagers/${dmsID}?profile=native_k8sapi" \
263 -H 'accept: application/json' -H "Authorization: Bearer ${SMO_TOKEN_DATA}" \
264 | jq --raw-output '.["extensions"]["profileData"]["admin_client_key"]')
266 # If you do not want to set up the CA data, you can execute following command without the secure checking
267 # kubectl config set-cluster ${CLUSTER_NAME} --server=${K8S_SERVER} --insecure-skip-tls-verify
269 kubectl config set-cluster ${CLUSTER_NAME} --server=${K8S_SERVER}
270 kubectl config set clusters.${CLUSTER_NAME}.certificate-authority-data ${K8S_CA_DATA}
272 kubectl config set-credentials ${K8S_USER_NAME}
273 kubectl config set users.${K8S_USER_NAME}.client-certificate-data ${K8S_USER_CLIENT_CERT_DATA}
274 kubectl config set users.${K8S_USER_NAME}.client-key-data ${K8S_USER_CLIENT_KEY_DATA}
276 # set the context and use it
277 kubectl config set-context ${K8S_USER_NAME}@${CLUSTER_NAME} --cluster=${CLUSTER_NAME} --user ${K8S_USER_NAME}
278 kubectl config use-context ${K8S_USER_NAME}@${CLUSTER_NAME}
280 kubectl get ns # check the command working with this context
282 Now you can use “kubectl”, which means you set up a successfully
283 Kubernetes client. But, it uses the default admin user, so I
284 recommend you create an account for yourself.
286 Create a new user and account for K8S with a “cluster-admin” role.
287 And, set the token of this user to the base environment.
292 NAMESPACE="kube-system"
294 cat <<EOF > admin-login.yaml
299 namespace: kube-system
301 apiVersion: rbac.authorization.k8s.io/v1
302 kind: ClusterRoleBinding
306 apiGroup: rbac.authorization.k8s.io
310 - kind: ServiceAccount
312 namespace: kube-system
315 kubectl apply -f admin-login.yaml
316 TOKEN_DATA=$(kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep ${USER} | awk '{print $1}') | grep "token:" | awk '{print $2}')
319 Set the new user in ‘kubectl’ replace the original user, and set the
320 default namespace into the context.
325 TOKEN_DATA=<TOKEN_DATA from INF>
328 CLUSTER_NAME="o2dmsk8s1"
330 kubectl config set-credentials ${USER} --token=$TOKEN_DATA
331 kubectl config set-context ${USER}@inf-cluster --cluster=${CLUSTER_NAME} --user ${USER} --namespace=${NAMESPACE}
332 kubectl config use-context ${USER}@inf-cluster