Installing the GitLab Agent
The GitLab Agent is used to connect a Managed Service for Kubernetes cluster to GitLab. You can deploy the application in a Yandex Managed Service for GitLab instance or in a standalone GitLab instance.
The GitLab Agent enables you to:
- Work with Managed Service for Kubernetes clusters behind NAT.
- Get real-time access to the Managed Service for Kubernetes cluster API.
- Receive information about events in a Managed Service for Kubernetes cluster.
- Activate the cache of Kubernetes objects, which are updated with very low latency.
Note
The GitLab Agent does not execute CI/CD pipelines. To do this, install GitLab Runner.
Getting started
-
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the
--folder-name
or--folder-id
parameter. -
Make sure that the security groups for the Managed Service for Kubernetes cluster and its node groups are configured correctly. If any rule is missing, add it.
Warning
The configuration of security groups determines the performance and availability of the cluster and the services and applications running in it.
-
Prepare for GitLab Agent installation:
- Create a Managed Service for GitLab instance or a standalone instance.
- Create an agent configuration file in the repository:
- Open your GitLab instance and go to your project.
- In the
main
branch, create a new folder named.gitlab/agents/<GitLab_agent_name>
. - In the
<GitLab_agent_name>
folder, create an empty file namedconfig.yaml
.
- Register the agent in GitLab and get an access token:
- Open your GitLab instance and go to your project.
- Select Operate on the left-hand panel, and then select Kubernetes clusters from the drop-down menu.
- Click Connect a cluster and select the agent name:
<GitLab_agent_name>
. - Click Register.
- GitLab will create a token required to install the application. Store the token in a secure place.
Note
For more information about setting up and registering an agent, see the GitLab documentation
.
Installation using Yandex Cloud Marketplace
- Go to the folder page
and select Managed Service for Kubernetes. - Click the name of the Managed Service for Kubernetes cluster you need and select the
Marketplace tab. - Under Application available for installation, select GitLab Agent and click Go to install.
- Configure the application:
- Namespace: Select a namespace or create a new one.
- Application name: Specify the app name, e.g.,
gitlab-agent
. - GitLab domain name: Enter the name of your GitLab domain, e.g.,
gitlab-test.gitlab.yandexcloud.net
. - Agent access token: Paste the GitLab access token you received earlier into this field.
- Click Install.
- Wait for the application status to change to
Deployed
. - Open your GitLab instance and go to Infrastucture → Kubernetes clusters. Make sure the agent status changed to
Connected
.
Installation using a Helm chart
-
Install Helm
v3.8.0 or higher. -
Install kubectl
and configure it to work with the created cluster. -
To install a Helm chart
with the GitLab Agent, run the following command:helm pull oci://cr.yandex/yc-marketplace/yandex-cloud/gitlab-org/gitlab-agent/chart/gitlab-agent \ --version 1.16.0-1 \ --untar && \ helm upgrade --install \ --namespace <namespace> \ --create-namespace \ --set config.kasAddress='wss://<your_GitLab_domain_name>/-/kubernetes-agent/' \ --set config.token='<GitLab_access_token>' \ gitlab-agent ./gitlab-agent/
This command also creates a new namespace required for the application.
Note
If you are using a Helm version below 3.8.0, append the
export HELM_EXPERIMENTAL_OCI=1 && \
string to the command to enable Open Container Initiative (OCI) support in the Helm client. -
Make sure the GitLab Agent pod status changed to
Running
:kubectl get pods --namespace gitlab-agent
-
Open your GitLab instance and go to Infrastucture → Kubernetes clusters. Make sure the agent status changed to
Connected
.