gitlab使用k8s 1.18.2部署,部署yaml文件如下:
1.gitlab-redis.yaml:
apiVersion: v1
kind: Namespace
metadata:
name: gitlab
labels:
name: gitlab
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: gitlab-redis-pv
namespace: gitlab
labels:
pv: gitlab-redis-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
nfs:
path: /opt/k8s/project-manage-sys/gitlab/redis
server: k8s-nfs-server
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitlab-redis-pvc
namespace: gitlab
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
storageClassName: nfs
selector:
matchLabels:
pv: gitlab-redis-pv
---
apiVersion: v1
kind: ReplicationController
metadata:
name: redis
namespace: gitlab
spec:
replicas: 1
selector:
name: redis
template:
metadata:
name: redis
labels:
name: redis
spec:
nodeSelector:
name: "k8s-node-1"
containers:
- name: redis
image: sameersbn/redis
env:
- name: TZ
value: Asia/Shanghai
ports:
- name: redis
containerPort: 6379
volumeMounts:
- mountPath: /var/lib/redis
name: data
livenessProbe:
exec:
command:
- redis-cli
- ping
initialDelaySeconds: 30
timeoutSeconds: 5
readinessProbe:
exec:
command:
- redis-cli
- ping
initialDelaySeconds: 5
timeoutSeconds: 1
volumes:
- name: data
persistentVolumeClaim:
claimName: gitlab-redis-pvc
---
apiVersion: v1
kind: Service
metadata:
name: redis
namespace: gitlab
labels:
name: redis
spec:
ports:
- name: redis
port: 6379
targetPort: redis
selector:
name: redis
2。gitlab-postgresql.yaml:
apiVersion: v1
kind: PersistentVolume
metadata:
name: gitlab-postgresql-pv
namespace: gitlab
labels:
pv: gitlab-postgresql-pv
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
nfs:
path: /opt/k8s/project-manage-sys/gitlab/postgresql
server: k8s-nfs-server
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitlab-postgresql-pvc
namespace: gitlab
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Gi
storageClassName: nfs
selector:
matchLabels:
pv: gitlab-postgresql-pv
---
apiVersion: v1
kind: ReplicationController
metadata:
name: postgresql
namespace: gitlab
spec:
replicas: 1
selector:
name: postgresql
template:
metadata:
name: postgresql
labels:
name: postgresql
spec:
nodeSelector:
name: "k8s-node-1"
containers:
- name: postgresql
image: sameersbn/postgresql:10
env:
- name: TZ
value: Asia/Shanghai
- name: DB_USER
value: gitlab
- name: DB_PASS
value: passw0rd
- name: DB_NAME
value: gitlab_production
- name: DB_EXTENSION
value: pg_trgm
ports:
- name: postgres
containerPort: 5432
volumeMounts:
- mountPath: /var/lib/postgresql
name: data
# livenessProbe:
# exec:
# command:
# - pg_isready
# - -h
# - localhost
# - -U
# - postgres
# initialDelaySeconds: 30
# timeoutSeconds: 5
# readinessProbe:
# exec:
# command:
# - pg_isready
# - -h
# - localhost
# - -U
# - postgres
# initialDelaySeconds: 5
# timeoutSeconds: 1
volumes:
- name: data
persistentVolumeClaim:
claimName: gitlab-postgresql-pvc
---
apiVersion: v1
kind: Service
metadata:
name: postgresql
namespace: gitlab
labels:
name: postgresql
spec:
ports:
- name: postgres
port: 5432
targetPort: postgres
selector:
name: postgresql
3.gitlab.yaml:
apiVersion: v1
kind: PersistentVolume
metadata:
name: gitlab-pv
namespace: gitlab
labels:
pv: gitlab-pv
spec:
capacity:
storage: 500Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: nfs
nfs:
path: /opt/k8s/project-manage-sys/gitlab/gitlab
server: k8s-nfs-server
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitlab-pvc
namespace: gitlab
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 500Gi
storageClassName: nfs
selector:
matchLabels:
pv: gitlab-pv
---
apiVersion: v1
kind: ReplicationController
metadata:
name: gitlab-ldap
namespace: gitlab
spec:
replicas: 1
selector:
name: gitlab
template:
metadata:
name: gitlab
labels:
name: gitlab
spec:
nodeSelector:
name: "k8s-node-1"
containers:
- name: gitlab
image: sameersbn/gitlab:12.1.6
env:
- name: TZ
value: Asia/Shanghai
- name: GITLAB_TIMEZONE
value: Beijing
- name: GITLAB_SECRETS_DB_KEY_BASE
value: long-and-random-alpha-numeric-string
- name: GITLAB_SECRETS_SECRET_KEY_BASE
value: long-and-random-alpha-numeric-string
- name: GITLAB_SECRETS_OTP_KEY_BASE
value: long-and-random-alpha-numeric-string
- name: GITLAB_ROOT_PASSWORD
value: gitlab123
- name: GITLAB_HOST
value: "10.7.11.115"
- name: GITLAB_PORT
value: "30001"
- name: GITLAB_SSH_PORT
value: "30002"
- name: GITLAB_NOTIFY_ON_BROKEN_BUILDS
value: "true"
- name: GITLAB_NOTIFY_PUSHER
value: "false"
- name: GITLAB_BACKUP_SCHEDULE
value: daily
- name: GITLAB_BACKUP_TIME
value: 01:00
- name: DB_TYPE
value: postgres
- name: DB_HOST
value: postgresql
- name: DB_PORT
value: "5432"
- name: DB_USER
value: gitlab
- name: DB_PASS
value: passw0rd
- name: DB_NAME
value: gitlab_production
- name: REDIS_HOST
value: redis
- name: REDIS_PORT
value: "6379"
ports:
- name: http
containerPort: 80
- name: ssh
containerPort: 22
volumeMounts:
- mountPath: /home/git/data
name: data
# livenessProbe:
# httpGet:
# path: /
# port: 80
# initialDelaySeconds: 180
# timeoutSeconds: 5
# readinessProbe:
# httpGet:
# path: /
# port: 80
# initialDelaySeconds: 5
# timeoutSeconds: 1
volumes:
- name: data
persistentVolumeClaim:
claimName: gitlab-pvc
---
apiVersion: v1
kind: Service
metadata:
name: gitlab
namespace: gitlab
labels:
name: gitlab
spec:
type: ClusterIP
ports:
- name: http
port: 80
targetPort: http
- name: ssh
port: 22
targetPort: ssh
selector:
name: gitlab
---
kind: Service
apiVersion: v1
metadata:
labels:
name: gitlab
type: LoadBalancer
name: gitlab-balancer
namespace: gitlab
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
nodePort: 30001
- name: ssh
port: 22
protocol: TCP
targetPort: 22
nodePort: 30002
selector:
name: gitlab
type: NodePort
---
# apiVersion: extensions/v1beta1
# kind: Ingress
# metadata:
# name: gitlab
# namespace: gitlab
# annotations:
# kubernetes.io/ingress.class: traefik
# spec:
# rules:
# - host: gitlab.xxx.net
# http:
# paths:
# - backend:
# serviceName: gitlab
# servicePort: 80
前两天因服务器断电,发现数据库中的数据部分丢失,仓库的数据可能还在,在5月底做了数据的全量备份,即nfs 目录:/opt/k8s/project-manage-sys/gitlab/gitlab 下的所有文件做了备份,到服务器断电前正常使用,请教有办法恢复吗?
摘要
此文本将被隐藏