首页 > 其他分享 >kubernetes部署gitlab

kubernetes部署gitlab

时间:2023-12-30 22:15:12浏览次数:41  
标签:43m postgresql kubernetes 部署 gitlab redis nfs GitLab

1. 部署

镜像地址:Explore Docker's Container Image Repository | Docker Hub

github地址:sameersbn/docker-gitlab: Dockerized GitLab (github.com)

PostgreSQL:Omnibus GitLab 附带的 PostgreSQL 版本 | 极狐GitLab

环境变量介绍:sameersbn/docker-gitlab: Dockerized GitLab (github.com)

### gitlab
cat > gitlab-deploy.yaml <<EOF
# Service
kind: Service
apiVersion: v1
metadata:
  name: gitlab
  labels:
    name: gitlab
spec:
  ports:
    - name: http
      protocol: TCP
      port: 80
    - name: ssh
      protocol: TCP
      port: 22
      targetPort: ssh
  selector:
    name: gitlab
---
# PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-pv-claim
  labels:
    app: gitlab
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi
---
# Deployment
kind: Deployment
apiVersion: apps/v1
metadata:
  name: gitlab
  labels:
    name: gitlab
spec:
  replicas: 1
  selector:
    matchLabels:
      name: gitlab
  template:
    metadata:
      name: gitlab
      labels:
        name: gitlab
    spec:
      containers:
      - name: gitlab
        image: 'sameersbn/gitlab:15.11.13'
        ports:
        - name: ssh
          containerPort: 22
        - name: http
          containerPort: 80
        - name: https
          containerPort: 443
        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: admin@1234
        - name: GITLAB_ROOT_EMAIL 
          value: z0ukun@163.com     
        - name: GITLAB_HOST           
          value: 'gitlab.z0ukun.com'
        - name: GITLAB_PORT        
          value: '80'                   
        - name: GITLAB_SSH_PORT   
          value: '22'
        - name: GITLAB_NOTIFY_ON_BROKEN_BUILDS
          value: 'true'
        - name: GITLAB_NOTIFY_PUSHER
          value: 'false'
        - name: DB_TYPE             
          value: postgres
        - name: DB_HOST         
          value: gitlab-postgresql           
        - name: DB_PORT          
          value: '5432'
        - name: DB_USER        
          value: gitlab
        - name: DB_PASS         
          value: admin@1234
        - name: DB_NAME          
          value: gitlab_production
        - name: REDIS_HOST
          value: gitlab-redis
        - name: REDIS_PORT      
          value: '6379'
        livenessProbe:
          httpGet:
            path: /
            port: 80
            scheme: HTTP
          initialDelaySeconds: 300
          timeoutSeconds: 5
          periodSeconds: 10
          successThreshold: 1
          failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /
            port: 80
            scheme: HTTP
          initialDelaySeconds: 5
          timeoutSeconds: 30
          periodSeconds: 10
          successThreshold: 1
          failureThreshold: 3
        volumeMounts:
        - name: gitlab-persistent-storage
          mountPath: /home/git/data
        - name: localtime
          mountPath: /etc/localtime
      volumes:
      - name: gitlab-persistent-storage
        persistentVolumeClaim:
          claimName: gitlab-pv-claim
      - name: localtime
        hostPath:
          path: /etc/localtime
EOF

### redis
cat > redis-deploy.yaml <<EOF
# Service
kind: Service
apiVersion: v1
metadata:
  name: gitlab-redis
  labels:
    name: gitlab-redis
spec:
  type: ClusterIP
  ports:
    - name: redis
      protocol: TCP
      port: 6379
      targetPort: redis
  selector:
    name: gitlab-redis
# PVC
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-redis-pv-claim
  labels:
    app: gitlab
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
---
# Deployment
kind: Deployment
apiVersion: apps/v1
metadata:
  name: gitlab-redis
  labels:
    name: gitlab-redis
spec:
  replicas: 1
  selector:
    matchLabels:
      name: gitlab-redis
  template:
    metadata:
      name: gitlab-redis
      labels:
        name: gitlab-redis
    spec:
      containers:
      - name: gitlab-redis
        image: 'redis:6.2'
        ports:
        - name: redis
          containerPort: 6379
          protocol: TCP
        volumeMounts:
          - name: gitlab-redis-persistent-storage
            mountPath: /var/lib/redis
        livenessProbe:
          exec:
            command:
              - redis-cli
              - ping
          initialDelaySeconds: 5
          timeoutSeconds: 5
          periodSeconds: 10
          successThreshold: 1
          failureThreshold: 3
        readinessProbe:
          exec:
            command:
              - redis-cli
              - ping
          initialDelaySeconds: 5
          timeoutSeconds: 5
          periodSeconds: 10
          successThreshold: 1
          failureThreshold: 3
      # 持久化存储配置
      volumes:
      - name: gitlab-redis-persistent-storage
        persistentVolumeClaim:
          claimName: gitlab-redis-pv-claim
EOF
### postgresql
cat > postgresql-deploy.yaml <<EOF
# Service
kind: Service
apiVersion: v1
metadata:
  name: gitlab-postgresql
  labels:
    name: gitlab-postgresql
spec:
  ports:
    - name: postgres
      protocol: TCP
      port: 5432
      targetPort: postgres
  selector:
    name: postgresql
  type: ClusterIP
---
# PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-postgresql-pv-claim
  labels:
    app: gitlab-postgresql
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi
---
# Deployment
kind: Deployment
apiVersion: apps/v1
metadata:
  name: gitlab-postgresql
  labels:
    name: gitlab-postgresql
spec:
  replicas: 1
  selector:
    matchLabels:
      name: postgresql
  template:
    metadata:
      name: postgresql
      labels:
        name: postgresql
    spec:
      containers:
      - name: gitlab-postgresql
        image: sameersbn/postgresql:12-20200524
        ports:
        - name: postgres
          containerPort: 5432
        env:
        - name: DB_USER
          value: gitlab
        - name: DB_PASS
          value: admin@1234
        - name: DB_NAME
          value: gitlab_production
        - name: DB_EXTENSION
          value: 'pg_trgm,btree_gist'
        livenessProbe:
          exec:
            command: ["pg_isready","-h","localhost","-U","postgres"]
          initialDelaySeconds: 30
          timeoutSeconds: 5
          periodSeconds: 10
          successThreshold: 1
          failureThreshold: 3
        readinessProbe:
          exec:
            command: ["pg_isready","-h","localhost","-U","postgres"]
          initialDelaySeconds: 5
          timeoutSeconds: 1
          periodSeconds: 10
          successThreshold: 1
          failureThreshold: 3
        volumeMounts:
        - name: gitlab-postgresql-persistent-storage
          mountPath: /var/lib/postgresql
      # 持久化存储配置
      volumes:
      - name: gitlab-postgresql-persistent-storage
        persistentVolumeClaim:
          claimName: gitlab-postgresql-pv-claim
EOF

注:这里使用默认的storageclass,自己之前部署的,本地使用nfs服务共享目录。

kubectl get storageclasses.storage.k8s.io
NAME                    PROVISIONER                                   RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
nfs-storage (default)   k8s-sigs.io/nfs-subdir-external-provisioner   Delete          Immediate           false                  21d

启动:

kubectl apply -f .
# 查看启动的资源
kubectl get pod,svc,pvc,deployments.apps | grep gitlab
pod/gitlab-56ff55dff8-66p8v                   1/1     Running   2 (31m ago)     43m
pod/gitlab-postgresql-85dd6d8c88-92ffr        1/1     Running   0               43m
pod/gitlab-redis-75574b7cd9-sq2r4             1/1     Running   0               43m
service/gitlab              ClusterIP   10.111.72.205   <none>        80/TCP,22/TCP   43m
service/gitlab-postgresql   ClusterIP   10.109.38.11    <none>        5432/TCP        43m
service/gitlab-redis        ClusterIP   10.104.28.18    <none>        6379/TCP        43m
persistentvolumeclaim/gitlab-postgresql-pv-claim   Bound    pvc-a2f7b41c-bae5-4ad1-b1a0-639c761b13c7   50Gi       RWO            nfs-storage    43m
persistentvolumeclaim/gitlab-pv-claim              Bound    pvc-ff3ecf68-d427-4151-8893-648ad9e7b79f   50Gi       RWO            nfs-storage    43m
persistentvolumeclaim/gitlab-redis-pv-claim        Bound    pvc-c423261c-73ce-4a4d-a0e0-13389df83f8f   5Gi        RWO            nfs-storage    43m
deployment.apps/gitlab                   1/1     1            1           43m
deployment.apps/gitlab-postgresql        1/1     1            1           43m
deployment.apps/gitlab-redis             1/1     1            1           43m

注:这里gitlab启动需要的启动标准,,一定要查看gitlab日志的启动情况判断是否正常启动。

参考:kubernetes快速部署GitLab – 邹坤个人博客 (z0ukun.com)

标签:43m,postgresql,kubernetes,部署,gitlab,redis,nfs,GitLab
From: https://www.cnblogs.com/-k8s/p/17037795.html

相关文章

  • docker部署mysql服务
    ##########创建单机数据库服务myql下载镜像:dockerpullmysql:5.7 启动mysql 容器名称,数据目录,日志目录,配置文件目录,密码,镜像版本dockerrun-d-p3306:3306--namemysql-server-v/opt/mysql/data:/var/lib/mysql\ -v/opt/mysql/log:/var/log/mysql\ -v/opt/m......
  • 部署springboot前后端分离框架
    springboot前后端分离的文件长这样 1.是后端代码2.是前端代码3.是数据库省去了语句参照了一下几个博主的文章部署成功:超详细部署后端:https://blog.csdn.net/weixin_45393094/article/details/123674367运行时遇到报错信息:https://blog.csdn.net/qq_44802992/article/detai......
  • docker部署tomcat服务
    下载镜像dockerpulltomcat:9.0 什么是dockerrun—rm在进行Docker的开发、测试或者部署应用时,使用dockerrun--rm这一命令可以方便快捷地启动或运行容器,并在容器退出时自动清理容器及其运行时产生的数据  ##运行tomcat9.0dockerrun-d--rmtomcat:9.0 ##查看容器......
  • Rem部署适配
    参考vant官网:https://vant-contrib.gitee.io/vant/v3/#/zh-CN/advanced-usage两个插件:1.postcss-pxtorem是一款PostCSS插件,用于将px单位转化为rem单位2.lib-flexible用于设置rem基准值3.示例配置//postcss.config.jsmodule.exports={plugins:{'p......
  • 华为云耀云服务器L实例-大数据学习-Hive的部署-1
     华为云耀云服务器L实例-大数据学习-Hive的部署-1  产品官网:https://www.huaweicloud.com/product/hecs-light.html  今天我们采用可靠更安全、智能不卡顿、价优随心用、上手更简单、管理特省心的华为云耀云服务器L实例为例,介绍Hive的部署 Hive 是建立在 Hado......
  • 华为云耀云服务器L实例--Hive的部署
     华为云耀云服务器L实例--Hive的部署  产品官网:https://www.huaweicloud.com/product/hecs-light.html  今天我们采用可靠更安全、智能不卡顿、价优随心用、上手更简单、管理特省心的华为云耀云服务器L实例为例,继续Hive的部署 Hive 是建立在 Hadoop 上的一个......
  • 华为云耀云服务器L实例-大数据学习-MapReduce&Yarn的部署
      华为云耀云服务器L实例-大数据学习-MapReduce&Yarn的部署 产品官网:https://www.huaweicloud.com/product/hecs-light.html  今天我们采用可靠更安全、智能不卡顿、价优随心用、上手更简单、管理特省心的华为云耀云服务器L实例为例,介绍MapReduce 和 YARN(Yet Ano......
  • 华为云耀云服务器L实例-大数据学习-hadoop前置准备2-JDK环境部署
     华为云耀云服务器L实例-大数据学习-hadoop前置准备2-JDK环境部署  产品官网:https://www.huaweicloud.com/product/hecs-light.html  今天我们采用可靠更安全、智能不卡顿、价优随心用、上手更简单、管理特省心的华为云耀云服务器L实例为例,演示单台服务器配置伪分......
  • 使用Jenkins和单个模板部署多个Kubernetes组件
    前言在持续集成和部署中,我们通常需要部署多个实例或组件到Kubernetes集群中。通过Jenkins的管道脚本,我们可以自动化这个过程。在本文中,我将演示如何使用JenkinsPipeline及单个YAML模板文件(.tpl)来部署多个类似的Kubernetes组件,而不需要为每个组件提供单独的模板文件。问题背景参......
  • 技术文档 | 在Jenkins及GitlabCI中集成OpenSCA,轻松实现CI/CD开源风险治理
    插播:OpenSCA-cli现支持通过homebrew以及winget安装:Mac/Linuxbrewinstallopensca-cliWindowswingetinstallopensca-cli总有小伙伴问起如何在CI/CD中集成OpenSCA,文档它这不就来啦~若您解锁了其他OpenSCA的用法,也欢迎向项目组来稿,将经验分享给社区的小伙伴们~Jenkins在Jenk......