定于spec:clusterIP: None

还记得Service的Cluster IP是做什么的吗?对,一个Service可能对应多个EndPoint(Pod),client访问的是Cluster IP,通过iptables规则转到Real Server,从而达到负载均衡的效果(实现原理请见这里)。如下:

有头service

kubectl get service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-service 10.107.124.218 192.168.128.158 /TCP,/TCP 1d
kubectl describe  service nginx-service
Name: nginx-service
Namespace: default
Labels:
Selector: component=nginx
Type: ClusterIP
IP: 10.107.124.218
External IPs: 192.168.128.158
Port: nginx-http 80/TCP
Endpoints: 10.244.2.9:80
Port: nginx-https 443/TCP
Endpoints: 10.244.2.9:443
nslookup nginx-service.default.svc.cluster.local  10.96.0.10  #这个ip为k8s dns的ip
Server: 10.96.0.10
Address: 10.96.0.10#53 Name: nginx-service.default.svc.cluster.local
Address: 10.107.124.218

虽然service有2个endpoint,但是dns查询时只会返回service的地址。具体client访问的是哪个Real Server,是由iptables来决定的。

无头service

kubectl get service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx None /TCP 1h
kubectl describe  service nginx
Name: nginx
Namespace: default
Labels: app=nginx
Selector: app=nginx
Type: ClusterIP
IP: None
Port: web 80/TCP
Endpoints: 10.244.2.17:80,10.244.2.18:80 #通过web获取到pod的ip地址
nslookup nginx.default.svc.cluster.local 10.96.0.10
Server: 10.96.0.10
Address: 10.96.0.10#53 Name: nginx.default.svc.cluster.local
Address: 10.244.2.17
Name: nginx.default.svc.cluster.local
Address: 10.244.2.18

dns查询会如实的返回2个真实的endpoint

最新文章

  1. 基于HT for Web 3D技术快速搭建设备面板
  2. ubuntu 远程开机
  3. PHPExcel 类
  4. margin负值的使用
  5. NLog 安装使用
  6. 解决win service 2003 IIS发布Gis网站后,访问地图服务出错,无法正常打开而且 事件查看器出现错误提示。
  7. Git/Github 教程
  8. block的修饰词为什么选用copy
  9. 关于jquery ajax跨域请求获取response headers问题
  10. Error Code: 1175. You are using safe update mode and you tried to update a table
  11. Android EditText常用属性
  12. C#设计模式(17)——观察者模式
  13. lwip协议栈移植(1)
  14. tomcat one connection one thread one request one thread
  15. C语言 - 栈和单链表的实现
  16. MQTT 嵌入式端通讯协议解析(转)
  17. MySQL5.7修改默认密码、随机密码
  18. Assetbundle创建与加载
  19. java图片压缩(Thumbnails)
  20. 如何在osx的终端下使用字典

热门文章

  1. Git 命令及git服务器
  2. JD-GUI反编译出现ERROR
  3. 从Redis到Codis移植实践
  4. Python 字符串操作 starswitch() find() re.IGNORECASE replace() join()
  5. CentOS7 安装极点五笔输入法
  6. fork项目适合全局替换注释说明
  7. 集束搜索beam search和贪心搜索greedy search
  8. MSSQL 漏洞利用与提权
  9. 异常处理与网络基础中的tcp,udp协议
  10. pycharm使用selenium之前