From the platform, you can create microservices and manage their entire life cycle, from code compilation to the deployment in CaaS.
1.Creation
From the microservices screen https://development.onesaitplatform.com/controlpanel/microservices/list we can create a new microservice.
1.1 Creation of the project in Gitlab
If we are creating the project from scratch, we can choose an archetype and a Gitlab project will be generated with a base code to start working on it.
Depending on the type of project, we will select an archetype or another. For example, the IoT Client archetype is configured to communicate with the platform broker to and perform query operations on an ontology.
1.2 Creation with an existing Git project
If the code already exists in a Git repository and we only want to manage the entire life cycle from the platform, then we can indicate that we do not want to create the Git repository (by unchecking the box 'CREATE GIT REPOSITORY'), and configure the existing Git repository.
1.3. Context and port
It is important to specify the context path defined in our application, as well as the port, to later generate the correct paths in the microservice gateway.
1.4 Settings
We must set up the credentials of Git, Jenkins, and CaaS (in this case Rancher).
Now that everything is configured, we can create the microservice (if we have selected the option to create a repository in Git, then it may take a few seconds).
We can now see and manage our microservice from the previous list:
We can clone the repository and start working on the project.
Info | ||
---|---|---|
| ||
The user token for both GitLab and Jenkins needs to have the necessary permissions to be able to create git projects and continuous integration pipelines. |
2. Compilation and generation of Docker images
At any point, through the Jenkins self-generated pipeline, we can compile any Git branch of the repository and generate new Docker images.
We just have to click on the 'Build service' hammer.
A pop-up window will appear, asking us for the input parameters of the pipeline:
Once those are inserted, we click 'Generate' and we will have to wait for it to finish.
Once finished, the spinner will disappear, and we can deploy it.
3.Deployment in CaaS
Once the images are generated, we can proceed to deploy the microservice. To do this, we click on the 'Deploy' rocket:
A pop-up window will open, where we will have to select the environment and the host from a drop-down, along with the DNS where the microservice will be deployed:
Besides, once the environment is selected, a dropdown will appear in which we can choose the stack in which to deploy the microservice. This is quite useful should we want to group several microservices within the same Rancher 1.6 stack.
We click Deploy, it will take a few seconds...
Once deployed, the microservice will be automatically available from the outside. If it is a web application with visual components, then we can navigate to the microservice through the Eye icon:
If it is a purely REST service, then we can copy the generated URL (in this case https://development.onesaitplatform.com/restaurants/) and make calls from any REST client.
4.Upgrade of the deployed service
If we want to update the version of the microservice deployed, or overwrite some environment variable, we just have to click on the arrow key 'Upgrade'.
A window, similar to that of the deployment, will open, but in this one we can indicate environment variables: