kubernetes - 如何在k8s中重新生成Corefile?

标签 kubernetes dns

我的核心 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/

相关文章:

docker - 如何在 Kubernetes 中配置多个服务/容器?

Azure 地形 : Inserting "certificate-authority" data into Kube context during cluster creation

windows - 在命令行验证域凭据

php - Wordpress wp_remote_post() 给出 "cURL error 6: Could not resolve host"

powershell - 从 CSV 文件设置网络接口(interface)卡的 Azure DN 设置

c# - Dns.GetHostAddresses 真的取回所有已注册的 IP 吗?

kubernetes - 在不存在的情况下将 `serviceAccountName`设置为 `default`

kubernetes - 如何保证Pod不重启?

kubernetes - Kubernetes无法在自动扩展GKE节点池中的节点上调度Daemonset Pod

windows - Windows 7 上的 DNS 本地域反欺骗?