我的版本:kubernetes 1.3.0
coredns:1.2.4
参考:
官方网站,https://coredns.io/
CoreDNS安装,https://my.oschina.net/u/2306127/blog/1618543
CoreDNS使用手册,https://coredns.io/manual/toc/
CoreDNS源码,https://github.com/coredns
CoreDNS配置,https://my.oschina.net/u/2306127/blog/1788566
一、最近在研究coredns,安装一直有问题。网上的安装教程很多,把自己所遇到的,记录下来,方便以后学习的朋友。
kube-system coredns-75b9bc7f4b-njfg9 0/1 CrashLoopBackOff 5 5m59s 10.244.5.47 node1
kube-system coredns-75b9bc7f4b-tmf2f 0/1 CrashLoopBackOff 6 5m59s 10.244.4.36 node3
安装时,使用的KUBEADM安装的,后来卸载掉,自己手工安装。
二、安装使用的脚本:
https://github.com/coredns/deployment/tree/master/kubernetes
二、下载:(3个文件)
coredns.yaml.sed
deploy.sh
rollback.sh
三、卸载:
kubectl delete --namespace=kube-system deployment kube-dns
四、安装:
因为卸载了KUBE-DNS,所以安装时需要指定DNS IP .
./deploy.sh -i 10.96.0.10 cluster.local
可能出现的问题:
1,原有的POD还未删干净。
serviceaccount/coredns created
clusterrole.rbac.authorization.k8s.io/system:coredns created
clusterrolebinding.rbac.authorization.k8s.io/system:coredns created
configmap/coredns created
deployment.extensions/coredns created
The Service “kube-dns” is invalid: spec.clusterIP: Invalid value: “10.96.0.10”: provided IP is already allocated
解决方法:等待一会儿。。。
2,IP地址不在范围内
[root@master1 coredns]# ./deploy.sh -i 10.1.0.10 cluster.local | kubectl apply -f -
serviceaccount/coredns unchanged
clusterrole.rbac.authorization.k8s.io/system:coredns unchanged
clusterrolebinding.rbac.authorization.k8s.io/system:coredns unchanged
configmap/coredns unchanged
deployment.extensions/coredns unchanged
The Service “kube-dns” is invalid: spec.clusterIP: Invalid value: “10.1.0.10”: provided IP is not in the valid range. The range of valid IPs is 10.96.0.0/12
[root@master1 coredns]#
解决方法:修改上面SHELL 的指定IP地址。
3,出现这种状态
coredns-75b9bc7f4b-bcv24 0/1 CrashLoopBackOff 1 14s 10.244.4.39 node3
coredns-75b9bc7f4b-mqncs 0/1 CrashLoopBackOff 1 14s 10.244.5.50 node1
查看日志:
[root@master1 ~]# kubectl logs coredns-75b9bc7f4b-bcv24 -n kube-system
plugin/forward: not an IP address or file: ““192.168.8.20””
看来是脚本有问题,我懒得修改脚本了,直接修改配置文件。
./deploy.sh -i 10.96.0.10 cluster.local >> 1.yaml
vi 1.yaml
data:
Corefile: |
.:53 {
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
}
prometheus :9153
forward . "192.168.8.20"
cache 30
loop
reload
loadbalance
}
加粗那里,把" "去掉
vi 1.yaml
data:
Corefile: |
.:53 {
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
}
prometheus :9153
forward . 192.168.8.20
cache 30
loop
reload
loadbalance
}
然后重新apply
kubectl apply -f 1.yaml
4,出现image error状态。
查看本地是否有image
[root@master1 coredns]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.cn-hangzhou.aliyuncs.com/kubernetes2019/kubernetes v1.13.2 177db4b8e93a 2 weeks ago 181MB
busybox latest 3a093384ac30 3 weeks ago 1.2MB
k8s.gcr.io/kubernetes-dashboard-amd64 v1.10.1 f9aed6605b81 5 weeks ago 122MB
k8s.gcr.io/kube-proxy v1.13.0 8fa56d18961f 7 weeks ago 80.2MB
k8s.gcr.io/kube-scheduler v1.13.0 9508b7d8008d 7 weeks ago 79.6MB
k8s.gcr.io/kube-controller-manager v1.13.0 d82530ead066 7 weeks ago 146MB
k8s.gcr.io/kube-apiserver v1.13.0 f1ff9b7e3d6e 7 weeks ago 181MB
prom/node-exporter latest b3e7f67a1480 8 weeks ago 21MB
k8s.gcr.io/coredns 1.2.6 f59dcacceff4 2 months ago 40MB
k8s.gcr.io/etcd 3.2.24 3cab8e1b9802 4 months ago 220MB
k8scn/kubernetes-dashboard-amd64 v1.8.3 fcac9aa03fd6 7 months ago 102MB
k8s.gcr.io/kubernetes-dashboard-amd64 v1.8.3 fcac9aa03fd6 7 months ago 102MB
然后修改 coredns.yaml.s
ed 文件
containers:
- name: coredns
image: k8s.gcr.io/coredns:1.2.6
imagePullPolicy: IfNotPresent
基本上就没问题了,继续深入学习。