k8s 中的 odoo:Odoo pod 运行 然后崩溃

odoo in k8s: Odoo pod running then crashing

我尝试在 k8s 中部署 Odoo ;

我为 odoo/postgres/services 使用了以下 Yaml 文件。 Odoo pod 总是崩溃。日志结果:

could not translate host name "db" to address: Temporary failure in name resolution

apiVersion: apps/v1
kind: Deployment
metadata:
  name: odoo3
spec:
  replicas: 1
  selector:
    matchLabels:
      app: odoo3
  template:
    metadata:
      labels:
        app: odoo3
    spec:
      containers:
      - name: odoo3
        image: odoo
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        env:
        - name: POSTGRES_DB
          value: "postgres"
        - name: POSTGRES_PASSWORD
          value: "postgres"
        - name: POSTGRES_USER
          value: "postgres"
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: odoo3
  labels:
    app: odoo3
spec:
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: odoo3

需要指定环境变量HOST

 env:
        - name: POSTGRES_DB
          value: "postgres"
        - name: POSTGRES_PASSWORD
          value: "postgres"
        - name: POSTGRES_USER
          value: "postgres"
        - name: HOST
          value: "your-postgres-service-name"

您的 your-postgres-service-name 应该指向您的 postgres 数据库容器或服务器。