GitLab-Omnibus Helm Chart

Note:

  • This Helm chart is in beta, and will be deprecated by the cloud native GitLab chart.
  • These charts have been tested on Google Container Engine and Azure Container Service. Other Kubernetes installations may work as well, if not please open an issue.

This work is based partially on: https://github.com/lwolf/kubernetes-gitlab/. GitLab would like to thank Sergey Nuzhdin for his work.

For more information on available GitLab Helm Charts, please see our overview.

Introduction 

This chart provides an easy way to get started with GitLab, provisioning an installation with nearly all functionality enabled. SSL is automatically provisioned via Let's Encrypt.

This Helm chart is in beta, and will be deprecated by the cloud native GitLab chart once available. Due to the difficulty in supporting upgrades, migrating will require exporting data out of this instance and importing it into the new deployment.

The deployment includes:

Limitations 

  • This chart is in beta, and suited for small to medium size deployments. High Availability and Geo are not supported.
  • A new generation cloud native GitLab chart is in development, and will deprecate this chart. Due to the difficulty in supporting upgrades to the new architecture, migrating will require exporting data out of this instance and importing it into the new deployment. We plan to release the new chart in beta by the end of 2017.

For more information on available GitLab Helm Charts, please see our overview.

Prerequisites 

  • At least 4 GB of RAM available on your cluster. 41GB of storage and 2 CPU are also required.
  • Kubernetes 1.4+ with Beta APIs enabled
  • Persistent Volume provisioner support in the underlying infrastructure
  • wildcard DNS entry, which resolves to the external IP address
  • The kubectl CLI installed locally and authenticated for the cluster
  • The Helm client installed locally on your machine

Networking Prerequisites 

This chart configures a GitLab server and Kubernetes cluster which can support dynamic Review Apps, as well as services like the integrated Container Registry and Mattermost.

To support the GitLab services and dynamic environments, a wildcard DNS entry is required which resolves to the Load Balanceror External IP. Configuration of the DNS entry will depend upon the DNS service being used.

External IP (Recommended) 

To provision an external IP on GCP and Azure, simply request a new address from the Networking section. Ensure that the region matches the region your container cluster is created in. Note, it is important that the IP is not assigned at this point in time. It will be automatically assigned once the Helm chart is installed, and assigned to the Load Balancer.

Now that an external IP address has been allocated, ensure that the wildcard DNS entry you would like to use resolves to this IP. Please consult the documentation for your DNS service for more information on creating DNS records.

Finally, set the baseIP setting to this IP address when deploying GitLab.

Load Balancer IP 

If you do not specify a baseIP, an IP will be assigned to the Load Balancer or Ingress. You can retrieve this IP by running the following command after deploying GitLab:

kubectl get svc -w --namespace nginx-ingress nginx

The IP address will be displayed in the EXTERNAL-IP field, and should be used to configure the Wildcard DNS entry. For more information on creating a wildcard DNS entry, consult the documentation for the DNS server you are using.

For production deployments of GitLab, we strongly recommend using an External IP.

Configuring and Installing GitLab 

For most installations, only two parameters are required:

  • baseDomain: the base domain of the wildcard host entry. For example, mycompany.io if the wild card entry is *.mycompany.io.
  • legoEmail: Email address to use when requesting new SSL certificates from Let's Encrypt.

Other common configuration options:

For additional configuration options, consult the values.yaml.

Choosing a different GitLab release version 

The version of GitLab installed is based on the gitlab setting (see section above), and the value of the corresponding helm setting: gitlabCEImage or gitabEEImage.

gitlab: CE
gitlabCEImage: gitlab/gitlab-ce:9.5.2-ce.0
gitlabEEImage: gitlab/gitlab-ee:9.5.2-ee.0

The different images can be found in the gitlab-ce and gitlab-ee repositories on Docker Hub.

Persistent storage 

Note: If you are using a machine type with support for less than 4 attached disks, like an Azure trial, you should disable dedicated storage for Postgres and Redis.

By default, persistent storage is enabled for GitLab and the charts it depends on (Redis and PostgreSQL).

Components can have their claim size set from your values.yaml, along with whether to provision separate storage for Postgres and Redis.

Basic configuration:

redisImage: redis:3.2.10
redisDedicatedStorage: true
redisStorageSize: 5Gi
postgresImage: postgres:9.6.3
# If you disable postgresDedicatedStorage, you should consider bumping up gitlabRailsStorageSize
postgresDedicatedStorage: true
postgresStorageSize: 30Gi
gitlabRailsStorageSize: 30Gi
gitlabRegistryStorageSize: 30Gi
gitlabConfigStorageSize: 1Gi

Routing and SSL 

Ingress routing and SSL are automatically configured within this Chart. An NGINX ingress is provisioned and configured, and will route traffic to any service. SSL certificates are automatically created and configured by kube-lego.

Note: Let's Encrypt limits a single TLD to five certificate requests within a single week. This means that common DNS wildcard services like xip.io and nip.io are unlikely to work.

Installing GitLab using the Helm Chart 

Note: You may see a temporary error message SchedulerPredicates failed due to PersistentVolumeClaim is not bound while storage provisions. Once the storage provisions, the pods will automatically start. This may take a couple minutes depending on your cloud provider. If the error persists, please review the prerequisites to ensure you have enough RAM, CPU, and storage.

Add the GitLab Helm repository and initialize Helm:

helm repo add gitlab https://charts.gitlab.io
helm init

Once you have reviewed the configuration settings you can install the chart. We recommending saving your configuration options in a values.yaml file for easier upgrades in the future.

For example:

helm install --name gitlab -f values.yaml gitlab/gitlab-omnibus

or passing them on the command line:

helm install --name gitlab --set baseDomain=gitlab.io,baseIP=1.1.1.1,gitlab=ee,gitlabEELicense=$LICENSE,legoEmail=email@gitlab.com gitlab/gitlab-omnibus

Updating GitLab using the Helm Chart 

Note: If you are upgrading from a previous version to 0.1.35 or above, you will need to change the access mode values for GitLab's storage. To do this, set the following in values.yaml or on the CLI:

gitlabDataAccessMode=ReadWriteMany
gitlabRegistryAccessMode=ReadWriteMany
gitlabConfigAccessMode=ReadWriteMany

Once your GitLab Chart is installed, configuration changes and chart updates should be done using helm upgrade:

helm upgrade -f values.yaml gitlab gitlab/gitlab-omnibus

Upgrading from CE to EE using the Helm Chart 

If you have installed the Community Edition using this chart, upgrading to Enterprise Edition is easy.

If you are using a values.yaml file to specify the configuration options, edit the file and set gitlab=ee. If you would like to run a specific version of GitLab EE, set gitlabEEImage to be the desired GitLab docker image. Then you can use helm upgradeto update your GitLab instance to EE:

helm upgrade -f values.yaml gitlab gitlab/gitlab-omnibus

You can also upgrade and specify these options via the command line:

helm upgrade gitlab --set gitlab=ee,gitlabEEImage=gitlab/gitlab-ee:9.5.5-ee.0 gitlab/gitlab-omnibus

Uninstalling GitLab using the Helm Chart 

To uninstall the GitLab Chart, run the following:

helm delete gitlab

Troubleshooting 

Storage errors when updating gitlab-omnibus versions prior to 0.1.35 

Users upgrading gitlab-omnibus from a version prior to 0.1.35, may see an error like: Error: UPGRADE FAILED: PersistentVolumeClaim "gitlab-gitlab-config-storage" is invalid: spec: Forbidden: field is immutable after creation.

This is due to a change in the access mode for GitLab storage in version 0.1.35. To successfully upgrade, the access mode flags must be set to ReadWriteMany as detailed in the update section.

<think>我们正在讨论的是在Docker中部署GitLab时,关于`GITLAB_OMNIBUS_CONFIG`环境变量的使用以及如何正确配置以解决`git clone`失败的问题。 根据引用[5]中的描述,`GITLAB_OMNIBUS_CONFIG`用于在容器启动时直接配置GitLab,它允许我们在环境变量中写入GitLab的配置(通常是`gitlab.rb`文件的内容)。这样,我们就不需要在容器启动后再进入容器修改配置文件,然后重新配置(`gitlab-ctl reconfigure`)。 但是,`GITLAB_OMNIBUS_CONFIG`并不是必须的。我们可以通过其他方式来配置GitLab,例如: 1. 在宿主机上挂载配置文件(如`/etc/gitlab/gitlab.rb`)到容器中,然后在容器启动后执行`gitlab-ctl reconfigure`。 2. 进入容器手动修改`/etc/gitlab/gitlab.rb`,然后执行`gitlab-ctl reconfigure`。 然而,使用`GITLAB_OMNIBUS_CONFIG`环境变量是一种在容器启动时自动配置的便捷方式。 关于`git clone`失败的问题,常见原因及解决方法如下: ### 1. **SSH配置问题** - 在Docker部署中,通常会将容器的SSH端口(22)映射到宿主机的另一个端口(如2222)。因此,在克隆时需要使用映射的端口。 - 正确克隆命令: ```bash git clone ssh://git@your-server:2222/your-project.git ``` - 确保在GitLab的配置中指定了SSH端口(通过`gitlab_rails['gitlab_shell_ssh_port']`设置),如引用[5]所示: ```yaml environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://服务器IP或域名:1083' gitlab_rails['gitlab_shell_ssh_port'] = 2222 ``` - 同时,确保宿主机的防火墙开放了2222端口。 ### 2. **HTTP/HTTPS配置问题** - 如果使用HTTP/HTTPS克隆,需要确保`external_url`配置正确,并且端口映射正确(如将容器80端口映射到宿主机的8088端口,则访问地址为`http://your-server:8088`)。 - 在引用[2]中,映射了`--publish 8088:80`,所以HTTP访问地址应该是`http://192.168.61.134:8088`。 - 在引用[5]中,配置了`external_url 'http://服务器IP或域名:1083'`,同时将容器的80端口映射到了宿主机的1083端口(`ports`中的`- '1083:1083'`)?这里需要注意,在引用[5]的配置中,`nginx['listen_port'] = 1083`表示容器内nginx监听1083端口,而外部端口映射为`- '1083:1083'`,所以外部访问地址为`http://服务器IP或域名:1083`。 ### 3. **配置后需要重新配置** - 如果修改了`gitlab.rb`(无论是通过挂载文件还是环境变量`GITLAB_OMNIBUS_CONFIG`),都需要在容器内运行`gitlab-ctl reconfigure`来使配置生效。 - 使用`GITLAB_OMNIBUS_CONFIG`环境变量时,在容器启动时会自动执行`reconfigure`(根据GitLab官方Docker镜像的启动脚本)。 ### 4. **容器内服务未完全启动** - GitLab容器启动需要一段时间(尤其是第一次启动时),如果立即尝试克隆可能会失败。可以通过查看日志`docker logs gitlab`来检查启动状态。 ### 5. **权限问题** - 确保挂载的目录有正确的权限。GitLab容器以`root`用户运行,但挂载的目录如果权限不足,可能导致配置无法写入。可以尝试在宿主机上修改挂载目录的权限: ```bash sudo chmod -R 777 /var/gitlab # 根据挂载目录,如引用[2]中的/var/gitlab ``` 或者更安全的方式是设置合适的用户和组。 ### 正确配置步骤(以引用[5]的docker-compose为例) 1. 在`docker-compose.yml`中,通过`environment`设置`GITLAB_OMNIBUS_CONFIG`,配置关键参数: ```yaml environment: TZ: 'Asia/Shanghai' GITLAB_OMNIBUS_CONFIG: | external_url 'http://your-server-ip:1083' gitlab_rails['time_zone'] = 'Asia/Shanghai' gitlab_rails['gitlab_shell_ssh_port'] = 2222 nginx['listen_port'] = 1083 # 容器内nginx监听的端口 ``` 注意:`external_url`中的端口应该与外部映射的HTTP端口一致(这里外部映射端口为1083,容器内nginx监听1083),而SSH端口映射为2222,所以配置`gitlab_shell_ssh_port`为2222。 2. 端口映射: ```yaml ports: - '1083:1083' # 将容器内的1083端口(nginx)映射到宿主机的1083 - '2222:22' # 将容器内的22端口(SSH)映射到宿主机的2222 ``` 3. 启动容器: ```bash docker-compose up -d ``` 4. 等待几分钟,让GitLab完全启动。 5. 测试克隆: - HTTP克隆: ```bash git clone http://your-server-ip:1083/your-project.git ``` - SSH克隆: ```bash git clone ssh://git@your-server-ip:2222/your-project.git ``` ### 结论 - `GITLAB_OMNIBUS_CONFIG`不是必须的,但它是推荐的在Docker中配置GitLab的方式,因为它可以在容器启动时自动完成配置。 - 解决`git clone`失败的关键是正确配置`external_url`和`gitlab_shell_ssh_port`,并确保端口映射正确,同时防火墙开放相应端口。 ### 相关问题 1. 如何在Docker中升级GitLab容器? 2. 如何备份和恢复GitLab容器中的数据? 3. 如何配置GitLab使用HTTPS? 4. 如何调整GitLab容器的资源限制(CPU、内存)? 5. GitLab容器启动后如何修改配置?</think>### Docker 部署 GitLab 时 `GITLAB_OMNIBUS_CONFIG` 的配置解析与问题解决 #### 1. **`GITLAB_OMNIBUS_CONFIG` 是否必须?** - **非必须**,但**强烈推荐**使用 该配置提供容器启动时自动加载关键参数的能力,可避免手动修改容器内文件(如 `gitlab.rb`)。若未配置,需通过以下方式补足: ```bash # 手动进入容器修改配置 docker exec -it gitlab vi /etc/gitlab/gitlab.rb docker exec -it gitlab gitlab-ctl reconfigure # 重新加载配置[^4] ``` #### 2. **`git clone` 失败的常见原因与解决方案** ##### 原因 1:SSH 端口映射错误(最高频问题) - **问题表现** `git clone ssh://git@host:22/project.git` 失败,提示 `Connection refused` - **解决方案** 在 `GITLAB_OMNIBUS_CONFIG` 中显式声明 SSH 端口: ```yaml environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://your-host:1083' gitlab_rails['gitlab_shell_ssh_port'] = 2222 # 必须与宿主机映射端口一致[^5] ports: - "2222:22" # 宿主端口:容器端口 ``` 克隆命令需包含端口号: ```bash git clone ssh://git@your-host:2222/your-project.git # 注意端口号[^3] ``` ##### 原因 2:`external_url` 配置错误 - **问题表现** Web 界面可访问但 `git clone http://...` 失败 - **解决方案** 确保三层一致性: 1. `external_url` 的端口(如 `:1083`) 2. 容器端口映射(如 `- "1083:1083"`) 3. `nginx['listen_port']` 值(如 `1083`) ```yaml environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://your-host:1083' # 必须带端口 nginx['listen_port'] = 1083 # 容器内Nginx监听端口[^5] ``` ##### 原因 3:防火墙/安全组限制 - **检查点** ```bash sudo ufw status # 查看防火墙 sudo ufw allow 2222 # 开放SSH端口 sudo ufw allow 1083 # 开放HTTP端口 ``` #### 3. **推荐配置模板(docker-compose.yml)** ```yaml version: '3' services: gitlab: image: 'twang2218/gitlab-ce-zh:latest' restart: always hostname: 'your-host-ip' environment: TZ: 'Asia/Shanghai' GITLAB_OMNIBUS_CONFIG: | # 关键配置段 external_url 'http://your-host-ip:1083' gitlab_rails['gitlab_shell_ssh_port'] = 2222 nginx['listen_port'] = 1083 gitlab_rails['time_zone'] = 'Asia/Shanghai' ports: - "1083:1083" # HTTP - "2222:22" # SSH volumes: - ./config:/etc/gitlab - ./data:/var/opt/gitlab - ./logs:/var/log/gitlab ``` #### 4. **验证步骤** 1. 检查端口映射: ```bash docker port gitlab # 确认2222->22, 1083->1083 ``` 2. 查看容器内配置: ```bash docker exec gitlab cat /etc/gitlab/gitlab.rb | grep external_url docker exec gitlab cat /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml | grep port ``` 3. 测试克隆: ```bash git clone http://your-host-ip:1083/root/test.git # HTTP测试 git clone ssh://git@your-host-ip:2222/root/test.git # SSH测试 ``` #### 5. **故障排查命令** ```bash # 查看容器日志 docker logs gitlab # 检查SSH服务状态 docker exec gitlab gitlab-ctl status gitlab-shell # 测试端口连通性 nc -zv your-host-ip 2222 # SSH端口 nc -zv your-host-ip 1083 # HTTP端口 ``` > 通过正确配置 `GITLAB_OMNIBUS_CONFIG` 中的端口参数,可彻底解决 99% 的 `git clone` 失败问题[^3][^5]。 --- ### 相关问题 1. 如何将 GitLab 的 HTTP 访问升级为 HTTPS? 2. Docker 中如何备份和恢复 GitLab 数据? 3. GitLab 容器启动时出现 `502 Whoops` 错误如何解决? 4. 如何通过 Docker 配置 GitLab Runner 实现 CI/CD? 5. GitLab 容器占用磁盘空间过大如何清理?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值