2022-08-14:k8s安装PostgreSQL,yaml如何写?

Posted 福大大架构师每日一题

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2022-08-14:k8s安装PostgreSQL,yaml如何写?相关的知识,希望对你有一定的参考价值。

2022-08-14:k8s安装PostgreSQL,yaml如何写?

答案2022-08-14:

yaml如下:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: postgres
  name: postgres
  namespace: moonfdd
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - env:
            - name: POSTGRES_PASSWORD
              value: "moonfdd"
          image: "postgres"
          imagePullPolicy: IfNotPresent
          name: postgres
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: volv
      volumes:
        - hostPath:
            path: /root/k8s/moonfdd/postgres/var/lib/postgresql/data
            type: DirectoryOrCreate
          name: volv
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: postgres
  name: postgres
  namespace: moonfdd
spec:
  ports:
    - port: 5432
      protocol: TCP
      targetPort: 5432
  selector:
    app: postgres
  type: NodePort

结果如下:


以上是关于2022-08-14:k8s安装PostgreSQL,yaml如何写?的主要内容,如果未能解决你的问题,请参考以下文章

PostgreSQ 连接问题 FATAL: no pg_hba.conf entry for host

图文详解CDC技术,看这一篇就够了!

图文详解CDC技术,看这一篇就够了!

postgresql 安装

API Gateway - KONG 安装与配置

mac安装k8s