add subPath to volumeMount postgres-data#367
Open
xring wants to merge 1 commit into
Open
Conversation
Collaborator
Review: subPath 对已有部署的兼容性代码本身 LGTM, 潜在风险对于已有数据的部署,加上 建议:添加 init container 自动迁移可以加一个 init container,在 PG 启动前检测并自动迁移数据: initContainers:
- name: migrate-pgdata
image: busybox:1.36
command:
- sh
- -c
- |
# If PG_VERSION exists at root but not in subPath, migrate
if [ -f /data/PG_VERSION ] && [ ! -f /data/pgdata/PG_VERSION ]; then
echo "Migrating existing data to pgdata/ subdirectory..."
mkdir -p /data/pgdata
# Move everything except pgdata/ and lost+found/
for item in /data/*; do
base=$(basename "$item")
if [ "$base" != "pgdata" ] && [ "$base" != "lost+found" ]; then
mv "$item" /data/pgdata/
fi
done
echo "Migration complete."
else
echo "No migration needed."
fi
volumeMounts:
- name: postgres-data
mountPath: /data这样:
如果觉得 init container 过重,也可以在 PR 描述的 Risk 栏里注明"仅适用于全新部署,已有部署需手动迁移数据"即可。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
add
subPathtopostgres-datavolumeMountFull Deployment (with PostgreSQL + Redis) may fail because of
lost+found:Validation
Commands run:
Risk
Notes