我的核心 dns corefile 以某种方式损坏,现在我需要重新生成它或将其重置为默认安装值。我怎么做?我尝试通过 kubectl edit cm coredns -n kube-system 复制并粘贴本地保存的文件版本,但出现验证错误
error: configmaps "coredns" is invalid
A copy of your changes has been stored to "/tmp/kubectl-edit-suzaq.yaml"
error: Edit cancelled, no valid changes were saved.
最佳答案
当您直接编辑设置时,它曾经会给出错误。
你能做什么?
before you run anything, please take a backup:
kubectl -n kube-system get configmap coredns -o yaml > coredns.yaml
方法#1,强制应用。
kubectl apply --force -f /tmp/kubectl-edit-suzaq.yaml
大多数情况下,通过这种方式都会成功应用最新的设置。如果失败,请检查错误,更新文件 /tmp/kubectl-edit-suzaq.yaml
并再次强制应用。
方法#2,删除并再次应用。
kubectl -n kube-system get configmap coredns -o yaml > coredns.yaml
# do a backup, if you don't 100% sure the change will work
cp coredns.yaml coredns.yaml.orig
# update the change in coredns.yaml
# delete coredns
kubectl delete configmap coredns
# apply new change
kubectl apply -f coredns.yaml
请小心,上述步骤将导致中断。如果您在生产环境中工作,您应该考虑在进行上述更改之前备份所有 kubernetes 设置。
关于kubernetes - 如何在k8s中重新生成Corefile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60536960/