Kubernetes/File/Yaml/drone-postgres.yaml

79 lines
1.5 KiB
YAML
Raw Permalink Normal View History

2024-08-07 10:54:39 +00:00
apiVersion: v1
kind: Secret
metadata:
name: drone-db-secret
namespace: drone
stringData:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: drone
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: drone-db-pvc
namespace: drone
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: drone
name: drone-db
spec:
selector:
matchLabels:
app: drone-db
serviceName: drone-db
replicas: 1
template:
metadata:
labels:
app: drone-db
spec:
containers:
- name: drone-db
image: postgres:latest
envFrom:
- secretRef:
name: drone-db-secret
ports:
- containerPort: 5432
protocol: TCP
livenessProbe:
exec:
command:
- psql
- -h
- localhost
- -U
- postgres
- -c
- "SELECT 1;"
initialDelaySeconds: 10 #启动后等待10秒开始检测
periodSeconds: 10 #每隔10秒检测一次
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: data
volumes:
- name: data
persistentVolumeClaim:
claimName: drone-db-pvc
---
apiVersion: v1
kind: Service
metadata:
namespace: drone
name: drone-db
spec:
selector:
app: drone-db
ports:
- protocol: TCP
port: 5432
targetPort: 5432