hxd 们,之前手贱不小心删了 etcd 里的数据,导致好多资源都丢了
现在想要恢复下,部分应用原来的持久化是通过 NFS 实现的,现在我怎么继续引用 NFS 里面的数据
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgresql
spec:
selector:
matchLabels:
app: postgresql
template:
metadata:
labels:
app: postgresql
spec:
containers:
- image: postgres
imagePullPolicy: IfNotPresent #拉取策略
name: postgresql
env:
- name: POSTGRES_PASSWORD
value: ""
ports:
- containerPort: 5432
name: postgresql
volumeMounts:
- name: postgresql-persistent-storage
mountPath: /var/lib/postgresql/data
volumes:
- name: postgresql-persistent-storage
persistentVolumeClaim:
claimName: postgresql-pv-claim
serviceName: postgresql
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgresql-pv-claim
spec:
storageClassName: managed-nfs-storage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: v1
kind: Service
metadata:
name: postgresql-client-service
labels:
app: postgresql
spec:
type: NodePort
ports:
- port: 5432
targetPort: 5432
nodePort: 30432
protocol: TCP
selector:
app: postgresql
1
Suaxi 2022-04-14 15:21:16 +08:00
容器重新跑起来之后,先停一下,把对应容器重建的 pvc uuid 改成原来对应的 pvc uuid ,然后重启,实际操作还是需要根据你本地环境的情况
|
2
seagull7558 OP @Suaxi 老哥牛的,还有这操作,我去试试
|
3
seagull7558 OP @Suaxi 老哥我没用你说的修改 UID 觉得有点危险,我是直接拷贝文件
1. 先创建服务,然后缩容到 0 2. 清理新生成服务 PVC 映射的 NFS 目录下(A)的所有文件 3. 复制旧的 NFS 文件到 A 文件夹下 4. 扩容到 1 |
4
Suaxi 2022-04-14 16:46:19 +08:00 1
@seagull7558 可以的,刚刚忘了说操作之前记得备份下源数据
|