• K8s上安装gitlab-ce


    K8s上安装gitlab-ce

    前言
      使用pv-pvc来持久化gitlab的数据,配置,日志文件。
      pod启动后需要需要修改external_url然后重启pod。

    操作如下

    mkdir -p /mnt/data01/gitlab
    ctr -n k8s.io i pull docker.io/gitlab/gitlab-ce:latest
    kubectl label node [node_name] app=devops
    kubectl apply -f gitlab-deployment.yml
    
    • 1
    • 2
    • 3
    • 4

    如果镜像拉取不下来,可以

    wget -c http://117.72.10.233/file/gitlab-ce.tgz
    ctr -n k8s.io i import gitlab-ce.tgz
    
    • 1
    • 2

    Pod起来之后,修改 /mnt/data01/gitlab/conf/gitlab.rb 文件,修改配置然后重启Pod

    cat >> /mnt/data01/gitlab/conf/gitlab.rb << 'eof'
    external_url 'http://123.60.108.111:30080'  ## ip需要修改为访问地址
    gitlab_rails['gitlab_ssh_host'] = '123.60.108.111'  ## ip需要修改为访问地址
    gitlab_rails['gitlab_shell_ssh_port'] = 30022
    gitlab_rails['time_zone'] = 'Asia/Shanghai'
    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp.qq.com"
    gitlab_rails['smtp_port'] = 465
    gitlab_rails['smtp_user_name'] = "1391578633@qq.com"
    gitlab_rails['smtp_password'] = "yasfadsfafddfdj"  ## 密码为qq的smtp授权码
    gitlab_rails['smtp_domain'] = "smtp.qq.com"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_tls'] = true
    gitlab_rails['gitlab_email_enabled'] = true
    gitlab_rails['gitlab_email_from'] = '1391578633@qq.com'
    gitlab_rails['gitlab_email_display_name'] = 'gitlab'
    gitlab_rails['gitlab_email_reply_to'] = '1391578633@qq.com'
    gitlab_rails['gitlab_email_subject_suffix'] = '[gitlab]'
    eof
    kubectl get pods -n devops
    kubectl delete pod [上面的gitlab的podname] -n devops
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    在这里插入图片描述
    在这里插入图片描述
    最后浏览器访问ip:30080即可访问gitlab,账号是root,密码是初始密码执行grep 'Password' /mnt/data01/gitlab/conf/initial_root_password

    在这里插入图片描述

    gitlab-deployment.yml

    apiVersion: v1
    kind: Namespace
    metadata:
      name: devops
    ---
    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: gitlab-pv
    spec:
      accessModes:
      - ReadWriteOnce
      capacity:
        storage: 50Gi
      storageClassName: gitlab-ce
      hostPath:
        path: /mnt/data01/gitlab
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: gitlab-pvc
      namespace: devops
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 2Gi
        limits:
          storage: 50Gi
      storageClassName: gitlab-ce
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: gitlab-deployment
      namespace: devops
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: gitlab-ce
      template:
        metadata:
          labels:
            app: gitlab-ce
        spec:
          nodeSelector:
            app: devops
          containers:
          - name: gitlab-ce
            image: docker.io/gitlab/gitlab-ce:latest
            imagePullPolicy: IfNotPresent
            volumeMounts:
            - name: gen-dir
              mountPath: /var/opt/gitlab
              subPath: data
            - name: gen-dir
              mountPath: /etc/gitlab
              subPath: conf
            - name: gen-dir
              mountPath: /var/log/gitlab
              subPath: logs
            - name: localtime
              mountPath: /etc/localtime
          volumes:
          - name: gen-dir
            persistentVolumeClaim:
              claimName: gitlab-pvc
          - name: localtime
            hostPath:
              path: /etc/localtime
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: gitlab-svc
      namespace: devops
    spec:
      ports:
      - name: http
        port: 30080
        targetPort: 30080
        nodePort: 30080
      - name: https
        port: 443
        targetPort: 443
        nodePort: 30443
      - name: ssh
        port: 22
        targetPort: 22
        nodePort: 30022
      type: NodePort
      selector:
        app: gitlab-ce
    
    • 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
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
  • 相关阅读:
    【Mysql系列】mysql中删除数据的几种方法
    2023.11-9 hive数据仓库,概念,架构
    PyTorch - Dataset 迭代数据接口 __getitem__ 异常处理
    java计算机毕业设计基于web的面向公众的食品安全知识系统源程序+mysql+系统+lw文档+远程调试
    Linux进程终止
    wps、office插入的复选框无法设置字体及大小?教你一招
    Oracle作业调度器Job Scheduler
    Spring
    Mac中隐私安全性设置-打开任何来源
    如何与Linamar Corp 建立EDI连接?
  • 原文地址:https://blog.csdn.net/qq_46480020/article/details/132867882