Skip to content

Instantly share code, notes, and snippets.

@novohool
Last active July 17, 2018 05:12
Show Gist options
  • Save novohool/3ecbdd1c1197fd9b77a2d1e20e41a891 to your computer and use it in GitHub Desktop.
Save novohool/3ecbdd1c1197fd9b77a2d1e20e41a891 to your computer and use it in GitHub Desktop.
查看dns服务器及使用的域名格式
查看dns服务器地址:
```
[root@localhost ~]# kubectl exec -ti busybox -- cat /etc/resolv.conf
nameserver 172.18.0.250
search default.svc.cluster.local svc.cluster.local cluster.local localdomain
options ndots:5
```
域名格式:
```
<service_name>.<namespace>.svc.<cluster_domain>
```
服务器上查看:
```
[root@localhost ~]# nslookup nginx-svc.default.svc.cluster.local 172.18.0.250
Server: 172.18.0.250
Address: 172.18.0.250#53
Name: nginx-svc.default.svc.cluster.local
Address: 172.18.220.186
```
访问只需前两者【<service_name>.<namespace>】即可
```
[root@localhost ~]# kubectl exec -ti linux-797957557f-sptp9 -- curl nginx-svc.default
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
  body {
      width: 35em;
      margin: 0 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>
```
问题排除
```
kubectl exec -n kube-system -ti kube-dns-659bc9899c-vhv7z -- nslookup youku.com
kubectl exec -n kube-system -ti kube-dns-659bc9899c-vhv7z -- nslookup linux-svc.default
kubectl describe pod/kube-dns-659bc9899c-vhv7z -n kube-system
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment