Kubernetes [2]: Service discovery mechanism and cluster DNS installation (no CA certified version)

Source: Internet
Author: User
Tags etcd



  Service discovery mechanism

Kubernetes service






Kubernetes provides two ways to discover the service: kubernetes service pod 



1. Environment Variables


    When the pod is running, Kubernetes writes the information for the service that existed before


Kubernetes as service


    This method requires that the pod must be started after the service.


Kubernetes as a service


    The pod that was started before the service will not have an environment variable for that service.


Kubernetes expose service port


There is no such limit in the way DNS is used.
Selector kubernetes service


2.DNS


    When a new service is created, a DNS record is automatically generated.





With this approach, you need to install cluster DNS.










In Kubernetes each service will be assigned a virtual IP, each service under normal circumstances will not change for a long time, this is relative to the pod of the indefinite IP, the use of the cluster app is relatively stable. But the service's information injected into the pod is currently using an environment variable, and relies heavily on pod (RC) and service creation order, which makes the cluster look less perfect, so kubernetes introduced the DNS system in a plug-in way. Using DNS to map the service so that we can use the domain name directly in the app to reference, avoid the previous variable flooding problem, but also avoid the embarrassing situation of the creation order.













installation of cluster DNS under the Kubernetes1.2.7 version


Read the official source discovery on GitHub:
Cluster DNS Since the Kubernetes1.3 version, the structure has changed. This is the first study of the 1.2.7 version.





 cluster DNS extension is used to support Kubernetes's service discovery mechanism, and in the 1.2.7 version, Cluster DNS mainly contains the following items:  





1) Skydns
Provides a DNS resolution service.
2) Etcd
The storage used for DNS.
3) Kube2sky
Listen for Kubernetes When a new service is created, register it on ETCD.
4) Healthz
Provides health check functionality for SKYDNS services.



Download the Kubernetes release package on the master server


cluster DNS is under the Cluster/addons/dns directory of the Kubernetes release package



[[email protected] home]# yum -y install  wget[[email protected] home]# wget https://codeload.github.com/kubernetes/kubernetes/ tar.gz/v1.2.7[[email protected] home]# tar -xf kubernetes-1.2.7.tar.gz[[email  Protected] home]# lskubernetes-1.2.7  kubernetes-1.2.7.tar.gz  sheng[[email  protected] home]# cd kubernetes-1.2.7/cluster/addons/dns[[email protected] dns] # lskube2sky  maintainers.md  owners  readme.md  skydns   skydns-rc.yaml.in  skydns-svc.yaml.in# Skydns-rc.yaml.in and skydns-svc.yaml.in are two template files, and you can generate Replication controller and service definition files by modifying their corresponding property values by setting the environment variables. 



It is important to note that the Clusterip used by the Skydns service requires us to specify a fixed IP address that will be used by each node's kubelet process and cannot be automatically assigned to Skydns through Kuberneters.


























1. Skydns configuration file


Create an RC configuration file for the DNS service that contains 3 container definitions in this RC configuration















































Kubernetes Combat [2]: Service discovery mechanism and cluster DNS installation (no CA certified)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.