# GitLab 云环境部署

# Namespace

$ kubectl create namespace devops

# 部署

gitlab-deployment.yml

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitlab
  namespace: devops
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gitlab
  template:
    metadata:
      labels:
        app: gitlab
    spec:
      hostname: gitlab
      containers:
      - name: gitlab
        image: 172.16.62.204:30085/puyuan/gitlab-ce:12.10.14-ce.0
        imagePullPolicy: Always
        ports:
        - containerPort: 80
          name: port
          protocol: TCP
        resources:
          limits:
            cpu: 4000m
            memory: 8Gi
          requests:
            cpu: 4000m
            memory: 8Gi
        volumeMounts:
          - name: config
            mountPath: /etc/gitlab # GitLab配置文件目录
          - name: data
            mountPath: /var/opt/gitlab # GitLab数据目录
          - name: log
            mountPath: /var/log/gitlab # GitLab日志目录
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: gitlab-data
        - name: config
          persistentVolumeClaim:
            claimName: gitlab-config
        - name: log
          persistentVolumeClaim:
            claimName: gitlab-log

# 服务暴漏

gitlab-svc.yml

---
apiVersion: v1
kind: Service
metadata:
  name: gitlab
  namespace: devops
  labels:
    app: gitlab
spec:
  selector:
    app: gitlab
  type: NodePort
  ports:
  - name: port
    port: 80
    targetPort: port
    nodePort: 30075
上次更新: 2023-4-3 17:15:20