测试开发技术网站
博客
设计
设计
开发
Python
测试
unittest
运维
Linux基础应用
CI/CD
CI/CD
数据库
数据库
云计算
云计算
云原生
云原生
爬虫
爬虫
数据分析
数据分析
人工智能
人工智能
登录
注册
Gitlab----基于Kubernetes安装Gitlab
收藏本文
作者:redrose2100 类别: 日期:2023-05-16 17:22:56 阅读:558 次 消耗积分:0 分
[【原文链接】Gitlab----基于Kubernetes安装Gitlab](http://devops-dev.com/article/621) (1)创建命名空间gitlba ```bash kubectl create namespace gitlab ``` (2)然后创建Gitlab用的PVC,编写yaml配置文件如下 ```yaml kind: PersistentVolumeClaim apiVersion: v1 metadata: namespace: gitlab name: gitlab-data spec: accessModes: - ReadWriteOnce resources: requests: storage: 40Gi ``` 然后使用如下命令创建 ```bash kubectl apply -f pvc-gitlab.yaml ``` (3)创建Postgre用的PVC的配置文件 pvc-postsql.yaml ```yaml kind: PersistentVolumeClaim apiVersion: v1 metadata: name: postsql namespace: gitlab spec: accessModes: - ReadWriteMany resources: requests: storage: 5Gi ``` 然后执行如下命令 ```bash kubectl apply -f pvc-postsql.yaml ``` (4)为redis创建pvc,文件名 pvc-redis.yaml ```yaml kind: PersistentVolumeClaim apiVersion: v1 metadata: name: redis-data namespace: gitlab spec: accessModes: - ReadWriteMany resources: requests: storage: 5Gi ``` 然后执行如下命令创建供redis使用的pvc ```bash kubectl apply -f pvc-redis.yaml ``` (5)编写创建postgresql的yaml配置文件 ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: postgresql namespace: gitlab labels: name: postgresql spec: selector: matchLabels: name: postgresql template: metadata: labels: name: postgresql spec: containers: - name: postgresql image: sameersbn/postgresql:10 imagePullPolicy: IfNotPresent env: - name: DB_USER value: gitlab - name: DB_PASS value: gitlab - name: DB_NAME value: gitlab_production - name: DB_EXTENSION value: pg_trgm ports: - name: postgres containerPort: 5432 volumeMounts: - mountPath: /var/lib/postgresql name: data livenessProbe: exec: command: - pg_isready - -h - localhost - -U - postgres initialDelaySeconds: 30 timeoutSeconds: 5 readinessProbe: exec: command: - pg_isready - -h - localhost - -U - postgres initialDelaySeconds: 5 timeoutSeconds: 1 volumes: - name: data persistentVolumeClaim: claimName: postsql --- apiVersion: v1 kind: Service metadata: name: postgresql namespace: gitlab labels: name: postgresql spec: ports: - name: postgres port: 5432 targetPort: postgres selector: name: postgresql ``` 然后执行如下命令创建Pod ```bash kubectl apply -f postgresql.yaml ``` (6)编写redis的yaml配置文件 ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: redis namespace: gitlab labels: name: redis spec: selector: matchLabels: name: redis template: metadata: name: redis labels: name: redis spec: containers: - name: redis image: sameersbn/redis imagePullPolicy: IfNotPresent ports: - name: redis containerPort: 6379 volumeMounts: - mountPath: /var/lib/redis name: data livenessProbe: exec: command: - redis-cli - ping initialDelaySeconds: 30 timeoutSeconds: 5 readinessProbe: exec: command: - redis-cli - ping initialDelaySeconds: 5 timeoutSeconds: 1 volumes: - name: data persistentVolumeClaim: claimName: redis-data --- apiVersion: v1 kind: Service metadata: name: redis namespace: gitlab labels: name: redis spec: ports: - name: redis port: 6379 targetPort: redis selector: name: redis ``` 然后执行如下命令即可创建 ```bash kubectl apply -f redis.yaml ``` (7)编写创建gitlab的yaml配置文件 ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: gitlab namespace: gitlab labels: name: gitlab spec: selector: matchLabels: name: gitlab template: metadata: name: gitlab labels: name: gitlab spec: containers: - name: gitlab image: sameersbn/gitlab:11.8.1 imagePullPolicy: IfNotPresent env: - name: TZ value: Asia/Shanghai - name: GITLAB_TIMEZONE value: Beijing - name: GITLAB_SECRETS_DB_KEY_BASE value: long-and-random-alpha-numeric-string - name: GITLAB_SECRETS_SECRET_KEY_BASE value: long-and-RANDOM-ALPHA-NUMERIc-string - name: GITLAB_SECRETS_OTP_KEY_BASE value: long-and-random-alpha-numeric-string - name: GITLAB_ROOT_PASSWORD value: admin321 - name: GITLAB_ROOT_EMAIL value: hitredrose@163.com ##这里填自己的邮箱 - name: GITLAB_HOST value: 192.168.16.40 ##这里填gitlab的host地址,可以是主节点的ip - name: GITLAB_PORT value: "32765" # 与下面Service中配置的nodePort一致 - name: GITLAB_SSH_PORT # 与下面Service中配置的nodePort一致 value: "32766" - name: GITLAB_NOTIFY_ON_BROKEN_BUILDS value: "true" - name: GITLAB_NOTIFY_PUSHER value: "false" - name: GITLAB_BACKUP_SCHEDULE value: daily - name: GITLAB_BACKUP_TIME value: 01:00 - name: DB_TYPE value: postgres - name: DB_HOST value: postgresql - name: DB_PORT value: "5432" - name: DB_USER value: gitlab - name: DB_PASS value: gitlab - name: DB_NAME value: gitlab_production - name: REDIS_HOST value: redis - name: REDIS_PORT value: "6379" ports: - name: http containerPort: 80 - name: ssh containerPort: 22 volumeMounts: - mountPath: /home/git/data name: data livenessProbe: httpGet: path: / port: 80 initialDelaySeconds: 360 #这个值可以设置大一点,gitlab在启动时比较慢会处于一段时间的502,如果探测时间超过会进行重启,这样gitlab会一直处于重启状态 timeoutSeconds: 50 readinessProbe: httpGet: path: / port: 80 initialDelaySeconds: 360 timeoutSeconds: 50 volumes: - name: data persistentVolumeClaim: claimName: gitlab-data --- apiVersion: v1 kind: Service metadata: name: gitlab namespace: gitlab labels: name: gitlab spec: ports: - name: http port: 80 targetPort: http nodePort: 32765 - name: ssh port: 22 nodePort: 32766 targetPort: ssh selector: name: gitlab type: NodePort ``` 然后执行如下命令创建gitlab ```bash kubectl apply -f gitlab.yaml ``` (8)此时执行如下命令查看gitlab命名空间中的pod的状态,如下都为running,表示正常 ```bash [root@master gitlab]# kubectl get pod -n gitlab NAME READY STATUS RESTARTS AGE gitlab-855b5b7b7b-8hr97 1/1 Running 0 23m postgresql-b75d769dd-dn2pt 1/1 Running 0 17h redis-6c976f56dc-z7fsb 1/1 Running 0 55m [root@master gitlab]# ``` (9)然后通过Kubernetesmaster节点的ip地址和设置的端口比如这里32765,就可以访问gitlab了 ![](https://redrose2100.oss-cn-hangzhou.aliyuncs.com/img/fcb08294-f45c-11ed-b5f7-0242ac110004.png) (10)然后使用gitlab中设置的管理员密码,比如这里admin321,用户名root,就可以登录了,如下所示,为一个全新的gitlab ![](https://redrose2100.oss-cn-hangzhou.aliyuncs.com/img/820aafaa-f45d-11ed-b5f7-0242ac110004.png)
始终坚持开源开放共享精神,同时感谢您的充电鼓励和支持!
版权所有,转载本站文章请注明出处:redrose2100, http://blog.redrose2100.com/article/621
上一篇:
Gitlab----Gitlab-runner报ERROR: Job failed: execution took longer than 1h0m0s seconds错误的解决办法
下一篇:
画册-画册设计/尺寸
搜索
个人成就
出版书籍
《Pytest企业级应用实战》
测试开发技术全栈公众号
测试开发技术全栈公众号
DevOps技术交流微信群
加微信邀请进群
常用网站链接
开源软件洞察
云原生技术栈全景图
Python语言官方文档
Golang官方文档
Docker官方文档
Jenkins中文用户手册
Scrapy官方文档
VUE官方文档
Harbor官方文档
openQA官方文档
云原生开源社区
开源中国
Kubernetes中文文档
Markdown语法官方教程
Kubernetes中文社区
Kubersphere官方文档
BootStrap中文网站
JavaScript中文网
NumPy官方文档
Pandas官方文档
GitLink确实开源网站
数据库排名网站
编程语言排名网站
SEO综合查询网站
数学加减法练习自动生成网站
Kickstart Generator
文章分类
最新文章
最多阅读
特别推荐
×
Close
登录
注册
找回密码
登录邮箱:
登录密码:
图片验证码:
注册邮箱:
注册密码:
邮箱验证码:
发送邮件
注册邮箱:
新的密码:
邮箱验证码:
发送邮件