[Yandex Cloud documentation](../../../index.md) > [Yandex Managed Service for Kubernetes](../../index.md) > [Step-by-step guides](../index.md) > Installing applications from Cloud Marketplace > Installing the GitLab agent

# Installing the GitLab agent


The [GitLab Agent](https://yandex.cloud/en/marketplace/products/yc/gitlab-agent) helps connect [Managed Service for Kubernetes clusters](../../concepts/index.md#kubernetes-cluster) to GitLab. You can deploy the application in a [Yandex Managed Service for GitLab](../../../managed-gitlab/index.md) [instance](../../../managed-gitlab/concepts/index.md#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 info %}

The GitLab agent does not run CI/CD pipelines. To do this, install [GitLab Runner](https://yandex.cloud/en/marketplace/products/yc/gitlab-runner).

{% endnote %}

## Getting started {#before-you-begin}

1. If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

    The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

1. [Make sure](../connect/security-groups.md) the security groups for the Managed Service for Kubernetes cluster and its node groups are configured correctly. If a rule is missing, [add it](../../../vpc/operations/security-group-add-rule.md).

    {% note warning %}
    
    The configuration of security groups determines performance and availability of the cluster and the services and applications running in it.
    
    {% endnote %}

1. Get ready to install the GitLab agent:

    1. [Create a Managed Service for GitLab instance](../../../managed-gitlab/operations/instance/instance-create.md) or a standalone instance.
    1. Create an agent configuration file in the repository:
       1. Open your [GitLab instance](../../../managed-gitlab/concepts/index.md#instance) and go to your project.
       1. In the `main` branch, create a new folder named `.gitlab/agents/<GitLab_agent_name>`.
       1. In the `<GitLab_agent_name>` folder, create an empty file named `config.yaml`.
    1. Register the agent in GitLab and get an access token:
       1. Open your GitLab instance and go to your project.
       1. Select **Operate** on the left-hand panel, and then select **Kubernetes clusters** from the drop-down menu.
       1. Click **Connect a cluster** and select the agent name: `<GitLab_agent_name>`.
       1. Click **Register**.
       1. GitLab will create a token you need to install the application. Store the token in a secure place.

    {% note info %}

    For more information about setting up and registering an agent, see [this GitLab guide](https://docs.gitlab.com/ee/user/clusters/agent/install/).

    {% endnote %}

## Installation from Yandex Cloud Marketplace {#marketplace-install}

1. In the [management console](https://console.yandex.cloud), select a folder.
1. Navigate to **Managed Service for&nbsp;Kubernetes**.
1. Click the name of the Managed Service for Kubernetes cluster you need and select the ![image](../../../_assets/console-icons/shopping-cart.svg) **Marketplace** tab.
1. Under **Application available for installation**, select [GitLab Agent](https://yandex.cloud/en/marketplace/products/yc/gitlab-agent) and click **Go to install**.
1. Configure the application:
   * **Namespace**: Create a new [namespace](../../concepts/index.md#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](#before-you-begin) into this field.
1. Click **Install**.
1. Wait for the application status to change to `Deployed`.
1. Open your GitLab instance and go to **Infrastructure → Kubernetes clusters**. Make sure the agent status switched to `Connected`.

## Installation using a Helm chart {#helm-install}

1. [Install Helm](https://helm.sh/docs/intro/install/) v3.8.0 or higher.
1. [Install kubect](https://kubernetes.io/docs/tasks/tools/install-kubectl) and [configure it to work with the new cluster](../connect/index.md#kubectl-connect).
1. To install a [Helm chart](https://helm.sh/docs/topics/charts/) with the GitLab agent, run this command:

   ```bash
   helm pull oci://cr.yandex/yc-marketplace/yandex-cloud/gitlab-org/gitlab-agent/chart/gitlab-agent \
     --version 1.16.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 `namespace` to 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 info %}
   
   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](https://opencontainers.org/) (OCI) support in the Helm client.
   
   {% endnote %}

1. Make sure the GitLab agent pod switched to `Running`:

   ```bash
   kubectl get pods --namespace=<namespace>
   ```

1. Open your GitLab instance and go to **Infrastructure → Kubernetes clusters**. Make sure the agent status switched to `Connected`.

## Use cases {#examples}

* [Continuous deployment of containerized applications using GitLab](../../tutorials/gitlab-containers.md).

## See also {#see-also}

* [GitLab agent guides](https://docs.gitlab.com/ee/user/clusters/agent/)
* [Managed Service for GitLab guides](../../../managed-gitlab/index.md)