wget https://storage.googleapis.com/kubernetes-release/release/v1.11.0/kubernetes-server-linux-amd64.tar.gz tar -xzvf kubernetes-server-linux-amd64.tar.gz cd kubernetes tar -zxf kubernetes-src.tar.gz cp cluster/addons/dns/kube-dns/kube-dns.yaml.sed ~/kube-dns/kubedns-service.yaml 修改image地址 #把文件中$DNS_SERVER_IP替換成10.254.0.2 sed -i 's/$DNS_SERVER_IP/10.254.0.2/g' ./kubedns-service.yaml #把$DNS_DOMAIN替換成cluster.local sed -i 's/$DNS_DOMAIN/cluster.local/g' ./kubedns-service.yaml 增長父系DNS 修改配置文件kubedns-service.yaml apiVersion: v1 kind: ConfigMap metadata: name: kube-dns namespace: kube-system labels: addonmanager.kubernetes.io/mode: EnsureExists data: stubDomains: | ##此處指定以test.duia.com結尾的域名使用10.0.0.55解析 {"test.duia.com":["10.0.0.55"]} upstreamNameservers: | ##此處指定覆蓋上級dns ["223.5.5.5"] 啓動 kubectl create -f kubedns-service.yaml 驗證 get pods --namespace="kube-system" NAME READY STATUS RESTARTS AGE kube-dns-8498694664-99gqr 3/3 Running 0 38m kubernetes-dashboard-69db8c7745-hdhbg 1/1 Running 1 3h
進入隨意一個容器,能夠Ping通外網地址 linux
配置文件各項目的含義 名稱|含義 ---|--- errors|錯誤會被記錄到標準輸出 health|能夠經過http://localhost:8080/health查看健康情況 kubernetes|根據服務的IP響應DNS查詢請求,kubeadm的Cluster Domain和Service CIDR默認爲cluster.local和10.95.0.0/12,能夠經過--service-dns-domain和--service-cidr參數配置。 prometheus|能夠經過http://localhost:9153/metrics獲取prometheus格式的監控數據 proxy|本地沒法解析後,向上級地址進行查詢,默認使用宿主機的 /etc/resolv.conf 配置 cache|緩存時間 [root@k8s-master ~]# kubectl -n kube-system get configmap coredns -o yaml apiVersion: v1 data: Corefile: | .:53 { errors health kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure upstream fallthrough in-addr.arpa ip6.arpa ttl 30 } prometheus :9153 forward . /etc/resolv.conf cache 30 loop reload loadbalance } kind: ConfigMap metadata: creationTimestamp: "2019-08-22T10:09:36Z" name: coredns namespace: kube-system resourceVersion: "181" selfLink: /api/v1/namespaces/kube-system/configmaps/coredns uid: bb1db052-35c7-4162-8fc6-7ff8fe164ae2