我意外删除了一个StatefulSet,需要重新创建它。

huangapple go评论58阅读模式
英文:

I have deleted a StatefulSet on accident and need to re-create it

问题

很抱歉,我无法提供代码翻译。以下是您提供的非代码部分的翻译:

So, dumb me has deleted a very important Statefulset, (I was working in the wrong environment) and need to recover it.
所以,愚蠢的我已经删除了一个非常重要的Statefulset(我在错误的环境中工作),现在需要恢复它。
I have the .yaml file and the description (what you get when you get when you click edit on OpenLens).
我有.yaml文件和描述(当您在OpenLens上点击编辑时会看到的内容)。
This stateful set if used for the database and I can not lose the data.
这个Statefulset用于数据库,我不能丢失数据。
The pvc's and pv's are still there and I have not done anything in fear of losing data.
PVC(持久卷声明)和PV(持久卷)仍然存在,我还没有采取任何行动,以免丢失数据。
As you can probably tell, I am not very familiar with Kubernetes and need help restoring my statefulset and not losing data in the process.
正如您可能已经注意到的,我对Kubernetes并不非常熟悉,需要帮助恢复我的Statefulset,而不丢失数据。

英文:

So, dumb me has deleted a very important Statefulset, (I was working in the wrong environment) and need to recover it.
I have the .yaml file and the description (what you get when you get when you click edit on OpenLens).
This stateful set if used for the database and I can not lose the data.
The pvc's and pv's are still there and I have not done anything in fear of losing data.
As you can probably tell, I am not very familiar with Kubernetes and need help restoring my statefulset and not losing data in the process.

As a sidenote, I tried just kubectl apply -f <file> in our dev environment and data gets lost.

答案1

得分: 1

为了恢复StatefulSet而不丢失数据,您应首先检查与StatefulSet相关的PersistentVolumeClaims(PVCs)和PersistentVolumes(PVs)的状态。您可以通过运行kubectl get pvckubectl get pv命令来执行此操作。一旦您确认PVCs和PVs是完好无损的,您需要相同的StatefulSet YAML文件来进行恢复,通过使用kubectl apply -f命令,您可以重新创建StatefulSet。如果您想要确保StatefulSet在被删除之前的状态完全恢复,您可以使用kubectl replace -f命令。这将使用.yaml文件中定义的新StatefulSet替换现有的StatefulSet,而不更改与之关联的PVCs和PVs上的任何数据。

为了确保在执行上述命令之前不会丢失数据,建议您在执行任何上述命令之前创建StatefulSet的备份。

英文:

To restore the StatefulSet without losing data, you should first check the status of the PersistentVolumeClaims (PVCs) and PersistentVolumes (PVs) associated with the StatefulSet. You can do this by running the kubectl get pvc and kubectl get pv commands. Once you have verified that the PVCs and PVs are intact, you need the same statefulset yaml file for restoring, by using kubectl apply -f command you can recreate the StatefulSet. If you want to ensure that the StatefulSet is restored exactly as it was before it was deleted, you can use the kubectl replace -f command instead. This will replace the existing StatefulSet with the one defined in the .yaml file, without changing any of the data on the associated PVCs and PVs.

To ensure that your data is not lost in the process, it is recommended that you create a backup of the StatefulSet before performing any of the above commands.

huangapple
  • 本文由 发表于 2023年2月8日 18:16:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75384304.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定