Gitlab-5.配置外部PostgreSQL

本文档介绍了如何配置Gitlab使用外部的PostgreSQL数据库,包括创建数据库账号、修改Gitlab配置文件,以及详细步骤来禁用本地PostgreSQL并设置数据库连接信息。
  • 配置Gitlab使用外部数据库官方文档:https://docs.gitlab.com/omnibus/settings/database.html
  • 配置外部数据库官方文档:https://docs.gitlab.com/ce/install/requirements.html#database
创建数据库账号信息
  • 创建用户gitlab
    create user gitlab with password '12345678';
    
  • 创建数据库gitlabhq_production
    create database gitlabhq_production OWNER gitlab;
    
  • 将gitlabhq_production库的所有权赋值给gitlab
    GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production TO gitlab;
    
修改Gitlab配置信息
  • 打开配置文件

    vim /etc/gitlab/gitlab.rb
    
  • 禁用本地PostgreSQL

    postgresql['enable'] = false
    

    在这里插入图片描述

  • 设置PostgreSQL数据库连接信息

    gitlab_rails['db_database'] = "gitlabhq_production"
    gitlab_rails['d
kubernetes GitLab + Ingressroot@k8s-m001:~/devops/test-devops/gitlab# ll total 44 drwxr-xr-x 3 root root 4096 Jun 15 18:25 ./ drwxr-xr-x 7 root root 4096 Jun 15 18:21 ../ -rw-r--r-- 1 root root 1337 Jun 15 18:21 gitlab-deployment.yaml -rw-r--r-- 1 root root 520 Jun 15 18:22 gitlab-ingress.yaml -rw-r--r-- 1 root root 723 Jun 15 17:51 gitlab-nfs-pvc-pro.yaml -rw-r--r-- 1 root root 58 Jun 14 21:55 gitlab-ns.yaml -rw-r--r-- 1 root root 293 Jun 15 18:25 gitlab-services.yaml drwxrwxrwx 2 root root 4096 Jun 15 16:31 gitlab.wh02.com_nginx/ -rw-r--r-- 1 root root 9078 Jun 15 16:28 gitlab.wh02.com_nginx.zip root@k8s-m001:~/devops/test-devops/gitlab# cat gitlab-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: gitlab namespace: gitlab spec: selector: matchLabels: app: gitlab replicas: 1 template: metadata: labels: app: gitlab spec: securityContext: fsGroup: 1000 containers: - name: gitlab image: harbor.wh02.com/cicd/gitlab/gitlab-ce:17.11.0-ce.0 imagePullPolicy: Always ports: - containerPort: 80 - containerPort: 22 env: - name: GITLAB_OMNIBUS_CONFIG value: | external_url 'https://gitlab.wh02.com' gitlab_rails['initial_root_password'] = "Aa123123" gitlab_rails['gitlab_default_locale'] = 'zh_CN' gitlab_rails['gitlab_default_locale_in_system'] = true volumeMounts: - name: gitlab-storage mountPath: /var/opt/gitlab subPath: data - name: gitlab-storage mountPath: /var/log/gitlab subPath: logs - name: gitlab-storage mountPath: /etc/gitlab subPath: config resources: requests: cpu: "2" memory: "5Gi" limits: cpu: "2" memory: "6Gi" volumes: - name: gitlab-storage persistentVolumeClaim: claimName: gitlab-pvc root@k8s-m001:~/devops/test-devops/gitlab# cat gitlab-ingress.yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: gitlab-ingress namespace: gitlab annotations: nginx.ingress.kubernetes.io/ssl-redirect: "true" spec: ingressClassName: nginx tls: - hosts: - gitlab.wh02.com secretName: gitlab-tls rules: - host: gitlab.wh02.com http: paths: - path: / pathType: Prefix backend: service: name: gitlab-service port: number: 80 root@k8s-m001:~/devops/test-devops/gitlab# cat gitlab-nfs-pvc-pro.yaml apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: nfs-gitlab-static provisioner: kubernetes.io/no-provisioner volumeBindingMode: WaitForFirstConsumer reclaimPolicy: Retain --- apiVersion: v1 kind: PersistentVolume metadata: name: gitlab-pv spec: capacity: storage: 50Gi accessModes: - ReadWriteMany nfs: server: 192.168.3.101 path: /data/k8sdata/gitlab_data storageClassName: nfs-gitlab-static persistentVolumeReclaimPolicy: Retain --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: gitlab-pvc namespace: gitlab spec: accessModes: - ReadWriteMany resources: requests: storage: 50Gi storageClassName: nfs-gitlab-static volumeName: gitlab-pv root@k8s-m001:~/devops/test-devops/gitlab# cat gitlab-ns.yaml apiVersion: v1 kind: Namespace metadata: name: gitlab root@k8s-m001:~/devops/test-devops/gitlab# cat gitlab-services.yaml apiVersion: v1 kind: Service metadata: name: gitlab-service namespace: gitlab spec: selector: app: gitlab type: NodePort ports: - name: http port: 80 targetPort: 80 # nodePort: 30030 - name: ssh port: 22 targetPort: 22 # nodePort: 30022 root@k8s-m001:~/devops/test-devops/gitlab# kubectl get secrets -n gitlab No resources found in gitlab namespace. root@k8s-m001:~/devops/test-devops/gitlab# kubectl get secrets -A NAMESPACE NAME TYPE DATA AGE ingress-nginx ingress-nginx-admission Opaque 3 97m jenkins harbor-pull-secret kubernetes.io/dockerconfigjson 1 7h41m kube-system calico-etcd-secrets Opaque 3 40h kubernetes-dashboard dashboard-admin-user kubernetes.io/service-account-token 3 65d kubernetes-dashboard kubernetes-dashboard-certs Opaque 0 65d kubernetes-dashboard kubernetes-dashboard-csrf Opaque 1 65d kubernetes-dashboard kubernetes-dashboard-key-holder Opaque 2 65d kuboard kuboard-admin-token kubernetes.io/service-account-token 3 40h kuboard kuboard-viewer-token kubernetes.io/service-account-token 3 40h root@k8s-m001:~/devops/test-devops/gitlab# kubectl get pv,pvc -n gitlab NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS VOLUMEATTRIBUTESCLASS REASON AGE persistentvolume/gitlab-pv 50Gi RWX Retain Bound gitlab/gitlab-pvc nfs-gitlab-static <unset> 44m persistentvolume/jenkins-pv 10Gi RWX Retain Released jenkins/jenkins-pvc <unset> 26h persistentvolume/pvc-1464be8d-5bc8-4ba1-8d91-c282167ea4cf 50Gi RWX Delete Bound jenkins/jenkins-pvc nfs-dynamic <unset> 7h41m persistentvolume/pvc-49a9790f-7ebf-43a6-8454-b90cf50d2f3d 50Gi RWX Retain Released jenkins/jenkins-pvc nfs-dynamic <unset> 7h54m persistentvolume/pvc-4ddd9d5b-a734-4889-af64-0c96f340ce11 50Gi RWX Retain Released jenkins/jenkins-pvc nfs-dynamic <unset> 8h NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE persistentvolumeclaim/gitlab-pvc Bound gitlab-pv 50Gi RWX nfs-gitlab-static <unset> 44m
06-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值