章工运维 章工运维
首页
  • linux
  • windows
  • 中间件
  • 监控
  • 网络
  • 存储
  • 安全
  • 防火墙
  • 数据库
  • 系统
  • docker
  • 运维工具
  • other
  • elk
  • K8S
  • ansible
  • Jenkins
  • GitLabCI_CD
  • 随笔
  • 面试
  • 工具
  • 收藏夹
  • Shell
  • python
  • golang
友链
  • 索引

    • 分类
    • 标签
    • 归档
    • 首页 (opens new window)
    • 关于我 (opens new window)
    • 图床 (opens new window)
    • 评论 (opens new window)
    • 导航栏 (opens new window)
周刊
GitHub (opens new window)

章工运维

业精于勤,荒于嬉
首页
  • linux
  • windows
  • 中间件
  • 监控
  • 网络
  • 存储
  • 安全
  • 防火墙
  • 数据库
  • 系统
  • docker
  • 运维工具
  • other
  • elk
  • K8S
  • ansible
  • Jenkins
  • GitLabCI_CD
  • 随笔
  • 面试
  • 工具
  • 收藏夹
  • Shell
  • python
  • golang
友链
  • 索引

    • 分类
    • 标签
    • 归档
    • 首页 (opens new window)
    • 关于我 (opens new window)
    • 图床 (opens new window)
    • 评论 (opens new window)
    • 导航栏 (opens new window)
周刊
GitHub (opens new window)
  • ansible系列文章

  • Kubernetes笔记

  • elk

  • jenkins

  • GitLabCI_CD

    • Gitlab ci与Jenkins对比
    • GitLabRunner简介
    • GitLabRunner安装
    • GitLabRunner注册
    • Runner-命令
    • 运行流水线任务
    • 集成构建工具
    • 制品库集成
    • 按时间统计GitLab所有用户代码提交量
    • gitlab ci部署web程序示例
    • gitlab部署

      • docker部署gitlab
      • rpm包部署gitlab
      • k8s yaml部署gitlab
        • pvc
        • deployment
        • svc
        • ingress
        • 查看资源信息
        • 访问验证
  • 专题
  • GitLabCI_CD
  • gitlab部署
章工运维
2024-03-14
目录

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

# 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

# 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

# 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

# 访问验证

# 查看资源信息

[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

# 访问验证

客户端新增hots记录192.168.10.10 gitlab.local.com


原文链接 (opens new window)

微信 支付宝
上次更新: 2025/02/07, 17:21:54

← rpm包部署gitlab

最近更新
01
shell脚本模块集合
05-13
02
生活小技巧(认知版)
04-29
03
生活小技巧(防骗版)
04-29
更多文章>
Theme by Vdoing | Copyright © 2019-2025 | 点击查看十年之约 | 鄂ICP备2024072800号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式