Zoekt chart

  • Tier: Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed
  • Status: Limited availability

This feature is in limited availability. For more information, see epic 9404. Provide feedback in issue 420920.

Zoekt chart with a Linux package instance

Use the Zoekt chart to connect Zoekt to a Linux package instance.

Prerequisites:

To use the Zoekt chart with a Linux package instance:

  1. Create a namespace called zoekt:

    kubectl create namespace zoekt
  2. Clone the gitlab-zoekt chart locally and change to its directory:

    git clone https://gitlab.com/gitlab-org/cloud-native/charts/gitlab-zoekt.git
    cd gitlab-zoekt
  3. Enable a load balancer. Because the Zoekt chart is a headless service, a load balancer is required.

  4. In values.yaml:

    1. Use the gitlab_shell secret from the /etc/gitlab/gitlab-secrets.json file to create the kubectl secret:

      kubectl create secret generic gitlab-zoekt-secret --from-literal=secret-key="<gitlab-shell-secret>" -n zoekt
    2. Add the secret:

      internalApi:
       secretName: 'gitlab-zoekt-secret'
       secretKey: 'secret-key'
    3. Add the GitLab instance URL and service URL with a load balancer IP port of :8080:

       internalApi:
         gitlabUrl: 'https://<gitlab_url>' # Internal URL to connect to GitLab
         serviceUrl: 'http://<loadbalancer_internal_ip>:8080' # URL to reach Zoekt service - LB internal URL
  5. In GitLab, change the Gitaly listening interface:

    gitaly['configuration'] = {
      listen_addr: '0.0.0.0:8075',
      storage: [
        {
          name: 'default',
          path: '/var/opt/gitlab/git-data/repositories',
        },
      ]
    }
    gitlab_rails['repositories_storages'] = {
      'default'  => { 'gitaly_address' => 'tcp://<gitlab_url>:8075' },
    }
  6. Install Zoekt by using helm:

    helm install gitlab-zoekt . -f values.yaml --version <latest_version> --namespace zoekt
  7. Confirm the pods were created. You should have both the gateway and gitlab-zoekt-0 pods:

    kubectl get pods
    NAME                                  READY   STATUS    RESTARTS   AGE
    gitlab-zoekt-0                        3/3     Running   0          13d
    gitlab-zoekt-gateway-b78dbc78-hzw28   1/1     Running   0          13d

    Install or upgrade the GitLab Helm chart if you make further changes to values.yaml.

  8. Enable exact code search.

  9. To index a top-level group, do one of the following:

    • Index all root namespaces automatically.

    • Index a specific top-level group manually:

      node = ::Search::Zoekt::Node.online.last
      namespace = Namespace.find_by_full_path('<top-level-group-to-index>')
      Search::Zoekt::EnabledNamespace.find_or_create_by(namespace: namespace)

Zoekt chart with the GitLab Helm chart

The Zoekt chart provides support for exact code search. You can install the chart by setting gitlab-zoekt.install to true. For more information, see gitlab-zoekt.

Enable the Zoekt chart

To enable the Zoekt chart, set the following values:

--set gitlab-zoekt.install=true \
--set gitlab-zoekt.replicas=2 \         # Number of Zoekt pods. If you want to use only one pod, you can skip this setting.
--set gitlab-zoekt.indexStorage=128Gi   # Disk size for the Zoekt node. Zoekt requires up to three times the repository's default branch's storage size, depending on the number of large and binary files.

Set CPU and memory usage

You can define requests and limits for the Zoekt chart by modifying the GitLab.com default settings.

Configure Zoekt in GitLab

To configure Zoekt for a top-level group in GitLab:

  1. Connect to the Rails console of the toolbox pod:

    kubectl exec <toolbox pod name> -it -c toolbox -- gitlab-rails console -e production
  2. Enable exact code search.

  3. To index a top-level group, do one of the following:

    • Index all root namespaces automatically.

    • Index a specific top-level group manually:

      node = ::Search::Zoekt::Node.online.last
      namespace = Namespace.find_by_full_path('<top-level-group-to-index>')
      Search::Zoekt::EnabledNamespace.find_or_create_by(namespace: namespace)
      node = ::Search::Zoekt::Node.online.last
      namespace = Namespace.find_by_full_path('<top-level-group-to-index>')
      enabled_namespace = Search::Zoekt::EnabledNamespace.find_or_create_by(namespace: namespace)
      replica = enabled_namespace.replicas.find_or_create_by(namespace_id: enabled_namespace.root_namespace_id)
      replica.ready!
      node.indices.create!(zoekt_enabled_namespace_id: enabled_namespace.id, namespace_id: namespace.id, zoekt_replica_id: replica.id, state: :ready)

Zoekt can now index projects in that group after any project is updated or created. For the initial indexing, wait at least a few minutes for Zoekt to start indexing the namespace.