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

结果如下:

在这里插入图片描述
在这里插入图片描述

本作品采用《CC 协议》,转载必须注明作者和本文链接
微信公众号:福大大架构师每日一题。最新面试题,涉及golang,rust,mysql,redis,云原生,算法,分布式,网络,操作系统。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!