Service discovery
In k8s, we usually will more than make an application instance, and also the corresponding multiple pod, if through the pod IP access to the pod service will be hard to manage. Kubernetes provides the concept of service can be accessed through the VIP pod services, but in the use of the time there is a problem: how do you know an application of the VIP?We have two application, for example, an APP, one is the DB, manage each application using the rc, and provide services through service exposed the port.APP needs to connect to the DB application, we only know the name of a DB application, but do not know the VIP address.
 
The simplest way from kubernetes provides query API.But this is a bad practice, every application must first write queries at start-up time rely on the service logic, this itself is repeat and increases the complexity of the application;Second leading to applications rely on kubernetes, will not be able to deploy and run separately (of course, if by adding configuration option is also can be done, but it is increase in degrees).
 
At first, the method of kubernetes adopted docker used - environment variables.Start each pod, will be put through the environment variable is set all service of IP and port information, so that the application of the pod can be read by the environment variable to rely on the service address information.Matching relation between service and environment variables this way has a certain specification, use rise also relatively simple, but there is a big problem: rely on the service must be started in the pod existed before, otherwise will not appear in the environment variable.
 
A more ideal solution is: application can directly use the name of the service, don't need to care about it the IP address of the actual, in the middle of the conversion can be done automatically.DNS is name and IP conversion between the function of the system, so kubernetes is also provides the DNS method to solve this problem.
 
DNS Service
The DNS service is not independent of the system, but an addon, as a plug-in to install, not kubernetes cluster must (but very recommended installation).Can take it as a run on the application of the cluster, it's just the application is special.
There are two kinds of DNS configuration mode, using etcd + kube2sky + skydns way before version 1.3, can be used after 1.3 kubedns + dnsmasq way.
 

kube2sky mode

    This model mainly has three containers in operation:
  • Kube2sky is responsible for the continuous monitoring k8s apiserver, once has the service creation, will obtain the service IP, and stored in the etcd
  • Etcd in the form of the key - value is used to store the service name and the corresponding "ClusterIP"
  • SkyDNS: according to the data of the etcd, external DNS query service

Service discovery
In k8s, we usually will more than make an application instance, and also the corresponding multiple pod, if through the pod IP access to the pod service will be hard to manage. Kubernetes provides the concept of service can be accessed through the VIP pod services, but in the use of the time there is a problem: how do you know an application of the VIP?We have two application, for example, an APP, one is the DB, manage each application using the rc, and provide services through service exposed the port.APP needs to connect to the DB application, we only know the name of a DB application, but do not know the VIP address.
 
The simplest way from kubernetes provides query API.But this is a bad practice, every application must first write queries at start-up time rely on the service logic, this itself is repeat and increases the complexity of the application;Second leading to applications rely on kubernetes, will not be able to deploy and run separately (of course, if by adding configuration option is also can be done, but it is increase in degrees).
 
At first, the method of kubernetes adopted docker used - environment variables.Start each pod, will be put through the environment variable is set all service of IP and port information, so that the application of the pod can be read by the environment variable to rely on the service address information.Matching relation between service and environment variables this way has a certain specification, use rise also relatively simple, but there is a big problem: rely on the service must be started in the pod existed before, otherwise will not appear in the environment variable.
 
A more ideal solution is: application can directly use the name of the service, don't need to care about it the IP address of the actual, in the middle of the conversion can be done automatically.DNS is name and IP conversion between the function of the system, so kubernetes is also provides the DNS method to solve this problem.
 
DNS Service
The DNS service is not independent of the system, but an addon, as a plug-in to install, not kubernetes cluster must (but very recommended installation).Can take it as a run on the application of the cluster, it's just the application is special.
There are two kinds of DNS configuration mode, using etcd + kube2sky + skydns way before version 1.3, can be used after 1.3 kubedns + dnsmasq way.
 

kube2sky mode

    This model mainly has three containers in operation:
  • Kube2sky is responsible for the continuous monitoring k8s apiserver, once has the service creation, will obtain the service IP, and stored in the etcd
  • Etcd in the form of the key - value is used to store the service name and the corresponding "ClusterIP"
  • SkyDNS: according to the data of the etcd, external DNS query service
        
                example:
                        There is a DB, a APP server, APP server needs to connect DB for data reading and writing
                       1.DB server, through the RC created a pod, and at the same time to create a service for integration of the pod,DB service named DB_server.This is accomplished by k8s - apiserver,Will be a cluster IP for DB service distribution,for example: 192.168.20.3,ClusterIP can only be used for use within the cluster.
                       2.kube2sky listening to APIserver operations, access to the service name: DB_server and clusterIP: 192.168.20.3, and will write etcd.
                       3.APP server configured in the DB address for 'DB_server', this is the name of DB service,Use the service name instead of IP
                       4.Pod will send service name: DB_server to skyDNS, loading from etcd skyDNS service name corresponding IP, returned to the Pod
 
kubeDNS mode
    This mode, kubeDNS container replace the function of the original three container, it will be to monitor apiserver and put all the service and the result of the endpoints using appropriate data structure stored in memory, and external DNS query service.

    • KubeDNS: to provide the original kube2sky + etcd + skyDNS function, can provide DNS query service
    • A lightweight DNS service software, can provide DNS cache function.KubeDNS mode, dnsmasq in memory set aside a block size (the default is 1g), save the current most commonly used DNS query record, if there is no to find records in the cache, it will into kubeDNS query, and the results are cached

                    
                 example:
                 1.DB server, through the RC created a pod, and at the same time to create a service for integration of the pod,DB service named DB_server.This is accomplished by k8s - apiserver,Will be a cluster IP for DB service distribution,for example: 192.168.20.3,ClusterIP can only be used for use within the cluster.
                  2. kubeDNS  listening to APIserver operations,access to the service name: DB_server and clusterIP: 192.168.20.3, and use tree structure write cache.
                  3. dnsmasq:DNS rules obtained through kubedns container, in a cluster to provide DNS query service, equivalent to the DNS server.
                  4. APP server configured in the DB address for 'DB_server', this is the name of DB service,Use the service name instead of IP
                  5. Pod will send service name: DB_server to dnsmasq,dnsmasq query to the service of the corresponding IP is returned to the pod, if not checked, will contact the kubeDNS,If kubeDNS no record, it will return an error report to the APP server pod.
                example:
                        There is a DB, a APP server, APP server needs to connect DB for data reading and writing
                       1.DB server, through the RC created a pod, and at the same time to create a service for integration of the pod,DB service named DB_server.This is accomplished by k8s - apiserver,Will be a cluster IP for DB service distribution,for example: 192.168.20.3,ClusterIP can only be used for use within the cluster.
                       2.kube2sky listening to APIserver operations, access to the service name: DB_server and clusterIP: 192.168.20.3, and will write etcd.
                       3.APP server configured in the DB address for 'DB_server', this is the name of DB service,Use the service name instead of IP
                       4.Pod will send service name: DB_server to skyDNS, loading from etcd skyDNS service name corresponding IP, returned to the Pod
 
kubeDNS mode
    This mode, kubeDNS container replace the function of the original three container, it will be to monitor apiserver and put all the service and the result of the endpoints using appropriate data structure stored in memory, and external DNS query service.

    • KubeDNS: to provide the original kube2sky + etcd + skyDNS function, can provide DNS query service
    • A lightweight DNS service software, can provide DNS cache function.KubeDNS mode, dnsmasq in memory set aside a block size (the default is 1g), save the current most commonly used DNS query record, if there is no to find records in the cache, it will into kubeDNS query, and the results are cached

                    
                 example:
                 1.DB server, through the RC created a pod, and at the same time to create a service for integration of the pod,DB service named DB_server.This is accomplished by k8s - apiserver,Will be a cluster IP for DB service distribution,for example: 192.168.20.3,ClusterIP can only be used for use within the cluster.
                  2. kubeDNS  listening to APIserver operations,access to the service name: DB_server and clusterIP: 192.168.20.3, and use tree structure write cache.
                  3. dnsmasq:DNS rules obtained through kubedns container, in a cluster to provide DNS query service, equivalent to the DNS server.
                  4. APP server configured in the DB address for 'DB_server', this is the name of DB service,Use the service name instead of IP
                  5. Pod will send service name: DB_server to dnsmasq,dnsmasq query to the service of the corresponding IP is returned to the pod, if not checked, will contact the kubeDNS,If kubeDNS no record, it will return an error report to the APP server pod.

kubeDNS workflow(service registration and discovery)的更多相关文章

  1. Open-Source Service Discovery

    Service discovery is a key component of most distributed systems and service oriented architectures. ...

  2. Spring Boot Dubbo Dubbok spring cloud

    比较spring cloud和dubbo,各自的优缺点是什么 - 趁年轻再疯狂一次吧 - CSDN博客 https://blog.csdn.net/u010664947/article/details ...

  3. springcloud情操陶冶-初识springcloud

    许久之前便听到了springcloud如雷贯耳的大名,但是不曾谋面,其主要应用于微服务的相关架构.笔者对微服务并不是很了解,但其既然比较出众,遂也稍微接触研究下 springcloud特性 sprin ...

  4. 微服务领域是不是要变天了?Spring Cloud Alibaba正式入驻Spring Cloud官方孵化器!

    引言 微服务这个词的热度自它出现以后,就一直是高烧不退,而微服务之所以这么火,其实和近几年互联网的创业氛围是分不开的. 与传统行业不同,互联网企业有一个特点,那就是市场扩张速度非常之快,可能也就是几天 ...

  5. springcloud

    基本术语 1.服务器 服务器:是提供计算服务的设备.由于服务器需要响应服务请求,并进行处理,因此一般来说服务器应具备承担服务并且保障服务的能力.服务器的构成:包括处理器.硬盘.内存.系统总线等,和通用 ...

  6. 微服务之Spring cloud

    微服务 Spring cloud Spring Cloud provides tools for developers to quickly build some of the common patt ...

  7. Spring Cloud简介

    一.本文介绍 Web应用由最早的单体应用发展成为集群式的部署,再到现在的分布式系统.尤其是这两年分布式相关的技术发展的很快,一方面是以Dubbo为代表的,另一方面则是以Spring Cloud系列为代 ...

  8. Spring Cloud Summary

    Spring Cloud Summary https://cloud.spring.io/spring-cloud-static/Finchley.RC1/single/spring-cloud.ht ...

  9. 搭建Spring Initializr服务器

    前言 按照网上很多教程,出错特别多.首先是GitHub和maven仓库的网络环境比较差,踩了很多坑:其次是SpringInitializr更新迭代几个版本,0.7.0我也没能弄成功.索性就用了旧版本0 ...

随机推荐

  1. Android Stuido中断点调试和高级调试

    写一个简单的调试程序 import android.os.Bundle; import android.support.v7.app.AppCompatActivity; public class M ...

  2. qt liunx 安装命令

    qt SDK : apt-get install qt-sdkqt 安装 : apt-get install qtcreator文档安装 : cmake kdelibs5-data subversio ...

  3. mybatis如何遍历Map的key和value【增删改查】

    转: mybatis如何遍历Map的key和value 2017年11月28日 10:07:57 Joker_Ye 阅读数:4158   1.sql.xml <?xml version=&quo ...

  4. Nova 实现的 Fit Instance NUMA to Host NUMA 算法

    目录 文章目录 目录 前文列表 numa_fit_instance_to_host _numa_fit_instance_cell _numa_fit_instance_cell_with_pinni ...

  5. 在mac下安装fiddler

    说明:学习fiddler好久了,一直以来也没形成文档,之前学的一些知识也快忘得差不多了:正好利用假期,把之前学的知识都捡起来,捋一遍,形成文档,供以后使用的时候参考和借鉴 一:下载Mono 因为fid ...

  6. 电脑上不了网,但是能登录QQ 问题解决方案

    电脑上不了网,但是能登录QQ 问题解决方案 问题现象 个人电脑连上Wifi,打不开百度等网页,但是能登录QQ. 解决方案 1.打开命令提示对话框(Win+R) 2.输入ipconfig/display ...

  7. SAS数据挖掘实战篇【五】

    SAS数据挖掘实战篇[五] SAS--预测模型 6.1 测模型介绍 预测型(Prediction)是指由历史的和当前的数据产生的并能推测未来数据趋势的知识.这类知识可以被认为是以时 间为关键属性的关联 ...

  8. RazorSQL for Mac如何编辑数据?

    RazorSQL 是一个非开源的功能非常强大数据库查询工具.SQL的编辑.数据库管理工具.支持通过 JDBC 和 ODBC 连接超过 29 种的数据库.允许您从一个数据库工具查询,更新,导航和管理所有 ...

  9. LinuxC/C++基础——引用

    1.引用(Reference) 1.1引用的基本语法 引用是C++对C的重要扩充,也存在与其他一些编程语言中,并不是C++的发明.通过引用,C++增加了 另外一种给函数传递地址的途径,这就是按引用传递 ...

  10. run.sh

    1.run.sh   文件  ./run.sh start启动    ./run.sh stop 停止    ./run.sh restart重启     ./run.sh install安装     ...