coreDNS域名无法解析问题
问题: 在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域名无法解析问题的更多相关文章
- .net iis 域名泛解析实战
最近做个人网站想实现多个二级域名,一来为了好记,二来为了搜索引擎优化,搜索引擎对二级域名的收录还是比较快的.刚开始做了4,5个二级域名,每个都是在域名解析后台手动添加的,不过随着二级域名越来越多,发现 ...
- 从浅入深详解独立ip网站域名恶意解析的解决方案
立IP空间的好处想必大家都能耳熟闻详,稳定性强,利于seo等让大家选择了鼎峰网络香港独立IP空间.那么, 网站独享服务器IP地址,独立IP空间利于百度收录和权重的积累.不受牵连.稳定性强等诸多优势为一 ...
- nginx 域名泛解析
部分应用场景下要求服务器根据客户输入的二级域名地址自动访问不同的页面,比如一个服务器放置了不同的业务,商城.官网等多个业务,又不想一个个配置server, 网站目录结构入戏: html 网站根目录 m ...
- seo优化之域名泛解析优缺点分析
原文地址:http://www.phpddt.com/web/analysis-of-domain-name.html 自己也算半个SEOER,虽然没从事过优化工作,由于自己很感兴趣,每天还是会去看很 ...
- 域名DNS解析说明
一直都对域名DNS 解析很懵逼,今天看到一个博客上面详细的介绍了域名解析. 特意记录下: 记录类型: A记录: 将域名指向一个IPv4地址(例如:8.8.8.8)CNAME:将域名指向另一个域名(例如 ...
- 域名无法解析 Linux临时或永久修改DNS
最近给VPS重装了系统,因为服务商不提供DHCP,所以只好手动设置IP和DNS Server.悲催的是系统重装的时候忘记了输入DNS Server,最后导致进去系统后,各种域名无法解析. Linux中 ...
- 防止独立IP被其它恶意域名恶意解析
一:什么是恶意域名解析 一般情况下,要使域名能访问到网站需要两步,第一步,将域名解析到网站所在的主机,第二步,在web服务器中将域名与相应的网站绑定.但是,如果通过主机IP能直接访问某网站,那么把域名 ...
- bind域名dns解析及主从服务的配置
bind域名dns解析及主从服务的配置 1.dns解析介绍 人们习惯记忆域名,但机器间互相只认IP地址,域名与IP地址之间是多对一的关系,一个ip地址不一定只对应一个域名,且一个域名只可以对应 ...
- 使用 DNSPOD API 实现域名动态解析
0. 简单概述在家里放一个 NAS 服务器,但是宽带的 IP 地址经常改变,一般路由器自带的花生壳域名解析可以解决,如果路由器没有类似功能或者想使用自己的域名,可以尝试使用 DNSPOD API 来实 ...
随机推荐
- ACM中值得注意/利用的C++语法特性
C++ 的易踩坑点 随时补充 STL不能边循环边erase() //自己写的求交集RE了 for (set <int> ::iterator it = s.begin(); it != s ...
- Hdu 4661 树上拓扑序计数
#include <bits/stdc++.h> using namespace std; typedef long long ll; ; ; ; ], nxt[MAXM << ...
- Python&Selenium自动化测试之PO设计模式
一.摘要 Page Object模式,后面简称PO,他是一种设计思想,在上一章节中,曾经列举了一些在编写自动化测试过程中随着代码量的增加导致的大量代码难以维护.难以扩展.可读性极差等灾难性的事件:那么 ...
- 模块化开发之Amd规范和Cmd规范
CMD规范:是SeaJS 在推广过程中对模块定义的规范化产出的. AMD规范:是 RequireJS 在推广过程中对模块定义的规范化产出的 // CMD define(function(require ...
- Bootstrap-轮播图-No.1
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...
- c++中lambda表达式的用法
#include <iostream> using namespace std; int main(){ ; auto func1 = [=](;}; auto func2 = [& ...
- Codeforces Round #589 (Div. 2) A. Distinct Digits
链接: https://codeforces.com/contest/1228/problem/A 题意: You have two integers l and r. Find an integer ...
- log4j.xml常用配置
Log4J的配置文件(Configuration File)就是用来设置记录器的级别.存放器和布局的,它可接key=value格式的设置或xml格式的设置信息.通过配置,可以创建出Log4J的运行环境 ...
- Java进阶知识17 Spring Bean对象的创建细节和创建方式
本文知识点(目录): 1.创建细节 1) 对象创建: 单例/多例 2) 什么时候创建? 3)是否延迟创建(懒加载) 4) 创建对象之后, ...
- 源码安装ROS Melodic Python3 指南 (转) + 安装记录
这篇文章转自 https://blog.csdn.net/id9502/article/details/80410989 csdn真是作大死,我保存这篇博客的时候还不需要花钱就能看,现在居然要v ...