GitLab Instance Deployment
This document introduces GitLab Operator subscription and GitLab instance deployment functionality.
Gitlab does not support deployment in namespaces with SPA (Security Policy Admission) policy set to Restricted due to the following reasons:
-
Init Container Requires Root Privileges: GitLab uses init containers to initialize PVC directory permissions, which requires root privileges that are not allowed under the Restricted policy.
-
Gitaly Component Requires Special System Calls: The Gitaly component requires specific system calls that are incompatible with
seccompProfileconfigured asRuntimeDefault.
Recommendation: Create a dedicated namespace for the GitLab deployment and ensure that its security policy is not set to Restricted. When deploying GitLab with hostPath storage, the namespace security policy must be configured as Privileged.
TOC
Prerequisites
-
This document applies to GitLab 17 and above versions provided by the platform. It is decoupled from the platform based on technologies such as Operator.
-
Please ensure that GitLab Operator has been deployed (subscribed) in the target cluster, i.e., the GitLab instance can be created from GitLab Operator.
Deployment Planning
GitLab supports various resource configurations to accommodate different customer scenarios. In different scenarios, the required resources and configurations may vary significantly. Therefore, this section introduces the aspects to consider when planning a GitLab instance deployment, as well as the impact of decision points, to help users make informed decisions for subsequent instance deployments.
Basic Information
-
The GitLab Operator provided by the platform is based on the official community GitLab Operator, with enterprise-level capability enhancements such as IPv6 support, ARM support, and security vulnerability fixes. It is fully compatible with the community version in terms of functionality, and enhances the convenience of GitLab deployment through optional and customizable templates.
-
A GitLab instance includes multiple components, such as the
Gitaly componentresponsible for Git repository access, thePostgreSQLcomponent providing storage for application metadata and user information, and theRediscomponent used for caching, etc. The platform provides professional PostgreSQL Operator and Redis Operator, so when deploying a GitLab instance, Redis and PostgreSQL resources are no longer deployed directly, but accessed through configuring specific access credentials to existing instances.
Pre-deployment Resource Planning
Pre-deployment resource planning refers to the resource planning that needs to be decided before deployment and takes effect during deployment. The main content includes:
High Availability
-
GitLab supports high availability deployment. The main impacts and limitations of this mode are:
-
Each component will be deployed with multiple replicas
-
Network access no longer supports
NodePort, but requires access through domain names configured viaIngress -
Storage method no longer supports
node storage, but requires access throughStorageClassorPVC
-
Resources
According to community recommendations and practices, a non-high-availability GitLab instance can run with a minimum of 3 cores and 6Gi of resources, while in high availability mode, a minimum of 18 cores and 22Gi of resources is required for stable operation.
Storage
-
Common storage methods provided by the platform can be used for GitLab, such as storage classes, persistent volume claims, node storage, etc.
-
TopoLVM storage class is recommended for Gitaly storage
-
Node storage is not suitable for
high availabilitymode, as it stores files in a specified path on the host node
-
-
In addition, GitLab also supports object storage. In this mode, separate storage access method adaptation is required. Please consult the vendor for details.
Network
-
The platform provides two mainstream network access methods:
NodePortandIngress-
NodePortrequires specifying HTTP and SSH ports, and ensuring that the ports are available.NodePortis not suitable forhigh availabilitymode -
Ingressrequires specifying a domain name and ensuring that the domain name resolution is working properly
-
-
The platform supports the HTTPS protocol, which needs to be configured after instance deployment. See Configure HTTPS for details.
Redis
-
The Redis component version currently required by GitLab is v6. It is recommended to deploy Redis instances using the Redis Operator provided by the platform, and then complete Redis integration by configuring access credentials.
- Redis access is achieved by configuring a
secretresource with specific format content. See Configure Redis, PostgreSQL, and Account Credentials for details.
- Redis access is achieved by configuring a
PostgreSQL
-
The PostgreSQL component version currently required by GitLab is v14. It is recommended to deploy PostgreSQL instances using the PostgreSQL Operator provided by the platform, and then complete PostgreSQL integration by configuring access credentials.
- PostgreSQL access is achieved by configuring a
secretresource with specific format content. See Configure Redis, PostgreSQL, and Account Credentials for details.
- PostgreSQL access is achieved by configuring a
-
Note: In high availability mode, the Gitaly component is in Cluster mode and requires an additional PostgreSQL credential configured in the same way as above to access a separate database. It can be two different databases under the same PostgreSQL instance.
Account Credentials
When creating a GitLab instance, you need to configure the root account and its password. This is done by configuring a secret resource. See Configure Redis, PostgreSQL, and Account Credentials for details.
Post-deployment Configuration Planning
Post-deployment configuration planning refers to configurations that do not need to be decided before deployment but can be completed as needed through standardized operations after deployment. These mainly include Single Sign-On (SSO), HTTPS configuration, external load balancer configuration, etc. For details, refer to Next Steps.
Instance Deployment
The GitLab Operator provided by the platform offers two deployment methods: deployment from templates and deployment from YAML.
The platform provides two built-in templates: the GitLab Quick Start template and the GitLab High Availability template, while also supporting customer-defined templates to meet their specific scenarios.
Information about the built-in templates and YAML deployment is as follows:
Deploying from the GitLab Quick Start Template
This template is used to quickly create a lightweight GitLab instance suitable for development and testing scenarios, not recommended for production environments.
- Computing resources: 3 CPU cores, 6Gi memory
- Storage method: Uses local node storage, requires configuring storage node IP and path
- Network access: Uses NodePort method, shares the node IP with storage, requires port specification
- Dependent services: Requires configuration of existing Redis and PostgreSQL access credentials
- Other settings: Requires account credentials configuration, SSO functionality is disabled by default
Complete the deployment by filling in the relevant information according to the template prompts.
Deploying from the GitLab High Availability Template
Deploying a high-availability GitLab instance requires higher resource configuration and provides a higher availability standard.
- Computing resources: 18 CPU cores, 22Gi memory
- Storage method: Uses storage class resources to store Gitaly, the code repository component
- Network access: Uses Ingress method, requires domain name specification
- Dependent services: Requires configuration of existing Redis and PostgreSQL access credentials, and additionally requires separate access credentials for another independent database in the PG instance for the Gitaly component
- Other settings: Requires account credentials configuration, SSO functionality is disabled by default
To achieve GitLab high availability, external dependencies must meet the following conditions:
- The
attachment storage classmust support multi-node read and write (ReadWriteMany) - The
RedisandPostgreSQLinstances must be highly available - The network load balancer must be highly available; when using ALB, a VIP must be configured
- The cluster must have more than 2 nodes
Complete the deployment by filling in the relevant information according to the template prompts.
Deploying from YAML
YAML deployment is the most basic and powerful deployment capability. Here we provide corresponding YAML snippets for each dimension from the Deployment Planning section, and then provide two complete YAML examples for different scenarios to help users understand the YAML configuration method and make changes as needed.
YAML Snippets Based on Deployment Planning
High Availability
In high availability mode, Gitaly needs to use cluster mode, and other components need at least 2 replicas. The YAML configuration snippet for high availability deployment is as follows:
Storage
GitLab data storage mainly includes two parts:
- Gitaly storage: Stores code repository data
- Attachment storage: Stores user avatars, user-uploaded images, etc.
Currently, three storage configuration methods are supported: storage class, PVC, and local node storage.
Storage class configuration snippet:
PVC configuration snippet:
Local node storage configuration snippet:
Network Access
Network access mainly includes two methods: domain name access and NodePort access.
Domain name access configuration snippet:
NodePort method requires configuring two ports: HTTP port and SSH port.
NodePort access configuration snippet:
Redis Access Credential Configuration
This refers to the configuration snippet in the GitLab instance for the Redis credential after configuring the secret resource with Redis credentials:
Standalone example:
Sentinel example:
PostgreSQL Access Credential Configuration
This refers to the configuration snippet in the GitLab instance for the PostgreSQL credential after configuring the secret resource with PostgreSQL credentials, which also includes the case of configuring two PostgreSQL databases in high availability mode:
Root Account Configuration
This refers to the configuration snippet in the GitLab instance for the account credential after configuring the secret resource with account credentials:
Complete YAML Example: Single Instance, Node Storage, NodePort Network Access
Complete YAML Example: High Availability, Storage Class, Ingress Network Access
Next Steps
Configure Single Sign-On (SSO)
Configuring SSO involves the following steps:
- Register an SSO authentication client in the global cluster
- Prepare the SSO authentication configuration
- Configure the GitLab instance to use the SSO authentication configuration
Create the following Oauth2Client resource in the global cluster to register the SSO authentication client.
Prepare the configuration content according to the comments in the JSON below.
Save the configuration content to a secret and create it in the namespace where the GitLab instance is located.
Edit the GitLab instance to add the following configuration:
Enable SSO for Platforms Using Self-Signed Certificates
If the platform is accessed via HTTPS and uses a self-signed certificate, you need to mount the self-signed certificate's CA to the GitLab instance as follows:
In the cpaas-system namespace of the global cluster, find the secret named dex.tls, get the ca.crt content from the secret, save it as a new secret, and create it in the namespace of the GitLab instance.
The certificate must be in PEM format.
Edit the GitLab instance to use this CA:
Configure HTTPS
After deploying the GitLab instance, you can configure HTTPS as needed.
First, create a TLS certificate secret in the namespace where the instance is located.
Then edit the YAML configuration of the GitLab instance to enable HTTPS access:
Configure Monitoring Dashboard
GitLab Operator provides default support for the platform operations center monitoring dashboard. When GitLab Operator and GitLab instance are deployed, GitLab Metrics will be automatically configured and can be viewed in the operations center monitoring dashboard.
Configure External Load Balancer (LB)
Configure External Load Balancer (LB) for GitLab