问题: 在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. 简单的jquery进度条插件LineProgressbar.js,myProgress.js

    参考   http://www.lanrenzhijia.com/jquery/4121.html demo下载 <script src="js/jquery.lineProgress ...

  2. git 获得当前分支名及其对应的远程分支

    git 获得当前分支名及其对应的远程分支 git symbolic-ref -q --short HEADgit rev-parse --abbrev-ref --symbolic-full-name ...

  3. python+Appium自动化:yaml配置capability

    场景 学习了yaml之后就是要将capability的各项参数值与代码分离开. 先创建一个capability.yaml文件,把各项参数存放在其中,然后用load()进行读取. 例子: capabil ...

  4. np中的随机函数

      numpy.random.uniform介绍: 1. 函数原型:  numpy.random.uniform(low,high,size)  ==>也即其他函数是对该函数的进一步封装 功能: ...

  5. queue的一些用法

    import queue q = queue.Queue(3)# 指定队列大小,如果为空则为无限大 print(q.empty()) q.put('厉智') q.put('程劲') q.put('陈培 ...

  6. [Docker] Run a command inside Docker container

    For example you are working in a backend project, you have setup Dockerfile: FROM node:10.16.0-stret ...

  7. centos6.5linux安装docker之升级内核

    一.运行docker Linux内核版本需要在3.8以上,针对centos6.5 内核为2.6的系统需要先升级内核.不然会特别卡 在yum的ELRepo源中,有mainline(4.5).long-t ...

  8. ila核数据输出

    在Tcl Console中输入以下命令(其中dataxxxx表示文件名,hw_ila_2则为ila窗口名): write_hw_ila_data -csv_file -force dataxxxx [ ...

  9. BZOJ 2834: 回家的路 Dijkstra

    按照横,竖为方向跑一个最短路即可,算是水题~ #include <bits/stdc++.h> #define N 200005 #define E 2000000 #define set ...

  10. Noip2011 提高组 Day1 T3 Mayan游戏

    题目描述 Mayan puzzle是最近流行起来的一个游戏.游戏界面是一个 7 行5 列的棋盘,上面堆放着一些方块,方块不能悬空堆放,即方块必须放在最下面一行,或者放在其他方块之上.游戏通关是指在规定 ...