在Kubernetes部署GitLab

本文涉及的产品
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
容器服务 Serverless 版 ACK Serverless,952元额度 多规格
简介: GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务。安装方法是参考GitLab在GitHub上的Wiki页面。GitLab是由GitLabInc.开发,使用MIT许可证的基于网络的Git仓库管理工具,且具有wiki和issue跟踪功能。使用Git作为代码管理工具,并在此基础上搭建起来的web服务

在Kubernetes部署GitLab

前置条件

已安装Helm工具
已部署NFS自动创建PVC

使用HELM安装

[root@k8s-master01 ~]# helm repo add gitlab https://charts.gitlab.io/
"gitlab" has been added to your repositories

[root@k8s-master01 ~]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "gitlab" chart repository
...Successfully got an update from the "cilium" chart repository
Update Complete. ⎈Happy Helming!⎈


[root@k8s-master01 ~]# helm upgrade --install gitlab gitlab/gitlab \
  --timeout 600s \
  --set global.hosts.domain=git.oiox.cn \
  --set global.hosts.externalIP=192.168.1.61 \
  --set certmanager-issuer.email=cby@chenby.cn 
  
NAME: gitlab
LAST DEPLOYED: Mon Sep 12 19:49:30 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
=== NOTICE
The minimum required version of PostgreSQL is now 12. See https://gitlab.com/gitlab-org/charts/gitlab/-/blob/master/doc/installation/upgrade.md for more details.

=== NOTICE
You've installed GitLab Runner without the ability to use 'docker in docker'.
The GitLab Runner chart (gitlab/gitlab-runner) is deployed without the `privileged` flag by default for security purposes. This can be changed by setting `gitlab-runner.runners.privileged` to `true`. Before doing so, please read the GitLab Runner chart's documentation on why we
chose not to enable this by default. See https://docs.gitlab.com/runner/install/kubernetes.html#running-docker-in-docker-containers-with-gitlab-runners
Help us improve the installation experience, let us know how we did with a 1 minute survey:https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=helm&release=15-3

=== NOTICE
The in-chart NGINX Ingress Controller has the following requirements:
    - Kubernetes version must be 1.19 or newer.
    - Ingress objects must be in group/version `networking.k8s.io/v1`.
[root@k8s-master01 ~]# 

查看POD情况

[root@k8s-master01 ~]# kubectl get pod -A
NAMESPACE           NAME                                                     READY   STATUS      RESTARTS         AGE
cilium-monitoring   grafana-59957b9549-6zzqh                                 1/1     Running     1 (6m28s ago)    8h
cilium-monitoring   prometheus-7c8c9684bb-4v9cl                              1/1     Running     1 (4m49s ago)    8h
default             chenby-75b5d7fbfb-7zjsr                                  1/1     Running     1 (6m15s ago)    35h
default             chenby-75b5d7fbfb-hbvr8                                  1/1     Running     1 (5m27s ago)    35h
default             chenby-75b5d7fbfb-ppbzg                                  1/1     Running     1 (5m57s ago)    35h
default             cm-acme-http-solver-8b6lg                                1/1     Running     1 (4m49s ago)    11m
default             cm-acme-http-solver-9sd7r                                1/1     Running     1 (4m49s ago)    11m
default             cm-acme-http-solver-tx5x2                                1/1     Running     1 (5m27s ago)    11m
default             cm-acme-http-solver-w74zd                                1/1     Running     1 (4m49s ago)    11m
default             echo-a-6799dff547-pnx6w                                  1/1     Running     1 (6m28s ago)    8h
default             echo-b-fc47b659c-4bdg9                                   1/1     Running     1 (4m49s ago)    8h
default             echo-b-host-67fcfd59b7-28r9s                             1/1     Running     1 (4m49s ago)    8h
default             gitlab-certmanager-7cb7797848-fgdff                      1/1     Running     1 (5m27s ago)    12m
default             gitlab-certmanager-cainjector-5968cb88f9-qw4d7           1/1     Running     2 (5m57s ago)    12m
default             gitlab-certmanager-webhook-797bcff548-t266p              1/1     Running     1 (6m15s ago)    12m
default             gitlab-gitaly-0                                          1/1     Running     1 (6m28s ago)    12m
default             gitlab-gitlab-exporter-58fc5779d7-lbl4s                  1/1     Running     1 (5m27s ago)    12m
default             gitlab-gitlab-runner-5484688b78-d5gmt                    0/1     Running     3 (2m8s ago)     12m
default             gitlab-gitlab-shell-7578c56d55-p5fvp                     1/1     Running     1 (5m27s ago)    12m
default             gitlab-gitlab-shell-7578c56d55-vzbrb                     1/1     Running     1 (4m49s ago)    12m
default             gitlab-issuer-1-sw7nm                                    0/1     Completed   0                12m
default             gitlab-kas-85f677867b-sjxqv                              1/1     Running     1 (4m49s ago)    12m
default             gitlab-kas-85f677867b-wwlsl                              1/1     Running     1 (6m28s ago)    12m
default             gitlab-migrations-1-hpsc8                                0/1     Completed   2                12m
default             gitlab-minio-74467697bb-76xcb                            1/1     Running     1 (4m49s ago)    12m
default             gitlab-minio-create-buckets-1-nwzh2                      0/1     Completed   0                12m
default             gitlab-nginx-ingress-controller-77589fdd6f-7rk5f         1/1     Running     1 (5m27s ago)    12m
default             gitlab-nginx-ingress-controller-77589fdd6f-lk96x         1/1     Running     1 (4m49s ago)    12m
default             gitlab-postgresql-0                                      2/2     Running     2 (5m27s ago)    12m
default             gitlab-prometheus-server-6bf4fffc55-ww59q                2/2     Running     2 (6m14s ago)    12m
default             gitlab-redis-master-0                                    2/2     Running     2 (4m49s ago)    12m
default             gitlab-registry-54899b8c96-gkmm2                         1/1     Running     1 (5m27s ago)    12m
default             gitlab-registry-54899b8c96-pzxcd                         1/1     Running     1 (5m57s ago)    12m
default             gitlab-sidekiq-all-in-1-v2-64cbbc8cd8-4pmm9              1/1     Running     1 (5m57s ago)    12m
default             gitlab-sidekiq-all-in-1-v2-64cbbc8cd8-fr2wn              1/1     Running     0                81s
default             gitlab-sidekiq-all-in-1-v2-64cbbc8cd8-sx8b6              1/1     Running     0                81s
default             gitlab-toolbox-746c98d8f6-cxwl9                          1/1     Running     1 (5m27s ago)    12m
default             gitlab-webservice-default-6998494449-9hrtc               2/2     Running     1 (6m28s ago)    12m
default             gitlab-webservice-default-6998494449-kdbbq               2/2     Running     2 (6m14s ago)    12m
default             host-to-b-multi-node-clusterip-69c57975d6-z4j2z          1/1     Running     3 (4m6s ago)     8h
default             host-to-b-multi-node-headless-865899f7bb-frrmc           1/1     Running     2 (4m16s ago)    8h
default             nfs-client-provisioner-665598d599-4xwmf                  1/1     Running     3 (5m57s ago)    52m
default             pod-to-a-allowed-cnp-5f9d7d4b9d-hcd8x                    1/1     Running     4 (3m54s ago)    8h
default             pod-to-a-denied-cnp-65cc5ff97b-2rzb8                     1/1     Running     1 (6m28s ago)    8h
default             pod-to-a-dfc64f564-p7xcn                                 1/1     Running     3 (4m6s ago)     8h
default             pod-to-b-intra-node-nodeport-677868746b-trk2l            1/1     Running     1 (4m49s ago)    8h
default             pod-to-b-multi-node-clusterip-76bbbc677b-knfq2           1/1     Running     2 (4m2s ago)     8h
default             pod-to-b-multi-node-headless-698c6579fd-mmvd7            1/1     Running     2 (4m48s ago)    8h
default             pod-to-b-multi-node-nodeport-5dc4b8cfd6-8dxmz            1/1     Running     2 (4m48s ago)    8h
default             pod-to-external-1111-8459965778-pjt9b                    1/1     Running     13 (5m57s ago)   8h
default             pod-to-external-fqdn-allow-google-cnp-64df9fb89b-l9l4q   1/1     Running     15 (4m39s ago)   8h
kube-system         cilium-7rfj6                                             1/1     Running     1 (5m27s ago)    8h
kube-system         cilium-d4cch                                             1/1     Running     1 (6m28s ago)    8h
kube-system         cilium-h5x8r                                             1/1     Running     1 (5m57s ago)    8h
kube-system         cilium-operator-5dbddb6dbf-flpl5                         1/1     Running     1 (6m28s ago)    8h
kube-system         cilium-operator-5dbddb6dbf-gcznc                         1/1     Running     2 (4m49s ago)    8h
kube-system         cilium-t2xlz                                             1/1     Running     1 (4m49s ago)    8h
kube-system         cilium-z65z7                                             1/1     Running     1 (6m15s ago)    8h
kube-system         coredns-665475b9f8-jkqn8                                 1/1     Running     2 (4m49s ago)    44h
kube-system         hubble-relay-59d8575-9pl9z                               1/1     Running     1 (6m28s ago)    8h
kube-system         hubble-ui-64d4995d57-nsv9j                               2/2     Running     2 (6m28s ago)    8h
kube-system         metrics-server-776f58c94b-c6zgs                          1/1     Running     2 (6m14s ago)    45h
[root@k8s-master01 ~]# 

查看INGRESS情况

[root@k8s-master01 ~]# kubectl  get svc -A | grep ingress
default             gitlab-nginx-ingress-controller           LoadBalancer   10.111.0.148     <pending>     80:32002/TCP,443:31390/TCP,22:30887/TCP   26m
default             gitlab-nginx-ingress-controller-metrics   ClusterIP      10.104.165.192   <none>        10254/TCP                                 26m

# 修改为NodePort
[root@k8s-master01 ~]# kubectl  edit svc gitlab-nginx-ingress-controller
service/gitlab-nginx-ingress-controller edited
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# kubectl  get svc -A | grep ingress
default             gitlab-nginx-ingress-controller           NodePort    10.111.0.148     <none>        80:32002/TCP,443:31390/TCP,22:30887/TCP   26m
default             gitlab-nginx-ingress-controller-metrics   ClusterIP   10.104.165.192   <none>        10254/TCP                                 26m
[root@k8s-master01 ~]# 
[root@k8s-master01 ~]# 

# 查看有哪些域名
[root@k8s-master01 ~]# kubectl  get ingress
NAME                        CLASS          HOSTS                  ADDRESS        PORTS     AGE
cm-acme-http-solver-84tql   gitlab-nginx   minio.git.oiox.cn      10.111.0.148   80        25m
cm-acme-http-solver-c4n6s   gitlab-nginx   kas.git.oiox.cn        10.111.0.148   80        25m
cm-acme-http-solver-vwn4s   gitlab-nginx   gitlab.git.oiox.cn     10.111.0.148   80        25m
cm-acme-http-solver-zccvm   gitlab-nginx   registry.git.oiox.cn   10.111.0.148   80        25m
gitlab-kas                  gitlab-nginx   kas.git.oiox.cn        10.111.0.148   80, 443   27m
gitlab-minio                gitlab-nginx   minio.git.oiox.cn      10.111.0.148   80, 443   27m
gitlab-registry             gitlab-nginx   registry.git.oiox.cn   10.111.0.148   80, 443   27m
gitlab-webservice-default   gitlab-nginx   gitlab.git.oiox.cn     10.111.0.148   80, 443   27m
[root@k8s-master01 ~]# 

本地写入域名

[root@k8s-master01 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

# 没有IPv6选择不配置即可
2409:8a10:9e10:8700::10 k8s-master01
2409:8a10:9e10:8700::20 k8s-master02
2409:8a10:9e10:8700::30 k8s-master03
2409:8a10:9e10:8700::40 k8s-node01
2409:8a10:9e10:8700::50 k8s-node02

192.168.1.61 k8s-master01
192.168.1.62 k8s-master02
192.168.1.63 k8s-master03
192.168.1.64 k8s-node01
192.168.1.65 k8s-node02
192.168.1.66 lb-vip

192.168.1.61 kas.git.oiox.cn
192.168.1.61 minio.git.oiox.cn
192.168.1.61 registry.git.oiox.cn
192.168.1.61 gitlab.git.oiox.cn
[root@k8s-master01 ~]# 

测试访问

# 查看密码
[root@k8s-master01 ~]# kubectl get secret gitlab-gitlab-initial-root-password -ojsonpath='{.data.password}' | base64 --decode ; echo
Hh7EjzH01T7DJw7TutWG6ynAU8yoGYcxNcV0cADCIpRCPeuFA5DBTC1I5V4T4gz4
[root@k8s-master01 ~]# 

# 访问
https://gitlab.git.oiox.cn:31390/

123

关于

https://www.oiox.cn/

https://www.oiox.cn/index.php/start-page.html

CSDN、GitHub、知乎、开源中国、思否、掘金、简书、华为云、阿里云、腾讯云、哔哩哔哩、今日头条、新浪微博、个人博客

全网可搜《小陈运维》

文章主要发布于微信公众号

相关实践学习
通过Ingress进行灰度发布
本场景您将运行一个简单的应用,部署一个新的应用用于新的发布,并通过Ingress能力实现灰度发布。
容器应用与集群管理
欢迎来到《容器应用与集群管理》课程,本课程是“云原生容器Clouder认证“系列中的第二阶段。课程将向您介绍与容器集群相关的概念和技术,这些概念和技术可以帮助您了解阿里云容器服务ACK/ACK Serverless的使用。同时,本课程也会向您介绍可以采取的工具、方法和可操作步骤,以帮助您了解如何基于容器服务ACK Serverless构建和管理企业级应用。 学习完本课程后,您将能够: 掌握容器集群、容器编排的基本概念 掌握Kubernetes的基础概念及核心思想 掌握阿里云容器服务ACK/ACK Serverless概念及使用方法 基于容器服务ACK Serverless搭建和管理企业级网站应用
相关文章
|
1月前
|
Kubernetes 持续交付 Docker
利用 Docker 和 Kubernetes 实现微服务部署
【10月更文挑战第2天】利用 Docker 和 Kubernetes 实现微服务部署
|
28天前
|
Prometheus Kubernetes 监控
k8s部署针对外部服务器的prometheus服务
通过上述步骤,您不仅成功地在Kubernetes集群内部署了Prometheus,还实现了对集群外服务器的有效监控。理解并实施网络配置是关键,确保监控数据的准确无误传输。随着监控需求的增长,您还可以进一步探索Prometheus生态中的其他组件,如Alertmanager、Grafana等,以构建完整的监控与报警体系。
115 60
|
29天前
|
Prometheus Kubernetes 监控
k8s部署针对外部服务器的prometheus服务
通过上述步骤,您不仅成功地在Kubernetes集群内部署了Prometheus,还实现了对集群外服务器的有效监控。理解并实施网络配置是关键,确保监控数据的准确无误传输。随着监控需求的增长,您还可以进一步探索Prometheus生态中的其他组件,如Alertmanager、Grafana等,以构建完整的监控与报警体系。
170 62
|
1月前
|
运维 Linux 开发工具
第22篇 如何部署gitLab进行开发版本控制
第22篇 如何部署gitLab进行开发版本控制
|
1月前
|
Kubernetes Docker 微服务
微服务实践k8s&dapr开发部署实验(1)服务调用(一)
微服务实践k8s&dapr开发部署实验(1)服务调用(一)
48 2
|
1月前
|
Kubernetes 网络安全 容器
基于Ubuntu-22.04安装K8s-v1.28.2实验(一)部署K8s
基于Ubuntu-22.04安装K8s-v1.28.2实验(一)部署K8s
130 2
|
26天前
|
NoSQL 关系型数据库 Redis
高可用和性能:基于ACK部署Dify的最佳实践
本文介绍了基于阿里云容器服务ACK,部署高可用、可伸缩且具备高SLA的生产可用的Dify服务的详细解决方案。
|
1月前
|
Kubernetes Cloud Native 流计算
Flink-12 Flink Java 3分钟上手 Kubernetes云原生下的Flink集群 Rancher Stateful Set yaml详细 扩容缩容部署 Docker容器编排
Flink-12 Flink Java 3分钟上手 Kubernetes云原生下的Flink集群 Rancher Stateful Set yaml详细 扩容缩容部署 Docker容器编排
68 0
|
1月前
|
Kubernetes 网络协议 安全
[kubernetes]二进制方式部署单机k8s-v1.30.5
[kubernetes]二进制方式部署单机k8s-v1.30.5
|
1月前
|
Kubernetes Docker 微服务
微服务实践k8s&dapr开发部署实验(1)服务调用(二)
微服务实践k8s&dapr开发部署实验(1)服务调用(二)
48 0