Set up microservices discovery in your GitLab CI/CD pipelines.
Early Adopter Release
This feature is currently in early adopter release and may not be available to all users.
Overview
If your organization uses GitLab as a platform for hosting code repositories, you can establish an automated process for microservices discovery by configuring GitLab CI/CD pipelines. Automated discovery ensures consistent updates and accurate representation of microservices within your system.
Prerequisites
Before you start, prepare the following:
- A YAML manifest file
- A relevant Python script
To learn how to create a YAML file and a Python script, see Microservice Discovery Through a Manifest File.
Configuring Your GitLab CI/CD Pipeline
The GitLab CI/CD pipeline outlined in this guide is designed to automatically update your microservices on each push or merge request to the main
branch. This ensures your microservice fact sheets are consistently updated with the latest changes. The pipeline includes the following steps:
- Checking out your code
- Setting up Python
- Installing the necessary Python dependencies
- Invoking the SAP LeanIX service discovery Python helper
To set up this pipeline, create or update your .gitlab-ci.yml
file in your repository root.
The following YAML script outlines the pipeline:
stages:
- update_microservice
update_microservice:
image: python:3.12
script:
- pip install --upgrade pip
- pip install requests pyyaml
- python leanix_service_discovery.py
only:
- main
By automating these steps, you not only streamline your microservice discovery process but also ensure accuracy and consistency in your microservice fact sheets.