• K8s 版本:1.20.6
  • 这里使用的镜像不是官方的,而是 Gitlab 容器化中使用非常多的一个第三方镜像:sameersbn/gitlab,基本上和官方保持同步更新。地址:http://www.damagehead.com/docker-gitlab/

1. Redis

apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
namespace: gitlab
labels:
name: redis
spec:
replicas: 1
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
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: redis
namespace: gitlab
labels:
name: redis
spec:
ports:
- name: redis
port: 6379
targetPort: redis
selector:
name: redis

2. Postgresql

apiVersion: v1
kind: PersistentVolume
metadata:
name: gitlab-postgresql-data
labels:
type: gitlab-postgresql-data
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
nfs:
path: /data/nfs/gitlab/pg_data
server: south-200 # *
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitlab-postgresql-data-pvc
namespace: gitlab
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: nfs
selector:
matchLabels:
type: gitlab-postgresql-data
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgresql
namespace: gitlab
labels:
name: postgresql
spec:
replicas: 1
selector:
matchLabels:
name: postgresql
template:
metadata:
name: postgresql
labels:
name: postgresql
spec:
containers:
- name: postgresql
image: sameersbn/postgresql:10
imagePullPolicy: IfNotPresent
env:
- name: DB_USER
value: gitlab
- name: DB_PASS
value: "..." # *
- name: DB_NAME
value: gitlab_production
- name: DB_EXTENSION
value: pg_trgm
ports:
- name: postgres
containerPort: 5432
volumeMounts:
- mountPath: /var/lib/postgresql
name: postgresql
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: postgresql
persistentVolumeClaim:
claimName: gitlab-postgresql-data-pvc
---
apiVersion: v1
kind: Service
metadata:
name: postgresql
namespace: gitlab
labels:
name: postgresql
spec:
ports:
- name: postgres
port: 5432
targetPort: postgres
selector:
name: postgresql

3. Gitlab

apiVersion: v1
kind: PersistentVolume
metadata:
name: gitlab-data
labels:
type: gitlab-data
spec:
capacity:
storage: 30Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
nfs:
path: /data/nfs/gitlab/data
server: south-200 # *
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: gitlab-data-pvc
namespace: gitlab
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: nfs
selector:
matchLabels:
type: gitlab-data
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: gitlab
namespace: gitlab
labels:
name: gitlab
spec:
replicas: 1
selector:
matchLabels:
name: gitlab
template:
metadata:
name: gitlab
labels:
name: gitlab
spec:
nodeName: 192.168.102.22 # *
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: admin123 # *
- name: GITLAB_ROOT_EMAIL
value: 164343992@qq.com # *
- name: GITLAB_HOST
value: gitlab.south.com # *
- name: GITLAB_PORT
value: "80"
- name: GITLAB_SSH_HOST
value: k8s-22.host.com # *
- name: GITLAB_SSH_PORT
value: "30022"
- 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: "..." # *
- 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: 180
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
timeoutSeconds: 1
volumes:
- name: data
persistentVolumeClaim:
claimName: gitlab-data-pvc
---
apiVersion: v1
kind: Service
metadata:
name: gitlab
namespace: gitlab
labels:
name: gitlab
spec:
ports:
- name: http
port: 80
targetPort: http
- name: ssh
port: 22
targetPort: ssh
nodePort: 30022
type: NodePort
selector:
name: gitlab
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gitlab
namespace: gitlab
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: gitlab.south.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: gitlab
port:
number: 80

创建:

$ kubectl create -f redis.yaml
$ kubectl create -f postgresql.yaml
$ kubectl create -f gitlab.yaml $ kubectl get all -n gitlab -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/gitlab-7b894fcff-mnkb4 1/1 Running 0 16m 172.20.1.27 192.168.102.22 <none> <none>
pod/postgresql-6b6b478f-s6nj7 1/1 Running 0 16m 172.20.1.10 192.168.102.22 <none> <none>
pod/redis-7db89c7d46-fqdr5 1/1 Running 0 16m 172.20.0.9 192.168.102.21 <none> <none> NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/gitlab NodePort 10.254.169.244 <none> 80:31993/TCP,22:30022/TCP 35m name=gitlab
service/postgresql ClusterIP 10.254.110.37 <none> 5432/TCP 46h name=postgresql
service/redis ClusterIP 10.254.209.159 <none> 6379/TCP 46h name=redis

参考:在 Kubernetes 上安装 Gitlab-阳明的博客

最新文章

  1. js正则表达式大全(3)
  2. 目标平台、活动平台 配置,出现未能加载文件或程序集“xxx”或它的某一个依赖项报错
  3. [转载]const_cast
  4. 开发常用到的terminal命令
  5. mysql同步
  6. eclipse插件hibernate tools安装 爱好者
  7. jemter接口测试之---接口测试的一些约定
  8. java多线程 join方法以及优先级方法
  9. (转)解析php中die(),exit(),return的区别
  10. php随机获取金山词霸每日一句
  11. 10步教你来优化WordPress速度 为服务器和访客减压
  12. Hdu5126-stars(两次CDQ分治)
  13. 瀑布流布局使用详解——JQuery插件Isotope(动态实现子项目筛选)
  14. jquery serializeArray()、serialize()增加数据
  15. Django 的认识,面试题
  16. Dvelopment descriptor
  17. scrapy爬虫--苏宁图书
  18. VC++环境下单文档SDI与OpenGL多视图分割窗口的实现-类似3DMAX的主界面
  19. HTML5开启浏览器桌面通知 Web Notification
  20. Qt封装QTcpServer参考资料--QT自带QTcpServer架构分析

热门文章

  1. mongodb主从复制(读写分离)
  2. 刷算法,这些api不可不知!
  3. Linux | Shell脚本的编写
  4. gitlab配置邮箱服务
  5. spring中如何向一个单例bean中注入非单例bean
  6. 打造一个window桌面应用:在线聊天对话机器人
  7. Python+Requests+Bs4(解析)爬取某诗词信息(数据分析二)
  8. airodump-ng的使用及显示
  9. Maven工程 报 Diamond types are not supported at language level &#39;5&#39;
  10. 随机数种子(random seed)