k8s yaml部署gitlab
# 创建资源
# pvc
[root@tiaoban cicd]# cat > gitlab-pvc.yaml << EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitlab-data-pvc
namespace: cicd
spec:
storageClassName: nfs-client
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitlab-config-pvc
namespace: cicd
spec:
storageClassName: nfs-client
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
EOF
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# deployment
[root@tiaoban cicd]# cat gitlab-deployment.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: gitlab
namespace: cicd
spec:
selector:
matchLabels:
app: gitlab
replicas: 1
template:
metadata:
labels:
app: gitlab
spec:
containers:
- name: gitlab
image: gitlab/gitlab-ce:16.0.4-ce.0
env:
- name: GITLAB_SKIP_UNMIGRATED_DATA_CHECK
value: "true"
- name: GITLAB_OMNIBUS_CONFIG
value: |
external_url = 'http://gitlab.local.com/'
prometheus['enable'] = false
alertmanager['enable'] = false
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['gitlab_email_enabled'] = false
gitlab_rails['smtp_enable'] = false
gitlab_rails['gravatar_plain_url'] = 'http://sdn.geekzu.org/avatar/%{hash}?s=%{size}&d=identicon'
gitlab_rails['gravatar_ssl_url'] = 'https://sdn.geekzu.org/avatar/%{hash}?s=%{size}&d=identicon'
nginx['worker_processes'] = 2
postgresql['max_connections'] = 100
postgresql['shared_buffers'] = "128MB"
ports:
- containerPort: 80
name: http
- containerPort: 443
name: https
- containerPort: 22
name: ssh
readinessProbe:
exec:
command: ["sh", "-c", "curl -s http://127.0.0.1/-/health"]
livenessProbe:
exec:
command: ["sh", "-c", "curl -s http://127.0.0.1/-/health"]
timeoutSeconds: 5
failureThreshold: 3
periodSeconds: 60
startupProbe:
exec:
command: ["sh", "-c", "curl -s http://127.0.0.1/-/health"]
failureThreshold: 20
periodSeconds: 120
resources:
requests:
memory: "4Gi"
cpu: "2"
limits:
memory: "8Gi"
cpu: "4"
volumeMounts:
- name: data
mountPath: /var/opt/gitlab
- name: config
mountPath: /etc/gitlab
- name: log
mountPath: /var/log/gitlab
- mountPath: /dev/shm
name: cache-volume
volumes:
- name: data
persistentVolumeClaim:
claimName: gitlab-data-pvc
- name: config
persistentVolumeClaim:
claimName: gitlab-config-pvc
- name: log
emptyDir: {}
- name: cache-volume
emptyDir:
medium: Memory
sizeLimit: 256Mi
EOF
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# svc
[root@tiaoban cicd]# cat > gitlab-svc.yaml << EOF
apiVersion: v1
kind: Service
metadata:
name: gitlab-svc
namespace: cicd
spec:
selector:
app: gitlab
ports:
- port: 80
targetPort: 80
name: http
- port: 443
targetPort: 443
name: https
- port: 22
targetPort: 22
name: ssh
EOF
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# ingress
[root@tiaoban cicd]# cat > gitlab-ingress.yaml << EOF
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: gitlab
namespace: cicd
spec:
entryPoints:
- web
routes:
- match: Host(`gitlab.local.com`)
kind: Rule
services:
- name: gitlab-svc
port: 80
EOF
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 访问验证
# 查看资源信息
[root@tiaoban cicd]# kubectl get all -n cicd
NAME READY STATUS RESTARTS AGE
pod/gitlab-68b7b46dc7-m687z 1/1 Running 0 11m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/gitlab-svc ClusterIP 10.108.64.185 <none> 80/TCP,443/TCP,22/TCP 11m
1
2
3
4
5
6
2
3
4
5
6
# 访问验证
客户端新增hots记录192.168.10.10 gitlab.local.com
上次更新: 2024/04/25, 14:45:25