问题: 在pod内无法解析域名

解决:

busybox的镜像有bug,导致ping可以解析,但是nslookup无法解析

kubectl run -it --rm --image=infoblox/dnstools dns-client

换成上面的就可以,实在解决不了再看下面的

dnstools# nslookup kubernetes

方式一:

创建coredns.yaml  要用hostwork模式,hostwork就是用的宿主机的 服务器IP端口

cluster-dns 指定成宿主机的

然后重启kubelet

然后重新创建pod

修改/etc/resolv.conf

[root@lab3 kubernetes]# kubectl get po -o wide -n kube-system
NAME READY STATUS RESTARTS AGE IP NODE
coredns-6d9f9c4fc9-2h652 / Running 1h 10.1.1.111 10.1.1.111
coredns-6d9f9c4fc9-6prhs / Running 1h 10.1.1.68 10.1.1.68 修改三台的 宿主机的 resolv.conf 都改成 10.1.1.111
[root@lab2 kubernetes]# cat /etc/resolv.conf
# Generated by NetworkManager
search openstacklocal
nameserver 10.1.1.111 修改三台的,改成各自对应的宿主机的ip地址
[root@lab2 kubernetes]# cat kubelet
KUBELET_HOSTNAME="--hostname-override=10.1.1.68"
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1"
KUBELET_CONFIG="--config=/etc/kubernetes/kubelet-config.yml"
KUBELET_ARGS="--bootstrap-kubeconfig=/etc/kubernetes/kubelet-bootstrap.conf --kubeconfig=/etc/kubernetes/kubelet.conf --cert-dir=/etc/kubernetes/pki --network-plugin=cni --cni-bin-dir=/opt/cni/bin --cni-conf-dir=/etc/cni/net.d --cluster-dns=10.1.1.68 --cluster-domain=cluster.local " 在cul容器内部访问
[ root@curl-87b54756-tsnwd:/ ]$ curl example-service.default.svc.cluster.local
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html> 在外部主机访问
[root@lab2 kubernetes]# curl example-service.default.svc.cluster.local
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html> 但是访问下面短的 还是不行
[root@lab3 kubernetes]# curl example-service
curl: () Could not resolve host: example-service; Unknown error 解决办法,指点:搜索域有问题,
他的是搜索域的问题 在busybox里面可以访问短的域名 [root@lab2 kubernetes]# kubectl run -it --rm --image=infoblox/dnstools dns-client
If you don't see a command prompt, try pressing enter.
dnstools#
dnstools#
dnstools# curl example-service
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html> 方式二: 新版本自然解决: 流程: 、删除原先coredns的配置 、部署coredns . 删除原先的pod、service、重新创建, #!/bin/bash
wget https://raw.githubusercontent.com/coredns/deployment/master/kubernetes/coredns.yaml.sed
wget https://raw.githubusercontent.com/coredns/deployment/master/kubernetes/deploy.sh
chmod +x deploy.sh
./deploy.sh -i 10.96.0.10 -d cluster.local. > dns.yaml
kubectl apply -f dns.yaml; --cluster-dns=10.1.1.8 --cluster-domain=cluster.local" 在外边访问service ,那是另外一个问题了啊!但是首先你cluster 中 DNS的IP 不应拿hostip 来顶住哦 可以把内部的cluster ip 再用其他的代理 代理出来,里边的还是用 一个clusterip #!/bin/bash
export http_proxy=
export https_proxy=
wget https://raw.githubusercontent.com/coredns/deployment/master/kubernetes/coredns.yaml.sed
wget https://raw.githubusercontent.com/coredns/deployment/master/kubernetes/deploy.sh
chmod +x deploy.sh
./deploy.sh -i 10.254.0.2 -d cluster.local. > dns.yaml
kubectl apply -f dns.yaml;
:: [root@lab3 kubernetes]# netstat -anp |grep
tcp 10.1.1.111: 10.1.1.8: ESTABLISHED /kubelet
tcp6 ::: :::* LISTEN /coredns
tcp6 ::: :::* LISTEN /coredns
udp6 ::: :::* /coredns
unix [ ACC ] STREAM LISTENING /NetworkManager /var/run/NetworkManager/private-dhcp
unix [ ] STREAM CONNECTED /NetworkManager
unix [ ] DGRAM /systemd-udevd
unix [ ] DGRAM /NetworkManager
unix [ ] STREAM CONNECTED /NetworkManager
unix [ ] STREAM CONNECTED /NetworkManager [ root@curl-87b54756-782kr:/ ]$ nslookup example-service
Server: 10.96.0.10
Address : 10.96.0.10 kube-dns.kube-system.svc.cluster.local Name: example-service
Address : 10.104.125.95 example-service.default.svc.cluster.local
[ root@curl-87b54756-782kr:/ ]$ curl example-service
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html>

coreDNS域名无法解析问题的更多相关文章

  1. .net iis 域名泛解析实战

    最近做个人网站想实现多个二级域名,一来为了好记,二来为了搜索引擎优化,搜索引擎对二级域名的收录还是比较快的.刚开始做了4,5个二级域名,每个都是在域名解析后台手动添加的,不过随着二级域名越来越多,发现 ...

  2. 从浅入深详解独立ip网站域名恶意解析的解决方案

    立IP空间的好处想必大家都能耳熟闻详,稳定性强,利于seo等让大家选择了鼎峰网络香港独立IP空间.那么, 网站独享服务器IP地址,独立IP空间利于百度收录和权重的积累.不受牵连.稳定性强等诸多优势为一 ...

  3. nginx 域名泛解析

    部分应用场景下要求服务器根据客户输入的二级域名地址自动访问不同的页面,比如一个服务器放置了不同的业务,商城.官网等多个业务,又不想一个个配置server, 网站目录结构入戏: html 网站根目录 m ...

  4. seo优化之域名泛解析优缺点分析

    原文地址:http://www.phpddt.com/web/analysis-of-domain-name.html 自己也算半个SEOER,虽然没从事过优化工作,由于自己很感兴趣,每天还是会去看很 ...

  5. 域名DNS解析说明

    一直都对域名DNS 解析很懵逼,今天看到一个博客上面详细的介绍了域名解析. 特意记录下: 记录类型: A记录: 将域名指向一个IPv4地址(例如:8.8.8.8)CNAME:将域名指向另一个域名(例如 ...

  6. 域名无法解析 Linux临时或永久修改DNS

    最近给VPS重装了系统,因为服务商不提供DHCP,所以只好手动设置IP和DNS Server.悲催的是系统重装的时候忘记了输入DNS Server,最后导致进去系统后,各种域名无法解析. Linux中 ...

  7. 防止独立IP被其它恶意域名恶意解析

    一:什么是恶意域名解析 一般情况下,要使域名能访问到网站需要两步,第一步,将域名解析到网站所在的主机,第二步,在web服务器中将域名与相应的网站绑定.但是,如果通过主机IP能直接访问某网站,那么把域名 ...

  8. bind域名dns解析及主从服务的配置

    bind域名dns解析及主从服务的配置 1.dns解析介绍     人们习惯记忆域名,但机器间互相只认IP地址,域名与IP地址之间是多对一的关系,一个ip地址不一定只对应一个域名,且一个域名只可以对应 ...

  9. 使用 DNSPOD API 实现域名动态解析

    0. 简单概述在家里放一个 NAS 服务器,但是宽带的 IP 地址经常改变,一般路由器自带的花生壳域名解析可以解决,如果路由器没有类似功能或者想使用自己的域名,可以尝试使用 DNSPOD API 来实 ...

随机推荐

  1. 基于递归的BFS(Level-order)

    上篇中学习了二叉树的DFS深度优先搜索算法,这次学习另外一种二叉树的搜索算法:BFS,下面看一下它的概念: 有些抽象是不?下面看下整个的遍历过程的动画演示就晓得是咋回事啦: 了解其概念之后,下面看下如 ...

  2. CF901C Bipartite Segments[点双+二分+前缀优化]

    不想翻译了,直接放luogu翻译 说了没有偶环,也就是说全是奇环,再结合二分图性质,那么暴力的话,固定左端点,增大序号,加点直到产生环就不合法了.也就是说,任何一个环,只要他上面的数全都被加了,就不合 ...

  3. BZOJ2730 [HNOI2012]矿场搭建[点双连通分量]

    看到删去一个点,需要剩下的都和关键点连通,有端联想到找点双,因为他怎么删点都是连通的. 对于一个孤立的点双,至少要设两个关键点. 如果两个点双以一个割点连接,假设断掉这个割点,两个块至少要各设一个关键 ...

  4. qt 启动参数 -qws

    运行嵌入式程序 在嵌入式QT版本中,程序需要服务器或自己作为服务器程序. 服务器程序构造的方法是构造一个QApplication::GuiServe类型的QApplication对象.或者使用-qws ...

  5. Mysql数据库多对多关系未建新表

    原则上,多对多关系是要新建一个关系表的,当遇到没有新建表的情况下如何查询多对多的SQL呢? FIND_IN_SET(str,strlist) 官网:http://dev.mysql.com/doc/r ...

  6. Python模块之目录

     1.加密算法有关 hmac模块 hashlib模块 2.进程有关 multiprocessing模块 3.线程有关 threading模块 4.协程有关 asyncio模块 5.系统命令调用 sub ...

  7. contents() 查找匹配元素内部所有的子节点(包括文本节点)。如果元素是一个iframe,则查找文档内容

    contents() V1.2概述 查找匹配元素内部所有的子节点(包括文本节点).如果元素是一个iframe,则查找文档内容   示例 描述:大理石平台检定规程 查找所有文本节点并加粗 HTML 代码 ...

  8. luogu 2519 [HAOI2011]problem a 动态规划+树状数组

    发现每一次 $[b[i]+1,n-a[i]]$ 这个区间的分数必须相同,否则不合法. 而一个相同的区间 $[l,r]$ 最多只能出现区间长度次. 于是,就得到了一个 $dp:$ 将每一种区间的出现次数 ...

  9. 【线性代数】3-1:向量空间(Space of Vectors)

    title: [线性代数]3-1:向量空间(Space of Vectors) categories: Mathematic Linear Algebra keywords: Vectors Spac ...

  10. 在chrome开发者模式中查找你的js文件

    在chrom开发者模式中按ctrl+o查找你的js文件