k8s部署gitlab
创建PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitlab-data-pvc
namespace: cicd
spec:
storageClassName: nfs-csi
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitlab-config-pvc
namespace: cicd
spec:
storageClassName: nfs-csi
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: gitlab
namespace: cicd
spec:
selector:
matchLabels:
app: gitlab
replicas: 1
template:
metadata:
labels:
app: gitlab
spec:
containers:
- name: gitlab
image: gitlab/gitlab-ce:17.2.1-ce.0
env:
- name: GITLAB_SKIP_UNMIGRATED_DATA_CHECK
value: "true"
- name: GITLAB_OMNIBUS_CONFIG
value: |
external_url = 'http://gitlab.yuankun.cc/'
prometheus['enable'] = false
alertmanager['enable'] = false
gitlab_rails['time_zone'] = 'Asia/Shanghai'
gitlab_rails['gitlab_email_enabled'] = false
gitlab_rails['smtp_enable'] = false
gitlab_rails['gravatar_plain_url'] = 'http://gravatar.loli.net/avatar/%{hash}?s=%{size}&d=identicon'
gitlab_rails['gravatar_ssl_url'] = 'https://gravatar.loli.net/avatar/%{hash}?s=%{size}&d=identicon'
nginx['worker_processes'] = 2
postgresql['max_connections'] = 100
postgresql['shared_buffers'] = "128MB"
ports:
- containerPort: 80
name: http
- containerPort: 443
name: https
- containerPort: 22
name: ssh
readinessProbe:
exec:
command: ["sh", "-c", "curl -s http://127.0.0.1/-/health"]
livenessProbe:
exec:
command: ["sh", "-c", "curl -s http://127.0.0.1/-/health"]
timeoutSeconds: 5
failureThreshold: 3
periodSeconds: 60
startupProbe:
exec:
command: ["sh", "-c", "curl -s http://127.0.0.1/-/health"]
failureThreshold: 20
periodSeconds: 120
resources:
requests:
memory: "4Gi"
cpu: "2"
limits:
memory: "8Gi"
cpu: "4"
volumeMounts:
- name: data
mountPath: /var/opt/gitlab
- name: config
mountPath: /etc/gitlab
- name: log
mountPath: /var/log/gitlab
- mountPath: /dev/shm
name: cache-volume
volumes:
- name: data
persistentVolumeClaim:
claimName: gitlab-data-pvc
- name: config
persistentVolumeClaim:
claimName: gitlab-config-pvc
- name: log
emptyDir: {}
- name: cache-volume
emptyDir:
medium: Memory
sizeLimit: 256Mi
service
apiVersion: v1
kind: Service
metadata:
name: gitlab-svc
namespace: cicd
spec:
selector:
app: gitlab
ports:
- port: 80
targetPort: 80
name: http
- port: 443
targetPort: 443
name: https
- port: 22
targetPort: 22
name: ssh
ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gitlab
namespace: cicd
spec:
ingressClassName: nginx
rules:
- host: gitlab.yuankun.cc
http:
paths:
- backend:
service:
name: gitlab-svc
port:
number: 80
path: /
pathType: Prefix
评论区