基于kubernetes部署gitlab

前提

已经搭建完kubernets集群并可提供服务。

下载镜像

去docker hub 下载具体版本镜像,当使用最新版本时,也建议具体制定版本号,而不是使用latest.
如 gitlab/gitlab-ce:15.10.0-ce.0
当然可以pull到本地,然后tag ,并push到本地harbor,以便本地化管理。

部署

kind: Deployment
apiVersion: apps/v1
metadata:
  name: gitlab
  namespace: xx-erp
  labels:
    app: gitlab
  annotations:
    deployment.kubernetes.io/revision: '5'
    kubesphere.io/creator: xxx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gitlab
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: gitlab
      annotations:
        kubesphere.io/restartedAt: '2023-03-23T07:37:27.995Z'
    spec:
      containers:
        - name: gitlab
          image: 'gitlab/gitlab-ce:15.10.0-ce.0'
          ports:
            - containerPort: 80
              protocol: TCP
            - containerPort: 22
              protocol: TCP
          resources:
            limits:
              cpu: '4'
              memory: 8Gi
              nvidia.com/gpu: '0'
            requests:
              cpu: '4'
              memory: 8Gi
              nvidia.com/gpu: '0'
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
            allowPrivilegeEscalation: true
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: default
      serviceAccount: default
      securityContext: {}
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600

此处需要注意 设置特权模式,以主机上的 root 用户运行容器进程。如下:
securityContext:
privileged: true
allowPrivilegeEscalation: true

服务

apiVersion: v1
kind: Service
metadata:
  name: gitlab
  namespace: xx-erp
spec:
  selector:
    app: gitlab
  ports:
  - name: http
    port: 80
    targetPort: 80
    nodePort: 30419
  - name: ssh
    port: 22
    targetPort: 22
  type: ClusterIP

这里30419 是开通的外部端口。可以在界面上操作的方式来增加。
在这里插入图片描述

在这里插入图片描述

到这里,就可以使用服务的ip+端口来访问gitlab了。

在这里插入图片描述

root默认密码在文件
/etc/gitlab/initial_root_password 中。可以编辑或者拷贝出来,登录后再在界面上用户管理中修改。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

祺稷

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值