废话不多说,直接上配置文件
需要修改的地方(备注都有写):
1.命名空间 namespace
- claimName 文件挂载
Deployment
kind: Deployment
apiVersion: apps/v1
metadata:
name: gitlab
namespace: cicd # 替换为您的命名空间
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: gitlab
annotations: {}
spec:
replicas: 1
selector:
matchLabels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: gitlab
template:
metadata:
creationTimestamp: null
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: gitlab
annotations:
kubectl.kubernetes.io/restartedAt: '2025-01-16T09:08:15+08:00'
spec:
volumes:
- name: gitlab-data
persistentVolumeClaim:
claimName: gitlab-pvc # 替换为您的 PVC 名称
containers:
- name: gitlab
image: 'gitlab/gitlab-ce:14.3.5-ce.0'
envFrom:
- configMapRef:
name: gitlab-env
env:
- name: TZ
value: Asia/Shanghai
- name: GITLAB_OMNIBUS_CONFIG
valueFrom:
configMapKeyRef:
name: gitlab-env
key: gitlab-config
resources: {}
volumeMounts:
- name: gitlab-data
mountPath: /var/opt/gitlab
subPath: data/gitlab/data
- name: gitlab-data
mountPath: /var/log/gitlab
subPath: data/gitlab/logs
- name: gitlab-data
mountPath: /etc/gitlab
subPath: data/gitlab/config
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
securityContext: {}
schedulerName: default-scheduler
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
revisionHistoryLimit: 10
progressDeadlineSeconds: 600
注意:gitlab/gitlab-ce:14.3.5-ce.0 其中的版本,如果更换可以不可以没试过哈。
Service
kind: Service
apiVersion: v1
metadata:
name: gitlab
namespace: cicd # 替换为您的命名空间
labels:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: gitlab
spec:
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
nodePort: 30009 # 根据需要调整
- name: https
protocol: TCP
port: 443
targetPort: 443
nodePort: 30718 # 根据需要调整
- name: ssh
protocol: TCP
port: 22
targetPort: 22
nodePort: 30256 # 根据需要调整
selector:
k8s.kuboard.cn/layer: svc
k8s.kuboard.cn/name: gitlab
type: NodePort
sessionAffinity: None
externalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
internalTrafficPolicy: Cluster
ConfigMap
kind: ConfigMap
apiVersion: v1
metadata:
name: gitlab-env
namespace: cicd # 替换为您的命名空间
data:
gitlab-config: |-
external_url 'http://gitlab.yourdomain.com' # 替换为您的 GitLab 外部访问地址
gitlab_rails['gitlab_shell_ssh_port'] = 2222
PersistentVolumeClaim 与 PersistentVolume
稍微给一个demo(可不用哈)
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: gitlab-pvc # PVC 名称
namespace: cicd # 替换为您的命名空间
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Gi # 根据需求调整存储大小
storageClassName: nfs-class # 使用您的 NFS 存储类
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
pv.kubernetes.io/provisioned-by: nfs-nfs-class
finalizers:
- kubernetes.io/pv-protection
name: gitlab-pv
resourceVersion: '5781171'
spec:
accessModes:
- ReadWriteMany
capacity:
storage: 100Gi
claimRef:
apiVersion: v1
kind: PersistentVolumeClaim
name: gitlab-pvc
namespace: cicd
nfs:
path: /k3s/gitlab
server: 192.168.1.x
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs-class
volumeMode: Filesystem
部署成功
查看密码(初始密码)

控制台输入命令
cat /etc/gitlab/initial_root_password

密码就是上面的那一串位置。
修改密码


博主新推出 的gitee免费开源项目(商城+APP+小程序+H5),有兴趣的小伙伴可 以了解一下。