【发布时间】:2020-11-15 22:53:23
【问题描述】:
我有一个运行应用程序的 Kubernetes 集群。集群的一部分是一个 postgresql pod,当前运行版本 10.4。不幸的是,我发现我需要升级 postgresql 版本。
postgres yaml 如下:
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:10.4
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: postgres-config
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgredb
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: postgres-pv-claim
postgresql 数据库中已经有一些数据。我需要找到一种在生产中升级集群的方法。
如果我只是尝试将图像更改为 12.0 并运行 kubectl apply 我会收到错误:
2020-11-15 22:48:08.332 UTC [1] DETAIL: The data directory was initialized by PostgreSQL version 10, which is not compatible with this version 12.5 (Debian 12.5-1.pgdg100+1).
所以我知道我需要手动升级集群内的 postgres 数据库,然后我才能修复 yaml。对吗?
【问题讨论】:
-
您好。您可能应该寻找 Pg 10 --> 12 的“已批准升级路径”。stackoverflow.com/questions/60409585/… 确保在进行任何更改之前备份了数据。
标签: postgresql kubernetes