k8s动态配置/etc/hosts

###使用命令行修改hosts,完事后保存退出,立即生效
kubectl  edit configmap  coredns  -n  kube-system
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
           pods insecure
           upstream
           fallthrough in-addr.arpa ip6.arpa
        }
        hosts {
           192.168.4.203 master.seq01
           fallthrough
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
    }
kind: ConfigMap
metadata:
  creationTimestamp: "2020-11-02T08:07:24Z"
  name: coredns
  namespace: kube-system
  resourceVersion: "387829"
  selfLink: /api/v1/namespaces/kube-system/configmaps/coredns
  uid: 70d8c28a-1ce2-11eb-a27e-bc97e155d4ce
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐