Commit 093538ed authored by Christos Tranoris's avatar Christos Tranoris
Browse files

Modifying doc for #2. It can be used also for

parent 1989205a
Loading
Loading
Loading
Loading
Loading
+71 −25
Original line number Original line Diff line number Diff line
@@ -4,10 +4,9 @@
## Intended Audience: Service Designers
## Intended Audience: Service Designers




To illustrate the powerful concept of Kubernetes operators and how they can be utilized to offer a service through OpenSlice, 
> To illustrate the powerful concept of Kubernetes operators and how they can be utilized to offer a service through OpenSlice, let's provide an example of a "Calculator as a Service." 
let's provide an example of a "Calculator as a Service." 

This example will demonstrate the flexibility and capabilities of Kubernetes operators in managing custom resources 
> This example will demonstrate the flexibility and capabilities of Kubernetes operators in managing custom resources and automating operational tasks.
and automating operational tasks.


---
---
## Offering "Calculator as a Service" through OpenSlice
## Offering "Calculator as a Service" through OpenSlice
@@ -18,8 +17,9 @@ and automating operational tasks.
- Also while the service is active, we can do further calculations, until we destroy it.
- Also while the service is active, we can do further calculations, until we destroy it.




- Assume the following simple CRD of a calculator model accepting two params (spec section) and an action and returning a result (status section)
Assume the following simple CRD of a calculator model accepting two params (spec section) and an action and returning a result (status section)
- The controller (the calculato code) is implemented in any language and is installed in a Kubernetes cluster

The controller (the calculator code) is implemented in any language and is installed in a Kubernetes cluster


```
```


@@ -103,17 +103,28 @@ To perform this through OpenSlice as a Service Specification ready to be ordered
### CRD is saved automatically as Resource Specification
### CRD is saved automatically as Resource Specification


As soon as the CRD is deployed in the cluster (e.g. by your admin via kubctl or via any installation through the internet) it is automatically transformed and is available in OpenSlice catalogs as a Resource Specification.
As soon as the CRD is deployed in the cluster (e.g. by your admin via kubctl or via any installation through the internet) it is automatically transformed and is available in OpenSlice catalogs as a Resource Specification.

- See also the fully qualified name of the resource specification. 
- See also the fully qualified name of the resource specification. 
- The resource specification name is quite unique, so you can install the CRD in many clusters around the internet. Each CRD on each cluster will appear here
	- MyCalculator@examples.osl.etsi.org/v1alpha1@docker-desktop@https://kubernetes.docker.internal:6443/
	- The resource specification name is quite unique, so you can install the CRD in many clusters around the internet. Each CRD on each cluster will appear here, for example:
		- MyCalculator@examples.osl.etsi.org/v1alpha1@default_cluster@https://10.10.10.8:6443/
		- MyCalculator@examples.osl.etsi.org/v1alpha1@edge1_cluster@https://172.16.10.10:6443/
	- Having this OpenSlice can manage resources in multiple clusters




<img src="img07.png" >
<img src="img07.png" >


> See also the detailed characteristics. See how OpenSlice makes all characteristics automatically flat and expanded with key-value style


<img src="img08.png" width=1024px>
<img src="img08.png" width=1024px>


---
---
### Create a ResourceFacingServiceSpecification
# Expose to Users
 
## Start by Creating a ResourceFacingServiceSpecification

From the UI menu create a new Service Specification





<img src="img09.png" width=1024px>
<img src="img09.png" width=1024px>
@@ -124,7 +135,7 @@ As soon as the CRD is deployed in the cluster (e.g. by your admin via kubctl or


### Creation of CRD-related characteristics
### Creation of CRD-related characteristics


- We need now to adjust some characteristics of this CRD as Resoruce Specification.
- We need now to adjust some characteristics of this CRD as Resource Specification.
- OpenSlice transalted automatically the CRD spec in a flat list of characteristics.So the "spec" section from the original yaml for example, is now unfold into: spec, spec.parama, spec.paramb, etc. the same for "status" object
- OpenSlice transalted automatically the CRD spec in a flat list of characteristics.So the "spec" section from the original yaml for example, is now unfold into: spec, spec.parama, spec.paramb, etc. the same for "status" object
- We need to make OpenSlice aware of when the service will be active. 
- We need to make OpenSlice aware of when the service will be active. 
	- So we go to characteristic _CR_CHECK_FIELD and we define that the field that shows the status of the service is the characteristic "status.status" (is a text field) 
	- So we go to characteristic _CR_CHECK_FIELD and we define that the field that shows the status of the service is the characteristic "status.status" (is a text field) 
@@ -132,7 +143,9 @@ As soon as the CRD is deployed in the cluster (e.g. by your admin via kubctl or
	- We need also to define the yaml file that OpenSLice will use to create the new resource in the kubernetes cluster
	- We need also to define the yaml file that OpenSLice will use to create the new resource in the kubernetes cluster
	- We insert the YAML in the characteristic _CR_SPEC
	- We insert the YAML in the characteristic _CR_SPEC
	
	
	the _CR_SPEC is: ```
	the _CR_SPEC is: 

```
apiVersion: examples.osl.etsi.org/v1alpha1
apiVersion: examples.osl.etsi.org/v1alpha1
kind: MyCalculator
kind: MyCalculator
metadata:
metadata:
@@ -149,9 +162,29 @@ spec:


> However the values are fixed. How do we allow a user to pass parameters through OpenSlice
> However the values are fixed. How do we allow a user to pass parameters through OpenSlice


### Pass parameters through OpenSlice
## Expose in Catalog

Create a new CustomerFacingServiceSpecification

	- Go to the menu Service Specification>New Service Specification
	- Create a service My Calulator and mark it as a Bundle
	- Go to Service Specification Relationships and add MyCalculatorRFS
	- The service will be automatically transformed to a "CustomerFacingServiceSpecification"
	- Add the following characteristics as the image shows:


<img src="cfs_img12.png" width=1024px>





### Allow users to pass new values through OpenSlice



We need to Create LCM rules in CustomerFacingServiceSpecification:


We need to Create LCM rules in ResourceFacingServiceSpecification
	- The goal of the rules is to allow the user to pass parameters to the actual resource towards the cluster.
	- The goal of the rules is to allow the user to pass parameters to the actual resource towards the cluster.
	- we will create one rule that will pass the parameters just before creating the service (PRE_PROVISION phase)
	- we will create one rule that will pass the parameters just before creating the service (PRE_PROVISION phase)
	- we will create one rule that will pass the parameters while the service is active (SUPERVISION phase)
	- we will create one rule that will pass the parameters while the service is active (SUPERVISION phase)
@@ -162,8 +195,12 @@ We need to Create LCM rules in ResourceFacingServiceSpecification
If we see one rule it will look like the following:
If we see one rule it will look like the following:
<img src="img13.png" width=1024px>
<img src="img13.png" width=1024px>


- We need to change the _CR_SPEC characteristic
- We need to change the _CR_SPEC characteristic of the referenced ResourceFacingServiceSpecification
- We use a block that changes a String according to variables
- First bring a block from Service>Relationships>Service Refs and drop the "Service MyCalculatorRFS" block
- Then add a list block from Lists
- Then add the block that modifies a referenced characteristic from Service>Relationships>Service Refs the block "Set value to characteristic of a Referenced Service"
- Add a block for text _CR_SPEC 
- We use a block that changes a String according to variables Text>"A formatted text replacing variables from List"
- See that we have as Input string the YAML string lines
- See that we have as Input string the YAML string lines
	- see that parama, paramb has a %d (they accept integers), action is %s (accepts a string)
	- see that parama, paramb has a %d (they accept integers), action is %s (accepts a string)
	- See that the variables tha will replace the %d, %d and %s are an list
	- See that the variables tha will replace the %d, %d and %s are an list
@@ -173,9 +210,17 @@ If we see one rule it will look like the following:
		
		




### Create a CustomerFacingServiceSpecification
If we see the SUPERVISION rule it will look like the following:

- It contains also the Result field, which takes the value from the referenced service
- Add a block for the Result field from Service>Number blocks
- Add a  str to int block from Number blocks
- Add Service>Relationships>Service Refs and drop the input block [Service MyCalculatorRFS] "Get Service details from current context running service" and select from the drop down the "serviceCharacteristicValue"
- Add as name the "status.result" 


<img src="img13_1.png" width=1024px>


We will now expose it to our users by creating a CustomerFacingServiceSpecification


<img src="img14.png" width=1024px>
<img src="img14.png" width=1024px>


@@ -196,7 +241,7 @@ When a user orders the service, it will look like this:
- After the Service Order we have 2 services in service inventory on CFS and on RFS. Both have references to values
- After the Service Order we have 2 services in service inventory on CFS and on RFS. Both have references to values
- OpenSlice (via CRIDGE service) updates the Resource in Resource Inventory and OSOM updates the Services in Service Inventory
- OpenSlice (via CRIDGE service) updates the Resource in Resource Inventory and OSOM updates the Services in Service Inventory
- The Actual resources are running in the Kubernetes cluster managed by OpenSlice
- The Actual resources are running in the Kubernetes cluster managed by OpenSlice
- The result is in the characteristic status.result
- The result is in the characteristic status.result of the running service


<img src="img17.png" width=800px>
<img src="img17.png" width=800px>


@@ -204,12 +249,13 @@ When a user orders the service, it will look like this:


### Modify the running service
### Modify the running service
 
 
 The use can modify the service
 The user can modify the service
 
 
<img src="img19.png" width=1024px>
<img src="img19.png" width=1024px>
 
 
- After a while the update is applied to the cluster, the controller will pick up the resource update and patch the resource
- After a while the update is applied to the cluster, the controller will pick up the resource update and patch the resource
- OpenSlice (via CRIDGE service) updates the Resource in Resource Inventory and OSOM updates the Services in Service Inventory
- OpenSlice (via CRIDGE service) updates the Resource in Resource Inventory and OSOM updates the Services in Service Inventory
- The result will be available to the respective characteristic "Result" after a few seconds, as need to go through various steps (OpenSlice orchestrator, down to kubernetes, to Calculator controller and back)
    	
    	


<img src="img20.png" width=1024px>
<img src="img20.png" width=1024px>
+106 KiB
Loading image diff...
+69.1 KiB
Loading image diff...
+319 KiB
Loading image diff...
+113 KiB
Loading image diff...
Loading