在Kubernetes中部署bluespice-free的持久卷配置相关问题问询
配置方案
Deployment持久卷配置修改
你需要在现有Deployment基础上添加卷挂载规则,将你已经创建的bluespice-pvc持久卷声明挂载到容器内的/data路径即可,完整配置如下:
apiVersion: apps/v1 kind: Deployment metadata: name: bluespice namespace: default labels: app: bluespice spec: replicas: 1 selector: matchLabels: app: bluespice template: metadata: labels: app: bluespice spec: containers: - name: bluespice image: bluespice/bluespice-free ports: - containerPort: 80 env: - name: bs_url value: "https://bluespice.mycompany.local" # 新增持久卷挂载配置 volumeMounts: - name: bluespice-storage mountPath: /data # 新增持久卷声明关联配置 volumes: - name: bluespice-storage persistentVolumeClaim: claimName: bluespice-pvc
现有未持久化Pod的数据保留方案
直接挂载持久卷无法保留现有数据:当前未配置持久卷的Pod中,/data路径下的内容存储在容器临时可写层,直接新增PVC挂载到/data时,空的PVC内容会覆盖该路径,原有数据会被隐藏无法访问。
如需保留数据可按以下步骤操作:
- 先从现有运行的Pod中复制
/data目录内容到本地备份:kubectl cp <当前运行的bluespice Pod名称>:/data ./bluespice-data-backup - 修改Deployment添加上述持久卷配置后重新发布,等待新Pod正常启动
- 将本地备份的数据复制回新Pod的
/data路径:kubectl cp ./bluespice-data-backup/* <新启动的bluespice Pod名称>:/data/ - 重启Pod确认数据正常加载即可
内容的提问来源于stack exchange,提问作者user9066046
相关产品推荐
相关产品推荐

