k8s部署PostgreSQL
apiVersion: apps/v1
kind: Deployment
metadata:
name: engine-postgres
namespace: pie-engine-infra
spec:
replicas: 1
selector:
matchLabels:
name: engine-postgres
template:
metadata:
labels:
name: engine-postgres
spec:
containers:
- name: postgres
image: infra/postgres:11.0-2.5
imagePullPolicy: IfNotPresent
env:
- name: POSTGRES_USER
value: postgres
- name: POSTGRES_PASSWORD
value: "密码"
volumeMounts:
- name: postgres
mountPath: /var/lib/postgresql/11/main
volumes:
- name: postgres
hostPath:
path: /data/postgre
---
apiVersion: v1
kind: Service
metadata:
name: engine-postgres
namespace: pie-engine-infra
labels:
name: engine-postgres
spec:
type: NodePort
ports:
- nodePort: 30811
port: 5432
targetPort: 5432
protocol: TCP
selector:
name: engine-postgres