Kubernetes密码验证上的Postgres失败

时间:2019-05-06 23:34:45

标签: postgresql docker kubernetes

我使用了本教程:https://severalnines.com/blog/using-kubernetes-deploy-postgresql

我在Kubernetes上的配置基于官方Docker镜像,我不断得到:

psql -h <publicworkernodeip> -U postgres -p <mynodeport> postgres
Password for user postgres: example
psql: FATAL:  password authentication failed for user "postgres"
DETAIL:  Role "postgres" does not exist.
Connection matched pg_hba.conf line 95: "host all all all md5"

yamls:

apiVersion: v1
kind: ConfigMap
metadata:
  name: postgres-config
  labels:
    app: postgres
data:
  POSTGRES_DB: postgres
  POSTGRES_USER: postgres
  POSTGRES_PASSWORD: example
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: postgres
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: postgres
          image: postgres:11
          imagePullPolicy: Always
          ports:
            - containerPort: 5432
          envFrom:
            - configMapRef:
                name: postgres-config
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgres
      volumes:
        - name: postgres
          persistentVolumeClaim:
            claimName: postgres-pv-claim
apiVersion: v1
kind: Service
metadata:
  name: postgres
  labels:
    app: postgres
spec:
  type: NodePort
  ports:
   - port: 5432
  selector:
   app: postgres
kind: PersistentVolume
apiVersion: v1
metadata:
  name: postgres-pv-volume
  labels:
    type: local
    app: postgres
spec:
  storageClassName: manual
  capacity:
    storage: 12Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/mnt/data"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: postgres-pv-claim
  labels:
    app: postgres
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 12Gi

1 个答案:

答案 0 :(得分:1)

尝试使用以下命令登录

psql -h $(主机名-i)-U postgres

router.get('/', (req, res) => {
    ProReg.find()
    .sort({ date: -1 })
   this is not working // .populate({path:"products", populate:["oem", "category", "subcategory"]})
this is also not working // .populate("products", "oem")
    .then(proreg => res.json(proreg))
    .catch(err => res.status(404).json({ msg: 'No Pro Reg found' }));
});