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

相关推荐
米高梅狮子11 小时前
Redis
数据库·redis·mysql·缓存·docker·容器·github
汪汪大队u11 小时前
基于 K8s 的物联网平台运维体系:Ansible+Zabbix 自动化监控与故障自愈(三)—— Zabbix Server 启动排错记
运维·kubernetes·ansible
代码熬夜敲Q12 小时前
Docker基础
运维·docker·容器
亚空间仓鼠12 小时前
Docker容器化高可用架构部署方案(十四)
docker·容器·架构
平行云12 小时前
实时云渲染平台数据通道,支持3D应用文件上传下载分享无缝交互
linux·unity·云原生·ue5·gpu算力·实时云渲染·像素流送
日取其半万世不竭12 小时前
OpenCost:Kubernetes 成本监控,开源的云资源费用分析
容器·kubernetes·开源
姚不倒13 小时前
Go 进阶实战:实现泛型数据验证器
云原生·golang
万里侯13 小时前
Ansible自动化运维实战:从入门到生产级应用
微服务·容器·k8s
Cat_Rocky13 小时前
k8s zabbix7学习-设置告警
学习·容器·kubernetes
容器魔方14 小时前
华为云云容器引擎CCE 2026-Q1优化升级,全面进化您的云原生体验!
大数据·分布式·云原生·容器·云计算