Installing the GitLab agent
The GitLab Agent helps connect Managed Service for Kubernetes clusters to GitLab. You can deploy the application in a Yandex Managed Service for GitLab instance or 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.
- Enable caching of Kubernetes objects that update with very low latency.
Note
The GitLab agent does not run CI/CD pipelines. To do this, install GitLab Runner.
Getting started
-
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the
yc config set folder-id <folder_ID>command. You can also set a different folder for any specific command using the--folder-nameor--folder-idparameter. -
Make sure the security groups for the Managed Service for Kubernetes cluster and its node groups are configured correctly. If a rule is missing, add it.
Warning
The configuration of security groups determines performance and availability of the cluster and the services and applications running in it.
-
Get ready to install the GitLab agent:
- 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
mainbranch, 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 you need to install the application. Store the token in a secure place.
Note
For more information about setting up and registering an agent, see this GitLab guide
.
Installation from Yandex Cloud Marketplace
- Navigate to the folder dashboard
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: Create a new namespace, e.g.,
gitlab-agent-space. If you leave the default namespace, the GitLab agent may work incorrectly. - Application name: Specify the application 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.
- Namespace: Create a new namespace, e.g.,
- Click Install.
- Wait for the application status to change to
Deployed. - Open your GitLab instance and go to Infrastructure → Kubernetes clusters. Make sure the agent status switched to
Connected.
Installation using a Helm chart
-
Install Helm
v3.8.0 or higher. -
Install kubect
and configure it to work with the new cluster. -
To install a Helm chart
with the GitLab agent, run this 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 will also create a new namespace required for the application.
If you set
namespaceto the default namespace, the GitLab agent may work incorrectly. We recommend specifying a value different from all the existing namespaces, e.g.,gitlab-agent-space.Note
If you are using a Helm version below 3.8.0, add the
export HELM_EXPERIMENTAL_OCI=1 && \string at the beginning of the command to enable Open Container Initiative (OCI) support in the Helm client. -
Make sure the GitLab agent pod switched to
Running:kubectl get pods --namespace=<namespace> -
Open your GitLab instance and go to Infrastructure → Kubernetes clusters. Make sure the agent status switched to
Connected.