The following simplifications are made in the diagram:

  • The diagram shows containers in different pods interacting directly with each other. In reality, they communicate via the corresponding Kubernetes Services (internal load balancers). Service names are omitted if they are obvious from the diagram context. Otherwise, the Service name is shown above the arrow.
  • Pods may run multiple replicas. However, each pod is shown as a single replica in the diagram.
  • Init containers are not shown in the diagrams.

The Level 2 C4 architecture of the Deckhouse Code deployed from a Helm chart (excluding components responsible for metrics collection: exporter and kube-rbac-proxy containers) is shown in the following diagram:

Deckhouse Code architecture

Components

Deckhouse Code is based on the GitLab platform, which is why the name GitLab appears in some component names.

Deckhouse Code consists of the following components:

  1. Gitaly-default (or shortened to Gitaly) (StatefulSet): A component that provides high-level remote procedure calls (RPC) for working with Git repositories. Through Gitaly, other Deckhouse Code components (for example, Webservice, Shell, Workhorse) access Git data — they read and write it. Each Gitaly pod uses a PersistentVolumeClaim for Git repositories.

    It consists of the following containers:

    • init-cgroups: Init container that configures Linux cgroups (control groups) so that the Gitaly container can manage them (set CPU and memory limits).
    • configure: Init container that performs preparatory tasks before the main container starts: it loads secrets, creates required directories and configuration files.
    • certificates: Init container that prepares SSL certificates.
    • gitaly: Main container.
    • kube-rbac-proxy (optional): Sidecar container with an authorization proxy based on Kubernetes RBAC that provides secure access to the component’s metrics.
  2. Praefect (StatefulSet): A router and transaction manager that combines Gitaly storage nodes into a cluster and ensures high availability of the Git storage. It acts as a transparent proxy between any Git client and Gitaly storage nodes. Praefect stores routing metadata in its own PostgreSQL database.

    It consists of the following containers:

    • configure: Init container that performs preparatory tasks before the main container starts: it loads secrets, creates required directories and configuration files.
    • praefect: Main container.
    • kube-rbac-proxy (optional): Sidecar container with an authorization proxy based on Kubernetes RBAC that provides secure access to the component’s metrics.
  3. Sidekiq-default and sidekiq-global-search (or shortened to Sidekiq) (Deployments): Background job processors that allow Deckhouse Code to avoid blocking the main thread during long operations, such as sending email messages, triggering CI/CD pipelines, updating repositories, or performing indexing. Sidekiq queues such tasks, and separate processes (workers) process them in parallel. Sidekiq-default is always enabled and processes the main (default) job queue.

    When advanced search is enabled, integration with OpenSearch (a full-text search engine) is configured, and a second Sidekiq instance — sidekiq-global-search — is launched to avoid interfering with the main queue. This instance populates the OpenSearch index with Deckhouse Code data.

    Both Sidekiq processors use Redis to store job queues. Redis can be deployed in Sentinel mode (for high availability), which is supported by Deckhouse Code. Sidekiq also accesses the PostgreSQL database and the Gitaly storage (via Praefect) to retrieve data needed to execute jobs.

    Both Sidekiq processors consist of the following containers:

    • configure: Init container that performs preparatory tasks before the main container starts: it loads secrets, creates required directories and configuration files.
    • dependencies: Init container that performs preparatory tasks before the main container starts, for example, configuring components required for its operation.
    • sidekiq: Main container.
    • audit: Sidecar container that collects and processes audit logs. It uses Datadog Vector as the log processor, which reads the audit log of its pod and outputs each event to stdout in CEF format, so the cluster logging stack collects events from the container logs.
    • kube-rbac-proxy (optional): Sidecar container with an authorization proxy based on Kubernetes RBAC to provide secure access to the component’s metrics.
  4. Webservice-default (Deployment): A component that provides the user interface and public API of Deckhouse Code (GitLab Rails API).

    It consists of the following containers:

    • configure: Init container that performs preparatory tasks before the main container starts: it loads secrets, creates required directories and configuration files.

    • dependencies: Init container that performs preparatory tasks before the main container starts, for example, configuring components required for its operation.

    • kube-rbac-proxy (optional): Sidecar container with an authorization proxy based on Kubernetes RBAC to provide secure access to the component’s metrics.

    • audit: Sidecar container collecting and processing audit logs (described in detail above).

    • gitlab-webservice (or shortened to Webservice): Container hosting the core GitLab codebase (an application built using the Ruby on Rails framework). Webservice runs on the Puma web server. Puma is a multi-threaded HTTP server designed specifically for Ruby applications. Its role is to run the core GitLab Rails application, which implements all interface functions: web UI, API, Git operations, etc. Webservice stores data in the application’s PostgreSQL database.

    • gitlab-workhorse (or shortened to Workhorse): Intelligent reverse proxy server. It sits in front of the main Webservice application and intercepts every HTTP request sent to or from this application. Workhorse performs the following operations:

      • Handling resource-intensive requests. Workhorse takes over operations such as uploading and downloading large files, cloning repositories (git clone), pushing and pulling changes (git push and git pull) over HTTP/HTTPS, and downloading repository archives. This offloads the main Webservice web server, which is responsible for quickly processing the web UI and business logic.
      • Optimizing static content. Workhorse can serve static pages, downloads (for example, avatars or attachments), and precompiled assets directly from the gitlab/public directory, bypassing Webservice, which speeds up system response.
      • Managing long-lived connections. Workhorse can manage long-term WebSocket connections, for example, for the web terminal (terminal websocket).
      • Interacting with other services. Workhorse interacts with Gitaly (via Praefect) for code operations and can also act as a proxy for the GitLab Rails API, for example, when interacting with the container registry.
      • Modifying responses. Workhorse can modify responses sent by the Rails API. For example, if Rails uses the send_file method, Workhorse opens the file on disk and sends its contents directly to the client, bypassing Rails.
      • Implementing long polling for CI/CD runner job requests. When a runner requests a job, Workhorse does not poll continuously but subscribes to a channel in Redis that publishes events about new jobs. Thus, Workhorse becomes a “listener” for these events.

    Regular user traffic should never reach the webservice container directly. Its purpose is to hold the application logic, and it is intended to process all non-resource-intensive requests.

    When Workhorse and Webservice work together in a typical architecture, a request follows this path:

    1. An external proxy server (for example, NGINX) accepts the user’s request and forwards it to Workhorse.
    2. Workhorse analyzes the request. If it is resource-intensive, Workhorse directly handles interaction with Gitaly or the filesystem, while delegating business logic processing to Webservice.
    3. Webservice performs the necessary authorization, validation, and business logic, then returns the result to Workhorse, which sends it back to the user via the proxy.
  5. Shell (Deployment): A component acting as a lightweight SSH server and proxy for Git commands. It handles SSH sessions, user authentication, and authorization for repository operations. When connecting to the Deckhouse Code server over SSH, Shell performs the following operations:

    • Limiting the set of commands. It allows only predefined Git commands: git push, git pull, git fetch, and others.
    • Checking authorization. It contacts the GitLab Rails API to verify that the user has the rights to perform the operation and to find out which Gitaly server hosts the repository.
    • Coordinating data exchange. It forwards data between the SSH client and the Gitaly server.
    • Modifying the authorized_keys file. On the client side (the user’s machine), Shell modifies this file.
    • Rate limiting. It applies limits on operations per user and project. The limit is configured via the Rails limiter with Redis as the backend. By default, it’s 600 requests per minute per command (for example, git push or git pull).
    • Supporting additional features. For example, generating 2FA recovery codes, verifying OTP for 2FA, authenticating for Git LFS, and using personal access tokens (PAT) over SSH.
    • Configuring timeouts. The gitlab_shell_git_timeout parameter sets the timeout (in seconds) for import and fetch Git operations handled by the shell. By default, it’s 10800 seconds (3 hours). It should be increased when synchronizing large repositories or working over slow network connections.

    It consists of the following containers:

    • configure: Init container that performs preparatory tasks before the main container starts: it loads secrets, creates required directories and configuration files.
    • gitlab-shell: Main container.
    • kube-rbac-proxy (optional): Sidecar container with an authorization proxy based on Kubernetes RBAC to provide secure access to the component’s metrics.
  6. Pages (Deployment): An optional component that allows publishing static websites directly from a repository in GitLab. Pages contacts the GitLab Rails API to publish a site; static sites are stored in an object storage bucket.

    It consists of the following containers:

    • configure: Init container that performs preparatory tasks before the main container starts: it loads secrets, creates required directories and configuration files.
    • pages: Main container.
    • kube-rbac-proxy (optional): Sidecar container with an authorization proxy based on Kubernetes RBAC to provide secure access to the component’s metrics.
  7. Registry (Deployment): A container image registry that allows users to create, upload, pull, and delete images directly from GitLab, without needing to set up a separate registry. Registry uses an object storage bucket as the backend for storing images and its own PostgreSQL database to store image metadata. It is an optional component.

    It consists of the following containers:

    • configure: Init container that performs preparatory tasks before the main container starts: it loads secrets, creates required directories and configuration files.
    • dependencies: Init container that performs preparatory tasks before the main container starts, for example, configuring components required for its operation.
    • registry: Main container.
    • kube-rbac-proxy (optional): Sidecar container with an authorization proxy based on Kubernetes RBAC to provide secure access to the component’s metrics.
  8. Kas (Deployment): GitLab Relay (formerly KAS or Kubernetes Agent Server), an optional component serving as the central relay for bidirectional gRPC communication between GitLab and external systems, including:

    • GitLab Runners (or runners): Programs/agents that execute jobs from the Deckhouse Code CI/CD pipeline.
    • Kubernetes clusters: For integration with an external cluster, the GitLab Agent program installed in it is used. The GitLab Agent establishes a bidirectional gRPC stream with GitLab Relay to receive commands from the GitLab server. This allows managing a Kubernetes cluster located in an isolated network (behind a firewall or NAT).

    GitLab Relay provides the following functionality:

    • Accepts requests for new build jobs from runners, forwards them to the Rails API, and returns a response containing build jobs to the runners.
    • Provides admission control for jobs executed by runners. Before executing a job, GitLab Relay sends a request for its acceptance to connected controllers (via the Runner controllers API), which can accept or reject the job according to configured user policies.
    • Proxies connections to external Kubernetes clusters.
    • Enables data exchange with external systems when working with isolated development environments (workspaces).

    GitLab Relay can be run on multiple nodes; in this case, GitLab Relay instances communicate with each other over 8155 TCP port, registering their private addresses in Redis. GitLab Relay uses Redis for several tasks:

    • Registering and discovering other KAS instances in the cluster. Each instance registers its private address so that other instances can contact it.
    • Storing information about agent access tokens to implement rate limiting.
    • Tracking connected agents.

    It consists of the following containers:

    • certificates: Init container that prepares SSL certificates.
    • kas: Main container.
    • kube-rbac-proxy (optional): Sidecar container with an authorization proxy based on Kubernetes RBAC to provide secure access to the component’s metrics.
  9. Haproxy (Deployment): An optional component used as a single entry point for all incoming traffic to the Deckhouse Code product. Haproxy redirects SSH requests to the Shell component and HTTP/HTTPS traffic to the Ingress controller, which then distributes traffic among Deckhouse Code components: Webservice, Registry, Pages, and GitLab Relay.

    It consists of the following containers:

    • haproxy: Main container. It is an Open Source project.
    • kube-rbac-proxy (optional): Sidecar container with an authorization proxy based on Kubernetes RBAC to provide secure access to the component’s metrics.
  10. Mailroom: A component responsible for processing incoming email messages and forwarding them to the GitLab Rails API for further processing. It enables email-based workflows: creating issues, commenting on an issue or merge request by replying to notifications, and supporting Service Desk. If multiple Mailroom instances are running, they use Redis for coordination — specifically, they acquire a lock on a message to prevent other Mailroom instances from processing it again. To receive incoming messages, Mailroom uses the IMAP protocol (an external mail service must be configured). Mailroom, as well as Sidekiq and Webservice, send email messages using the SMTP protocol (an SMTP gateway must be configured).

    It consists of the following containers:

    • configure: Init container that performs preparatory tasks before the main container starts: it loads secrets, creates required directories and configuration files.
    • mailroom: Main container.
  11. Toolbox (Deployment): A component that includes a container containing a set of utilities for administrators to perform Deckhouse Code maintenance tasks:

    • Create backups of PostgreSQL databases.
    • Restore data from PostgreSQL database backups.
    • Reindex the PostgreSQL database.
    • Diagnose Sidekiq queues.
    • Perform maintenance tasks on OpenSearch indexes.
    • Run operations for working with Git repositories.
    • Diagnose Deckhouse Code components.
    • Run Rake tasks (administrative tasks in the Webservice Ruby application).
    • Work via the GitLab Rails console. The Rails console in GitLab is an interactive terminal that allows direct low-level interaction with the GitLab instance: querying data, fixing errors, or performing administrative tasks not always available in the web UI.

    It consists of the following containers:

    • configure: Init container that performs preparatory tasks before the main container starts: it loads secrets, creates required directories and configuration files.
    • toolbox: Main container.

Metrics collection

The global.codeHelm.loadbalancer Helm chart section adds a kube-rbac-proxy sidecar container to the pods of the components. The container exposes its pod’s metrics on the https-metrics port and allows a request only after verifying its token via TokenReview and SubjectAccessReview. The chart creates a <RELEASE>-<COMPONENT>-metrics Service and a <RELEASE>-<COMPONENT> ServiceMonitor for each component, a <RELEASE>-prometheus-token Secret from which the ServiceMonitor retrieves the token, and the RBAC objects required by the containers for validation.

For more details on configuring metrics collection via kube-rbac-proxy, see the Deckhouse Code documentation.

To collect metrics from components not covered by their built-in exporters, a separate component called exporter is used. The exporter connects to the following components:

  • PostgreSQL: To collect database statistics.
  • Redis: To collect statistics on Sidekiq job queues.
  • Shell: To collect statistics on Git processes and git pull and git push execution time.

The exporter consists of the following containers:

  • configure: Init container that performs preparatory tasks before the main container starts: it loads secrets, creates required directories and configuration files.
  • exporter: Main container.
  • kube-rbac-proxy (optional): Sidecar container with an authorization proxy based on Kubernetes RBAC to provide secure access to the component’s metrics.

The Level 2 C4 architecture of the metrics collection in Deckhouse Code is shown in the following diagram:

Metrics collection architecture in Deckhouse Code

Interactions

Deckhouse Code interacts with the following external components:

  1. PostgreSQL:

    • Databases are used by components.
    • Database maintenance tasks are performed.
    • Database statistics is collected.
  2. Redis:

    • Redis channels are used to publish events related to CI/CD runners executing build jobs in build queues;
    • Redis queues are used to process background jobs.
    • Statistics on Sidekiq queues is collected.
    • Coordination of email message processing is performed.
    • Operational data is stored.
  3. OpenSearch:

    • Indexes are used for advanced search.
    • Index maintenance tasks are performed.
  4. Git repositories: Store Git data.

  5. Object storage: It is used by all components to store various types of data, including: uploaded files, artifacts, LFS objects, packages, merge request diffs, Terraform state, dependency proxy cache, and backup archives.

  6. Ingress controller: Forwards incoming HTTP/HTTPS traffic.

  7. Kube-apiserver: Authorizes requests for metrics.

  8. External authentication providers: Authenticates users.

  9. Mail server: Receives and sends email messages.

The following external applications interact with Deckhouse Code:

  1. GitLab Runner: Requests new build jobs.
  2. GitLab Agent: Establishes a connection to receive commands.
  3. Prometheus: Collects component metrics.