1

我有一个有 10 个副本的 StatefulSet,每个副本都有数百 GB 的数据。

我想在 10 个副本中的 1 个上对对象存储(例如 S3)运行备份命令。(因此可以在 initContainer 步骤中加载数据)

是否可以使用基于副本 ID 的亲和性来调度容器?或者是否可以从环境变量中检索副本 ID?

4

1 回答 1

0

I've iterated through 2 solutions on this so far:

using the $HOSTNAME env var to check that the current pod is replica 0

This works if you can tolerate taking backups while the pod is running

- "[ $HOSTNAME = 'mypod-0' ] && /start-backup.sh || echo 'noop' && sleep 10000"

a script that administers the cluster

but if the pod must flush state to disk before a backup, then create a script (I used Node.js) to do this:

  1. bring replica count down by 1
  2. attach disk from that replica that was brought down to a backup pod
  3. bring replica count up by 1
于 2018-09-04T16:19:04.200 回答