The API Console allows the user to create custom microservices from a template; it manages the following templates:
angular 2+: a ready to use Angular 2+ template that provides a basic Angular project, already up and running and ready to be customized.
These templates are all under the voice CREATE FROM TEMPLATE:
The service types can be different based on the API Console you are working on)
Our first custom service based on template
Following we will see how to create a custom Microservice using the API Console; this guide is generic, so you can follow it to create any type of custom microservice from template.
1. Service creation
Into the API Console, we have to create our service (template-service from now). To do this, follow these steps:
- Click on Services
- Click on Create new service
- Add the service information:
- type: your favorite service under the CREATE FROM TEMPLATE voice (the service types can be different based on the API Console you are working on)
- name: the service name
- description: the service description
- gitlab group path: the gitlab group where you want to save the service repository
- gitlab repository name: the gitlab repository name that you want for your service
- docker image name: the docker image name, you can leave the default one too
- look at the result
- Create the service
Now you have a customization interface and you can optionally customize some configuration if you want.
By default are enabled the standard kubernetes configurations, that provide the default configurations yml, but you can use your custom files by clicking, in the Advanced configuration section, the appropriate button:
Under the standard customizations you can customize the environment variables (Environment variable configuration section); this is an optional operation too, except for the angular 2+ service, that REQUIRES to modify the HTTP_PORT variable from 3000 to 8080, like the image:
NB. the API Console will show a yellow label now bacause there are unsaved changes
Do not save the changes now, we will save them later.
2. Creating the endpoint
Now we have our custom service repository *already deployed on the Mia-Platform Nexus repository manager, but we need an endpoint to call to access our custom service.
already deployed: it depends on the project and technologies we are working on, because we have clients that are not using the Gitlab Continuous Integration mechanism too, so we can need some other step to have the first image built after the service and repository creation. e.g. if we use a jenkins pipeline we can need to configure a webhoook on the just created repository before continue.
Following the steps for the creation of an endpoint:
- Click on endpoint
- Click on Create new endpoint
- Insert the endpoint data:
- base path: the endpoint base path
- type: select Custom Microservices
- service: select the microservice that you just created
- description: the endpoint description
- look at the result
- Click on the create button and your endpoint will be created!
3. Save the project
Finally it's time to save our modifications, so:
- Click on the save button:
- Insert a commit title
- Insert a commit message (optional)
4. Deploy the project through the API Console
Before deploy the project to have our service up and running we have to wait the end of the service pipeline, that will create a Docker image of the service that will be deployed.
So, before deploy, navigate on the gitlab repository of the just created service and wait the end of the pipeline; when the pipeline is done you can deploy the project:
- Login on the API Console
- Choose the desired project and branch
- Click on the Deploy button
- Select the environment and the branch to deploy, then click on the Deploy button
- Wait for the end of the deploy process
Now your service should be up and running, you can check it like this:
call the /-/healthz path if the service uses the Custom Plugin .
navigate the created endpoint and see the html page (frontend services)
call the base endpoint should ever work for some different type, if the endpoint is not secreted and is public.