In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the example analysis of installing kubernetes 1.6 kube-dns under ubuntu 16.04. the editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
1 preface
If service solves the problem of pod service discovery and load balancing, then kube-dns is born to solve the problem of service discovery. Imagine such a scenario. If an application wants to access the backend service without knowing the service ip, it can only query the IP and port corresponding to the service with kubectl get svc-n namespace, and then change the configuration, so that the configuration of each new service will be changed, which is troublesome enough. Then if this problem is solved, this is the content of this article.
2 use kube-dns to discover service
The kube-dns plug-in provides three container functions as follows:
Kubedns container
Monitor kubernetes service resources and update DNS records
Replace etcd, use TreeCache data structure to save DNS records and implement the backend interface of skydns
Connect to skydns and provide DNS query service to dnsmasq
Dnsmasq container
Provide DNS query service to the cluster
Set kubedns to upstream
Provide DNS cache to reduce kubedns load and improve performance
Exechealthz container
Regularly check the monitoring status of kubedns and dnsmasq
To provide HTTP API for kubernetes activity detection.
3 kubedns,dnsmasq,exechealthz schematic
4 kube-dns plug-in installation
The installation of kube-dns actually starts three containers: kubedns,dnsmasq,exechealthz
Create a kube-dns service first
Cat kubedns-svc.yaml
ApiVersion: v1
Kind: Service
Metadata:
Name: kube-dns
Namespace: kube-system
Labels:
K8s-app: kube-dns
Spec:
Selector:
K8s-app: kube-dns
ClusterIP: 10.10.10.10 # is consistent with the-cluster-dns of the kubelet startup parameters of each node * *
Ports:
-name: dns
Port: 53
Protocol: UDP
-name: dns-tcp
Port: 53
Protocol: TCP
Create kube-dns RC, create three containers
Cat kubedns-rc.yaml
ApiVersion: v1
Kind: ReplicationController
Metadata:
Name: kube-dns-v6
Namespace: kube-system
Labels:
K8s-app: kube-dns
Version: v6
Kubernetes.io/cluster-service: "true"
Spec:
Replicas: 1
Selector:
K8s-app: kube-dns
Version: v6
Template:
Metadata:
Labels:
K8s-app: kube-dns
Version: v6
Spec:
Containers:
-name: kubedns
Image: siriuszg/kubedns-amd64:latest
ImagePullPolicy: IfNotPresent
Resources:
Limits:
Cpu: 100m
Memory: 50Mi
LivenessProbe:
HttpGet:
Path: / healthz-kubedns
Port: 8080
Scheme: HTTP
InitialDelaySeconds: 60
TimeoutSeconds: 5
SuccessThreshold: 1
FailureThreshold: 5
ReadinessProbe:
HttpGet:
Path: / readiness
Port: 8081
Scheme: HTTP
InitialDelaySeconds: 3
TimeoutSeconds: 5
Args:
-domain=cluster.local. # is consistent with the startup parameter-cluster-domain in the kubelet of each node. There is a "." * * after cluster.local.
-dns-port=10053
-kube-master-url= http://192.168.100.20:8080
Ports:
-containerPort: 10053
Name: dns-local
Protocol: UDP
-name: kube-dnsmasq
Image: ist0ne/kube-dnsmasq-amd64:latest
ImagePullPolicy: IfNotPresent
LivenessProbe:
HttpGet:
Path: / healthz-dnsmasq
Port: 8080
Scheme: HTTP
InitialDelaySeconds: 60
TimeoutSeconds: 5
SuccessThreshold: 1
FailureThreshold: 5
Args:
-cache-size=1000
-no-resolv
-server=127.0.0.1#10053
-log-facility=-
Ports:
-containerPort: 53
Name: dns
Protocol: UDP
-containerPort: 53
Name: dns-tcp
Protocol: TCP
-name: healthz
Image: ist0ne/exechealthz-amd64:latest
ImagePullPolicy: IfNotPresent
Resources:
Limits:
Memory: 50Mi
Requests:
Cpu: 10m
Memory: 50Mi
Args:
-cmd=nslookup kubernetes.default.svc.cluster.local 127.0.0.1 > / dev/null
-url=/healthz-dnsmasq
-cmd=nslookup kubernetes.default.svc.cluster.local 127.0.0.1 10053 > / dev/null
-url=/healthz-kubedns
-port=8080
-quiet
Ports:
-containerPort: 8080
Protocol: TCP
DnsPolicy: Default
Note: the values of-- cluster-dns and-- cluster-domain,--cluster-dns should be added to the kubelet startup parameters of each node. The values of-- cluster-dns and-- cluster-domain,--cluster-dns are the values of clusterIP in service: 10.10.10.10.
In this way, the container startup automatically adds the following fields to / etc/resolv.conf
Execute kubectl create-f kubedns-svc.yaml and kubectl create-f kubedns-rc.yaml to create service and pod of kubedns, respectively
5 Verification
Through the above steps, the plug-in for kube-dns is installed. First, let's take a look at what we have installed. We can view the service,rc and pod we created through kubectl or dashboard. The screenshot below is viewed through kubectl.
You can see from the figure that the pod of kube-dns-v6-41d2c is started. On the node 192.168.100.93, the assigned IP is 172.17.2.5. A total of three containers are enabled, and the three containers share IP.
Find a pod from default namespace and use this pod to verify kube-dns
Choose the pod tomcat-gllz3 because the container in this pod contains nslookup.
It can be seen from the figure that all service can be parsed through kubedns.
Note: the domain name rule of kubedns is service-name.namespace.svc.domain
Service-name is the name of a service
Namespace is the namespace in which the service is located
Svc is a fixed character
Domain is the domain specified when creating the kubedns pod, that is, the cluster-domain in the kubelete startup parameters of each node. This article is cluster.local.
On the "ubuntu 16.04 installation of kubernetes 1.6 kube-dns sample analysis" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.