欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 焦点 > 记录一下在k3s快速创建gitlab

记录一下在k3s快速创建gitlab

2025/2/28 0:01:02 来源:https://blog.csdn.net/qq_38377190/article/details/145869145  浏览:    关键词:记录一下在k3s快速创建gitlab

废话不多说,直接上配置文件

需要修改的地方(备注都有写):

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

  • 阿里云服务器折扣场:点我进入  
  • 腾讯云服务器秒杀场:点我进入  

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词