K8S-部署Postgres

apiVersion: v1

kind: PersistentVolumeClaim

metadata:

name: postgres-pv-claim

namespace: ops

spec:

accessModes:

  • ReadWriteMany

resources:

requests:

storage: 13Gi

storageClassName: xxxxx


apiVersion: apps/v1

kind: Deployment

metadata:

name: postgres

namespace: ops

labels:

app: postgres

spec:

selector:

matchLabels:

app: postgres

replicas: 1

strategy:

rollingUpdate:

maxSurge: 25%

maxUnavailable: 25%

type: RollingUpdate

template:

metadata:

labels:

app: postgres

spec:

containers:

  • name: postgres

image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/postgres:15-alpine

imagePullPolicy: IfNotPresent

resources:

requests:

cpu: 100m

memory: 100Mi

limits:

cpu: 4

memory: 8000Mi

env:

  • name: POSTGRES_PASSWORD

value: 'xxx'

  • name: POSTGRES_USER

value: 'xxx'

  • name: POSTGRES_DB

value: 'postgres'

  • name: PGDATA

value: /var/lib/postgresql/data/pgdata

ports:

  • containerPort: 5432

name: postgresport

volumeMounts:

  • name: localtime

mountPath: /etc/localtime

  • name: data-disk

mountPath: /var/lib/postgresql/data

volumes:

  • name: localtime

hostPath:

path: /usr/share/zoneinfo/Asia/Shanghai

  • name: data-disk

persistentVolumeClaim:

claimName: postgres-pv-claim


apiVersion: v1

kind: Service

metadata:

name: postgres

namespace: ops

spec:

selector:

app: postgres

type: NodePort

ports:

  • name: postgres

port: 5432

targetPort:

protocol: TCP

相关推荐
阿里云云原生2 天前
阿里云获评 Agentic AI 开发平台领导者,函数计算 AgentRun 赢下关键分!
云原生
蝎子莱莱爱打怪2 天前
Centos7中一键安装K8s集群以及Rancher安装记录
运维·后端·kubernetes
崔小汤呀2 天前
Docker部署Nacos
docker·容器
缓解AI焦虑2 天前
Docker + K8s 部署大模型推理服务:资源划分与多实例调度
docker·容器
阿里云云原生2 天前
MSE Nacos Prompt 管理:让 AI Agent 的核心配置真正可治理
微服务·云原生
阿里云云原生3 天前
当 AI Agent 接管手机:移动端如何进行观测
云原生·agent
阿里云云原生3 天前
AI 原生应用开源开发者沙龙·深圳站精彩回顾 & PPT下载
云原生
阿里云云原生3 天前
灵感启发:日产文章 100 篇,打造“实时热点洞察”引擎
云原生
1candobetter3 天前
Docker Compose Build 与 Up 的区别:什么时候必须重建镜像
docker·容器·eureka
~莫子3 天前
Haproxy七层负载详解+实验详细代码
云原生