Skip to content

GitLab as self-hosted Git repository

GitLab is a self-hosted Git repository manager that can be deployed on-premises or on private infrastructure.^[400-devops-06-kubernetes-k8s-paas-05k8scicd.md] It serves as a centralized location for source code management, similar to GitHub or Gitee, but offers the control and security of local hosting.

Deployment and Configuration

In a typical Kubernetes-based DevOps environment, GitLab is often installed on a dedicated operations node (e.g., 10.4.7.200) using RPM packages via yum.^[400-devops-06-kubernetes-k8s-paas-05k8scicd.md] Key configuration steps include:

  1. Package Installation: Installing gitlab-ce (Community Edition) from a trusted mirror, such as Tsinghua University.^[400-devops-06-kubernetes-k8s-paas-05k8scicd.md]
  2. External URL: Modifying /etc/gitlab/gitlab.rb to set the external_url and the Nginx listen port (e.g., port 10000).^[400-devops-06-kubernetes-k8s-paas-05k8scicd.md]
  3. DNS Resolution: Adding a DNS A record (e.g., gitlab.od.com -> 10.4.7.200) to the domain zone configuration to allow internal network access.^[400-devops-06-kubernetes-k8s-paas-05k8scicd.md]

After configuration, the service is started using gitlab-ctl reconfigure, which initializes the application and its dependencies (PostgreSQL, Redis, Nginx).^[400-devops-06-kubernetes-k8s-paas-05k8scicd.md]

Integration with CI/CD

GitLab acts as the source control backend within a Continuous Integration/Continuous Delivery (CI/CD) pipeline.^[400-devops-06-kubernetes-k8s-paas-05k8scicd.md]

  • Alternative to Public Repos: While Gitee or GitHub are valid options, a self-hosted GitLab is preferred in enterprise scenarios to ensure stability and avoid external network dependencies during the build and deployment phases.^[400-devops-06-kubernetes-k8s-paas-05k8scicd.md]
  • Pipeline Trigger: Jenkins pipelines reference the self-hosted GitLab repository URL to pull source code (e.g., http://gitlab.od.com:10000/...).^[400-devops-06-kubernetes-k8s-paas-05k8scicd.md]
  • Access Control: SSH keys are typically used to facilitate secure, passwordless authentication between the build server and the Git repository.^[400-devops-06-kubernetes-k8s-paas-05k8scicd.md]

Sources

^[400-devops-06-kubernetes-k8s-paas-05k8scicd.md]