GitLab Instance Deployment
This document introduces how to subscribe to the Alauda Toolchain Code Repository E1 operator and deploy a GitLab instance.
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
PrerequisitesDeployment PlanningBasic InformationPre-deployment Resource PlanningPost-deployment Configuration PlanningInstance DeploymentDeploying from theGitLab Quick Start TemplateDeploying from the GitLab High Availability TemplateDeploying from YAMLYAML Snippets Based on Deployment PlanningComplete YAML Example: Single Instance, Node Storage, NodePort Network AccessComplete YAML Example: High Availability, Storage Class, Ingress Network AccessNext StepsConfigure Single Sign-On (SSO)Configure HTTPSConfigure Monitoring DashboardConfigure External Load Balancer (LB)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 the
Alauda Toolchain Code Repository E1operator has been deployed (subscribed) in the target cluster, i.e., the GitLab instance can be created from theAlauda Toolchain Code Repository E1operator.
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
Alauda Toolchain Code Repository E1operator 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 three network access methods:
NodePort,IngressandGateway API-
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 -
Gateway APIis intended for clusters that provide Gateway API instead of Ingress. It requires a domain name and aGatewaycreated in advance in the instance namespace; the instance is exposed through anHTTPRouteattached to thatGateway. See Gateway API Access for details
-
-
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 v16. 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 Alauda Toolchain Code Repository E1 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 or Gateway API method, requires domain name specification. When choosing Gateway API, select a
Gatewaythat already exists in the instance namespace - 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 three methods: domain name access through Ingress, domain name access through Gateway API, and NodePort access.
Domain name access (Ingress) configuration snippet:
NodePort method requires configuring two ports: HTTP port and SSH port.
NodePort access configuration snippet:
Gateway API Access
In clusters that provide Gateway API but no Ingress controller, expose the instance through an HTTPRoute attached to an existing Gateway.
Prerequisites:
- The cluster has the Gateway API CRDs and a Gateway controller installed (for example, Envoy Gateway), and a
GatewayClassis available. - A
Gatewayexists in the same namespace as the GitLab instance. It must have anHTTPlistener whosehostnameis empty or matches the instance domain name, and itsallowedRoutesmust accept routes from that namespace. The listener name is required in the instance configuration (sectionName). - The domain name resolves to the address of the
Gateway(seestatus.addressesof theGateway).
A minimal Gateway example:
Gateway API access configuration snippet:
Notes:
- Do not set
global.gatewayApi.enabled. It makes the chart create its ownGatewayand Envoy configuration, which is not needed when an existingGatewayis used. - If users reach the
HTTPlistener of theGatewayon a port other than 80 (for example, theGatewayService is aNodePort), set that port asglobal.appConfig.gitlabPortand include it inspec.externalURL(for example,http://gitlab.example.com:30080). GitLab cannot detect the external port, so without this setting the clone URLs and links it generates leave out the port. - Only the web entry goes through the
Gateway. To expose SSH, use the NodePort configuration ofgitlab-shellshown above. - Attach the route to an
HTTPlistener, as in the example. As with Ingress access, the instance is deployed with HTTP; to serve it over HTTPS, see Configure HTTPS after deployment. - The
HTTPRoutedoes not set timeouts or body size limits, so the defaults of the Gateway controller apply instead of the Ingress annotations described in How to Tune Webservice Ingress Timeout and Body Size. With Envoy Gateway, pushing a 400 MB repository (39 s) and cloning it (21 s) worked with the defaults. If large transfers are cut off, raise the limits with the policy resources of the Gateway controller (for Envoy Gateway, aBackendTrafficPolicyorClientTrafficPolicythat targets theHTTPRouteor theGateway). - The
HTTPRouteis named<instance name>-gitlab. Check that it is accepted withkubectl -n <namespace> get httproute <instance name>-gitlab -o yaml(status.parents[].conditionsshould containAcceptedandResolvedRefswith statusTrue). - To switch an existing instance from Ingress to Gateway API, see Migrate an Existing Instance from Ingress to Gateway API.
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:
For an instance exposed through Gateway API, TLS is terminated at the Gateway instead. Add an HTTPS listener that references the certificate secret to the Gateway (the Gateway and the secret are in the instance namespace):
Then attach the route to that listener and enable HTTPS in the GitLab instance:
If users reach the HTTPS listener on a port other than 443, also set global.appConfig.gitlabPort to that port. The route is then attached only to the HTTPS listener, so requests to the HTTP listener return 404. To send them to HTTPS, attach an HTTPRoute with a RequestRedirect filter (scheme: https) to the HTTP listener. If the two listeners are reached on non-default ports (for example, NodePorts), also set port in the filter to the external HTTPS port; otherwise the redirect keeps the HTTP port.
Configure Monitoring Dashboard
The Alauda Toolchain Code Repository E1 operator provides default support for the platform operations center monitoring dashboard. When the Alauda Toolchain Code Repository E1 operator and a 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
GitLab is a trademark of GitLab Inc.
Alauda is an independent vendor. This product is not affiliated with, endorsed by, or sponsored by GitLab Inc. All trademarks are the property of their respective owners and are used here for identification purposes only.