kubectl 数据库服务导致 postgres 崩溃?

问题描述 投票:0回答:1

我正在尝试为 kubernetes 的 postgres 配置数据库部署。但是我不断收到以下错误。有人可以告诉我我可能做错了什么吗?

数据库/secret.yml

apiVersion: v1
kind: Secret
metadata:
  name: postgres-secrets
type: Opaque
data:
  database: ZXRs
  username: cG9zdGdyZXM=
  password: cG9zdGdyZXM=

database/deployment.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: postgresdb
          image: postgres
          imagePullPolicy: "IfNotPresent"
          ports:
            - containerPort: 5432
          env:
            - name: DATABASE_NAME
              valueFrom:
                secretKeyRef:
                  name: postgres-secrets
                  key: database
            - name: DATABASE_USER
              valueFrom:
                secretKeyRef:
                  name: postgres-secrets
                  key: username
            - name: DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgres-secrets
                  key: password
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgresdb
            - name: postgres-secrets
              mountPath: "/etc/postgres-secrets"
              readOnly: true
      volumes:
        - name: postgresdb
          persistentVolumeClaim:
            claimName: postgres-pvc
        - name: postgres-secrets
          secret:
            secretName: postgres-secrets

日志

   kubectl logs postgres-6667fcb9c-sk77f       

错误:数据库未初始化且未指定超级用户密码。 您必须将 POSTGRES_PASSWORD 指定为非空值 超级用户。例如,“docker run”上的“-e POSTGRES_PASSWORD=password”。

   You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
   connections without a password. This is *not* recommended.

   See PostgreSQL documentation about "trust":
   https://www.postgresql.org/docs/current/auth-trust.html
postgresql kubernetes minikube
1个回答
0
投票

我对这样的事情了解不多,因为我还在学习。 这就是为什么我不想将此作为答案发布,而是作为评论发布,但我不能(没有足够的声誉)。

但我认为DATABASE_USER和DATABASE_PASSWORD应该是POSTGRES_USER和POSTGRES_PASSWORD。

© www.soinside.com 2019 - 2024. All rights reserved.