Kubernetes安装GitLab

半兽人 发表于: 2022-10-14   最后更新时间: 2022-10-24 15:53:49  
{{totalSubscript}} 订阅, 121 游览

Step 1: 准备yaml文件

创建 gitlab.yaml

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: gitlab
  namespace: my-space
spec:
  serviceName: gitlab
  replicas: 1
  selector:
    matchLabels:
      app: gitlab
  template:
    metadata:
      labels:
        app: gitlab
    spec:
      containers:
        - name: gitlab
          image: 'gitlab/gitlab-ce:15.2.3-ce.0'
          ports:
            - containerPort: 80
              name: web

创建外网访问 gitlab-nodeport.yaml

apiVersion: v1
kind: Service
metadata:
  name: gitlab-svc
  namespace: my-space
spec:
  type: NodePort
  selector:
    app: gitlab
  ports:
    - port: 80
      targetPort: 80

Step 2: 创建

创建以上的yaml文件

kubectl apply -f gitlab.yaml
kubectl apply -f gitlab-nodeport.yaml

或者用官方kubebiz的yaml源:

kubectl apply -f https://www.kubebiz.com/raw/KubeBiz/GitLab/latest/all

Step 3: 验证

查看pod状态

kubectl get pods -n my-space


NAME                                  READY   STATUS    RESTARTS      AGE
gitlab-0                              1/1     Running   0             3m

等待所有pod的状态为Running

查看服务:

kubectl get svc -n my-space
NAME             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                          AGE
gitlab-svc       NodePort    10.109.184.151   <none>        80:31467/TCP                     9s

通过创建的nodePort访问,通过 <nodepot-ip>:31467在游览器访问:

gitlab

Step 4: 获取账密

然后通过 kubectl exec 获取 root 初始化密码

kubectl exec gitlab-0 -n my-space -- cat /etc/gitlab/initial_root_password

返回:

# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: XEsdaYT8dpyg10FsYq5BbQuqHsS2yoGeeNuqwwIzCM4=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.

密码

XEsdaYT8dpyg10FsYq5BbQuqHsS2yoGeeNuqwwIzCM4=

完成。

更新于 2022-10-24
在线,12分钟前登录

鬓衰 1月前

这个登录用户是哪个呀

半兽人 -> 鬓衰 1月前

root,默认密码在容器中,进入容器,密码在/etc/gitlab/initial_root_password中。

查看kubernetes更多相关的文章或提一个关于kubernetes的问题,也可以与我们一起分享文章
提问