K8S常见的微服务中间件部署之GitLab
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.环境准备
1.导入镜像
[root@worker233 ~]# wget http://192.168.21.253/Resources/Kubernetes/Project/DevOps/images/yinzhengjie-gitlab-ce-v17.5.2.tar.gz
[root@worker233 ~]# docker load -i yinzhengjie-gitlab-ce-v17.5.2.tar.gz
[root@worker233 ~]# docker tag gitlab/gitlab-ce:17.5.2-ce.0 harbor250.yinzhengjie.com/yinzhengjie-devops/gitlab-ce:17.5.2-ce.0
[root@worker233 ~]# docker push harbor250.yinzhengjie.com/yinzhengjie-devops/gitlab-ce:17.5.2-ce.0
2.创建nfs共享目录
[root@master231 ~]# mkdir -pv /yinzhengjie/data/nfs-server/case-demo/gitlab/{data,logs,conf}
mkdir: created directory '/yinzhengjie/data/nfs-server/case-demo/gitlab'
mkdir: created directory '/yinzhengjie/data/nfs-server/case-demo/gitlab/data'
mkdir: created directory '/yinzhengjie/data/nfs-server/case-demo/gitlab/logs'
mkdir: created directory '/yinzhengjie/data/nfs-server/case-demo/gitlab/conf'
[root@master231 ~]#
二.K8S部署GitLab
1.编写资源清单
[root@master231 02-jenkins]# cat 01-deploy-svc-gitlab.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-gitlab
spec:
replicas: 1
selector:
matchLabels:
apps: gitlab
template:
metadata:
labels:
apps: gitlab
spec:
volumes:
- name: data
nfs:
server: 10.0.0.231
path: /yinzhengjie/data/nfs-server/case-demo/gitlab/data
- name: conf
nfs:
server: 10.0.0.231
path: /yinzhengjie/data/nfs-server/case-demo/gitlab/conf
- name: logs
nfs:
server: 10.0.0.231
path: /yinzhengjie/data/nfs-server/case-demo/gitlab/logs
containers:
- name: c1
image: harbor250.yinzhengjie.com/yinzhengjie-devops/gitlab-ce:17.5.2-ce.0
ports:
- containerPort: 22
name: ssh
- containerPort: 80
name: http
- containerPort: 443
name: https
volumeMounts:
- name: logs
mountPath: /var/log/gitlab
- name: data
mountPath: /var/opt/gitlab
- name: conf
mountPath: /etc/gitlab
---
apiVersion: v1
kind: Service
metadata:
name: svc-gitlab
spec:
type: LoadBalancer
selector:
apps: gitlab
ports:
- protocol: TCP
port: 80
name: http
- protocol: TCP
port: 443
name: https
- protocol: TCP
port: 22
name: sshd
[root@master231 02-jenkins]#
[root@master231 02-jenkins]#
2.创建资源
[root@master231 02-jenkins]# kubectl apply -f 01-deploy-svc-gitlab.yaml
deployment.apps/deploy-gitlab created
service/svc-gitlab created
[root@master231 02-jenkins]#
[root@master231 02-jenkins]# kubectl get svc svc-gitlab
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc-gitlab LoadBalancer 10.200.237.106 10.0.0.153 80:41391/TCP,443:15760/TCP,22:39022/TCP 9m12s
[root@master231 02-jenkins]#
[root@master231 02-jenkins]# kubectl get pods -o wide # GitLab是否能够正常访问,需要等待7-8m左右就可以正常访问。性能如果好一点,3-5m就可以正常访问了。
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
deploy-gitlab-c84979449-f5rn9 1/1 Running 0 9m16s 10.100.2.53 worker233 <none> <none>
[root@master231 02-jenkins]#
[root@master231 02-jenkins]#
3.查看gitlab的初始密码
[root@master231 02-jenkins]# kubectl logs deploy-gitlab-c84979449-f5rn9 | grep /etc/gitlab/initial_root_password
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.
[root@master231 02-jenkins]#
[root@master231 02-jenkins]# kubectl exec deploy-gitlab-c84979449-f5rn9 -- 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: a9/WZNn+4VHTjFa3pd6h2niEodrEYQUcepGNjWc7AEc=
# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
[root@master231 02-jenkins]#
4.访问测试
http://10.0.0.153/
用上一步的密码进行登录,用户名为: root
5.修改密码

如上图所示,按照步骤依次执行即可修改密码,注意密码长度不得少于8位哟~
本文来自博客园,作者:尹正杰,转载请注明原文链接:https://www.cnblogs.com/yinzhengjie/p/18999841,个人微信: "JasonYin2020"(添加时请备注来源及意图备注,有偿付费)
当你的才华还撑不起你的野心的时候,你就应该静下心来学习。当你的能力还驾驭不了你的目标的时候,你就应该沉下心来历练。问问自己,想要怎样的人生。

浙公网安备 33010602011771号