基于k8s搭建gitlab

前言

一、安装kubernetes 集群

可以参考这篇博客,写的挺好的:搭建k8s环境

二、安装helm

在github上下载helm的二进制文件,在系统中解压,并将可执行文件移动到 /usr/bin/ 目录下

三 helm 安装gitlab

helm 添加gitlab源

helm repo add gitlab https://charts.gitlab.io/
helm repo update

导出gitlab yaml文件

helm show values gitlab/gitlab >> gitlab.yaml

新建storageclass pvc文件

**将 CUSTOM_STORAGE_CLASS_NAME 替换成自己的storageclass 名字,size设置适当的大小**
cat >storage.yaml <<EOF
gitlab:
  gitaly:
    persistence:
      storageClass: CUSTOM_STORAGE_CLASS_NAME
      namespace: gitlab
      size: 50Gi
postgresql:
  persistence:
    storageClass: CUSTOM_STORAGE_CLASS_NAME
    namespace: gitlab
    size: 8Gi
minio:
  persistence:
    storageClass: CUSTOM_STORAGE_CLASS_NAME
    namespace: gitlab
    size: 10Gi
redis:
  master:
    persistence:
      storageClass: CUSTOM_STORAGE_CLASS_NAME
      namespace: gitlab
      size: 5Gi
EOF

修改gitlab.yaml文件

# 设置访问域名
------------------------------------------
  hosts:
    domain: example.com 		# 将这里的域名地址修改自己的域名 
------------------------------------------

# 设置邮箱地址
------------------------------------------
certmanager-issuer:
#   # The email address to register certificates requested from Let's Encrypt.
#   # Required if using Let's Encrypt.
   email: [email protected]		# 设置 自己emali地址

------------------------------------------

# 关闭certmanager
------------------------------------------
certmanager:
  installCRDs: false
  nameOverride: certmanager
  # Install cert-manager chart. Set to false if you already have cert-manager
  # installed or if you are not using cert-manager.
  install: false
  # Other cert-manager configurations from upstream
  # See https://github.com/jetstack/cert-manager/blob/master/deploy/charts/cert-manager/README#configuration
  rbac:
    create: false

------------------------------------------

# 设置tls 证书名字
------------------------------------------
  ingress:
    apiVersion: ""
    configureCertmanager: false		# 原先true修改false
    provider: nginx
    # class:
    annotations: {}
    enabled: true
    tls:
       enabled: true
       secretName: gitlab.example.com 	# 设置secre 名字,一般如设置为域名
    path: /
    pathType: Prefix

------------------------------------------

创建gitlab的secret

# 创建gitlab namespace
kubectl create ns gitlab

# 去生成自己ssl证书,将证书上传自服务器,在创建上面的提到tls secret(gitlab.example.com),例如:
kubectl create secret tls gitlab.example.com --cert=fullchain.crt --key=private.pem -n gitlab

备注:
	gitlab.example.com 是上文提到的tls证书的名字

安装gitlab

helm upgrade  --install gitlab gitlab/gitlab -n gitlab -f gitlab.yaml -f storage.yaml

你可能感兴趣的:(云原生,kubernetes,gitlab,运维)