废话不多说,直接上配置文件
需要修改的地方(备注都有写):
1.命名空间 namespace
2. claimName 文件挂载
Deployment
kind: Deployment
apiVersion: apps/v1
metadata:name: gitlabnamespace: cicd # 替换为您的命名空间labels:k8s.kuboard.cn/layer: svck8s.kuboard.cn/name: gitlabannotations: {}
spec:replicas: 1selector:matchLabels:k8s.kuboard.cn/layer: svck8s.kuboard.cn/name: gitlabtemplate:metadata:creationTimestamp: nulllabels:k8s.kuboard.cn/layer: svck8s.kuboard.cn/name: gitlabannotations:kubectl.kubernetes.io/restartedAt: '2025-01-16T09:08:15+08:00'spec:volumes:- name: gitlab-datapersistentVolumeClaim:claimName: gitlab-pvc # 替换为您的 PVC 名称containers:- name: gitlabimage: 'gitlab/gitlab-ce:14.3.5-ce.0'envFrom:- configMapRef:name: gitlab-envenv:- name: TZvalue: Asia/Shanghai- name: GITLAB_OMNIBUS_CONFIGvalueFrom:configMapKeyRef:name: gitlab-envkey: gitlab-configresources: {}volumeMounts:- name: gitlab-datamountPath: /var/opt/gitlabsubPath: data/gitlab/data- name: gitlab-datamountPath: /var/log/gitlabsubPath: data/gitlab/logs- name: gitlab-datamountPath: /etc/gitlabsubPath: data/gitlab/configterminationMessagePath: /dev/termination-logterminationMessagePolicy: FileimagePullPolicy: IfNotPresentrestartPolicy: AlwaysterminationGracePeriodSeconds: 30dnsPolicy: ClusterFirstsecurityContext: {}schedulerName: default-schedulerstrategy:type: RollingUpdaterollingUpdate:maxUnavailable: 25%maxSurge: 25%revisionHistoryLimit: 10progressDeadlineSeconds: 600
注意:gitlab/gitlab-ce:14.3.5-ce.0 其中的版本,如果更换可以不可以没试过哈。
Service
kind: Service
apiVersion: v1
metadata:name: gitlabnamespace: cicd # 替换为您的命名空间labels:k8s.kuboard.cn/layer: svck8s.kuboard.cn/name: gitlab
spec:ports:- name: httpprotocol: TCPport: 80targetPort: 80nodePort: 30009 # 根据需要调整- name: httpsprotocol: TCPport: 443targetPort: 443nodePort: 30718 # 根据需要调整- name: sshprotocol: TCPport: 22targetPort: 22nodePort: 30256 # 根据需要调整selector:k8s.kuboard.cn/layer: svck8s.kuboard.cn/name: gitlabtype: NodePortsessionAffinity: NoneexternalTrafficPolicy: ClusteripFamilies:- IPv4ipFamilyPolicy: SingleStackinternalTrafficPolicy: Cluster
ConfigMap
kind: ConfigMap
apiVersion: v1
metadata:name: gitlab-envnamespace: 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:- ReadWriteManyresources:requests:storage: 100Gi # 根据需求调整存储大小storageClassName: nfs-class # 使用您的 NFS 存储类
apiVersion: v1
kind: PersistentVolume
metadata:annotations:pv.kubernetes.io/provisioned-by: nfs-nfs-classfinalizers:- kubernetes.io/pv-protectionname: gitlab-pvresourceVersion: '5781171'
spec:accessModes:- ReadWriteManycapacity:storage: 100GiclaimRef:apiVersion: v1kind: PersistentVolumeClaimname: gitlab-pvcnamespace: cicdnfs:path: /k3s/gitlabserver: 192.168.1.xpersistentVolumeReclaimPolicy: RetainstorageClassName: nfs-classvolumeMode: Filesystem
部署成功
查看密码(初始密码)
控制台输入命令
cat /etc/gitlab/initial_root_password
密码就是上面的那一串位置。
修改密码
博主新推出的gitee免费开源项目(商城+APP+小程序+H5),有兴趣的小伙伴可以了解一下。
生鲜商城kxmall-小程序 + App + 公众号H5: kxmall-生鲜商城+APP+小程序+H5。同时支持微信小程序、H5、安卓App、苹果App。支持集群部署,单机部署。可用于B2C商城,O2O外卖,社区超市,生鲜【带配套骑手端配送系统】。kxmall使用uniapp编码。使用Java开发,SpringBoot 2.1.x框架,MyBatis-plus持久层框架、Redis作为缓存、MySql作为数据库。前端vuejs作为开发语言。https://gitee.com/zhengkaixing/kxmall
- 阿里云服务器折扣场:点我进入
- 腾讯云服务器秒杀场:点我进入