以下是定义服务和postgres服务部署的postgres服务文件。
但是,postgres服务会每分钟重新启动一次。谁能帮助我了解为什么它一直盯着看?我在Minikube(1.18)上运行yaml文件
apiVersion: v1
kind: Service
metadata:
name: postgresdb
labels:
app: postgresdb
spec:
ports:
- port: 5432
name: tcp
selector:
app: postgresdb
type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgresdb-v1
labels:
app: postgresdb
version: v1
spec:
replicas: 1
selector:
matchLabels:
app: postgresdb
version: v1
template:
metadata:
labels:
app: postgresdb
version: v1
spec:
containers:
- name: postgresdb
image: postgres
imagePullPolicy: IfNotPresent
ports:
- containerPort: 5432
env:
- name: POSTGRES_DB
value: simple-service
- name: POSTGRES_USER
value: user
- name: POSTGRES_PASSWORD
value: pass
readinessProbe:
exec:
command: ["psql", "-P", "pass", "-U", "user", "-d", "simple-service", "-c", "SELECT 1"]
initialDelaySeconds: 15
timeoutSeconds: 2
livenessProbe:
exec:
command: ["psql", "-P", "pass", "-U", "user", "-d", "simple-service", "-c", "SELECT 1"]
initialDelaySeconds: 45
timeoutSeconds: 2
---
最佳答案
由于脚本中的无效标志,您的准备工作探针失败。要通过命令行传递密码,请使用-W或--password检查doc here
因此,您的调查应如下所示(准备和活跃度调查)
command: ["psql", "--password", "pass", "-U", "user", "-d", "simple-service", "-c", "SELECT 1"]
关于postgresql - Kubernetes:Postgres容器不断重启,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63112772/