Kubernetes Basic Primer-Installation Deployment Configuration Example
Deploying Kubernetes Skydns
Kubernetes can provide DNS internal domain name resolution services for pods.
Kubernetes pause
Its main function is to provide pods with the ability to resolve the IP directly through the service's name to the corresponding service!
Kubernetes pause pod
1. First add the options in the Kubelet process for each node:
Pause pod kubernetes
kubelet_args= "--cluster_dns=10.254.0.10--cluster_domain=kube.local"
The Master node operates as follows:
[email protected] master/root/yaml]# cat Dns/kubedns-rc.yaml
Kind:replicationcontroller
Metadata
Name:kube-dns-v6
Namespace:default
Labels
K8s-app:kube-dns
Version:v6
Kubernetes.io/cluster-service: "True"
Spec
Replicas:1
Version:v6
Template
Metadata
Labels
K8s-app:kube-dns
Version:v6
Kubernetes.io/cluster-service: "True"
Spec
Containers
-NAME:ETCD
image:index.tenxcloud.com/google_containers/etcd:2.0.9
Command
-/USR/LOCAL/BIN/ETCD
--listen-client-urls
-http://0.0.0.0:2379,http://0.0.0.0:4001
--advertise-client-urls
-http://127.0.0.1:2379,http://127.0.0.1:4001
-Name:kube2sky
image:index.tenxcloud.com/google_containers/kube2sky:1.11
Resources
Limits
cpu:100m
Memory:50mi
Command
-/kube2sky
---kube_master_url=http://192.168.11.10:8080
--domain=kube.local
-Name:skydns
image:index.tenxcloud.com/google_containers/skydns:2015-03-11-001
Resources
Command
-/skydns
--machines=http://localhost:4001
--addr=0.0.0.0:53
--domain=kube.local
Ports
-containerport:53
Name:dns
Protocol:udp
-containerport:53
Name:dns-tcp
Protocol:tcp
Dnspolicy:default
[Email protected] Master yaml]# cat Dns/kubedns-service.yaml
Apiversion:v1
Kind:service
Metadata
Name:kube-dns
Namespace:default
Labels
K8s-app:kube-dns
Kubernetes.io/cluster-service: "True"
Kubernetes.io/name: "Kubedns"
Spec
Selector
K8s-app:kube-dns
clusterip:10.254.0.10
Ports
-Name:dns
port:53
Protocol:udp
-Name:dns-tcp
port:53
Protocol:tcp
Attention:
(Pause is responsible for managing the pod's network and other related transactions: gcr.io/google_containers/pause-amd64:3.0)
Google is a wall and can be used in the following ways:
1. Turn over the wall or visit the domestic Docker mirror site to download the renamed
[[Email protected] Master yaml]# Docker pull mritd/pause-amd64:3.0
[[Email protected] Master yaml]# Docker tag mritd/pause-amd64:3.0 gcr.io/google_containers/pause-amd64:3.0
2. Using the internal private warehouse, add the following parameters to the Kubelet service process for each k8s node:
"--pod-infra-container-image=my.hub.io/pause-amd64:3.0"
>>> node Mirror list [ Mirror of Private warehouse recommended in real world ]:
# Docker images ( display content is easy to view, so incomplete)
GCR.IO/GOOGLE_CONTAINERS/PAUSE-AMD64 3.0
Index.tenxcloud.com/google_containers/kube2sky 1.11
Index.tenxcloud.com/google_containers/etcd 2.0.9
Index.tenxcloud.com/google_containers/skydns 2015-03-11-001
----------------------------------------------------
[[Email protected] Master yaml]# kubectl create-f dns/kubedns-rc.yaml --validate /Check the correctness of the file and create
[Email protected] Master yaml]# kubectl create-f Dns/kubedns-service.yaml
[[Email protected] Master yaml]# kubectl get RC
NAME Desired Current Age
KUBE-DNS-V6 1 1 38m
[[Email protected] Master yaml]# kubectl Get Svc
NAME cluster-ip external-ip PORT (S) Age
Kube-dns 10.254.0.10 <none> 53/udp,53/tcp 38m
Kubernetes 10.254.0.1 <none> 443/tcp 5h
[[Email protected] Master yaml]# kubectl get svc-o wide //-o wide parameter display details
NAME cluster-ip external-ip PORT (S) Age SELECTOR
Kube-dns 10.254.0.10 <none> 53/udp,53/tcp 2d K8s-app=kube-dns
Kubernetes 10.254.0.1 <none> 443/tcp 3d <none>
2. Test DNS for normal parsing:
First, create a pod named: Mysql-service Service and BusyBox, respectively.
[Email protected] Master yaml]# cat Mysql-server.yaml
Apiversion:v1
Kind:service
Metadata
Labels
Name:mysql
Role:service
Name:mysql-service
Spec
Type:nodeport
Ports
-port:3306
targetport:3306
nodeport:31000
Selector
Name:mysql
[Email protected] Master yaml]# cat Busybox.yaml
Apiversion:v1
Kind:pod
Metadata
Labels
Name:busybox
Role:master
Name:busybox
Spec
Containers
-Name:busybox
Image:busybox
Command
-Sleep
-"360000"
[Email protected] Master yaml]# kubectl create-f Mysql-server.yaml
[Email protected] Master yaml]# kubectl create-f Busybox.yaml
[[Email protected] Master yaml]# kubectl Get Svc
NAME cluster-ip external-ip PORT (S) Age
Kube-dns 10.254.0.10 <none> 53/udp,53/tcp 41m
Kubernetes 10.254.0.1 <none> 443/tcp 5h
Mysql-service 10.254.155.188 <nodes> 3306/tcp 41m
[[Email protected] Master yaml]# kubectl get pod-o Wide
NAME ready STATUS Restarts IP NODE
BusyBox 1/1 Running 0 2d 10.1.77.2 Node1
KUBE-DNS-V6-DFUCV 3/3 Running 0 2d 10.1.62.2 Node2
[[Email protected] Master yaml]# kubectl exec-i-t BusyBox sh
/# nslookup Mysql-service
server:10.254.0.10
Address 1:10.254.0.10
Name:mysql-service
Address 1:10.254.155.188
/# nslookup Mysql-service.default.kube.local
server:10.254.0.10
Address 1:10.254.0.10
Name:mysql-service.default.kube.local
Address 1:10.254.155.188
/# nslookup Mysql-service.default.svc.kube.local
server:10.254.0.10
Address 1:10.254.0.10
Name:mysql-service.default.svc.kube.local
Address 1:10.254.155.188
You can see Mysql-service, mysql-service.default.svc.kube.local, The domain name of the mysql-service.default.kube.local can be correctly parsed into the Mysql-service service of 10.254.155.188.
Mysql-service.default.kube.local is the full domain name, and its composition is <service-name>.<namespace>.<domain-name>
Extended command Operations < more command operations please KUBECTL--HELP or visit the Official KUBECTL command manual >
-# KUBECTL Get RC--namespace=kube-system query specified namespace
-# Kubectl Get pod--all-namespaces=true querying all namespaces
3. Finally, the principle of Kubernetes DNS is briefly introduced.
First, a DNS RC is created at deployment time, resulting in three containers (without pause)
[[email protected] Node2]# Docker ps-a//Run on Kubectl node based on Pod-o get wide node2 above
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
033800F393B9 index.alauda.cn/tutum/centos:centos6 "/run.sh" 3 days ago up 3 da Ys 22/tcp Awesome_newton
0FB60DCFB8B4 gcr.io/google_containers/etcd:2.0.9 "/usr/local/bin/etcd" 3 days ago up 3 da Ys K8S_ETCD.8D001F7F_KUBE-DNS-V6-JU8CB_DEFAULT_149FDBA5-4E50-11E6-BA47-0800273D5F3F_6AFE5C27
0A0EFD5F0AAA gcr.io/google_containers/skydns:2015-03-11-001 "/skydns-machines=ht" 3 days ago up 3 da Ys K8s_skydns.5d0f4a29_kube-dns-v6-ju8cb_default_149fdba5-4e50-11e6-ba47-0800273d5f3f_f7c4ee 06
cfef318e4032 gcr.io/google_containers/kube2sky:1.11 "/kube2sky--kube_mas" 3 days ago up 3 da Ys K8s_kube2sky.eb7ac18c_kube-dns-v6-ju8cb_default_149fdba5-4e50-11e6-ba47-0800273d5f3f_19b7 9770
Afad7b2ebd3d docker.io/kubernetes/pause "/pause" 3 days ago up 3 da Ys k8s_pod.87e723e6_kube-dns-v6-ju8cb_default_149fdba5-4e50-11e6-ba47-0800273d5f3f_3c3f7c87
"DNS parsing process"
In the pod that you created, you can view the domain name resolution server that it uses:
[[email protected]]# kubectl exec-i-t BusyBox sh
/# cat/etc/resolv.conf
Search Default.svc.kube.local svc.kube.local kube.local
NameServer 10.254.0.10
Options Ndots:5
When the pod is created in Kubelet, the-cluster_dns=10.254.0.10--cluster_domain=kube.local configured for Kubelet is used, and the corresponding DNS server is used in the pod created.
And this DNS resolution service is actually done by the gcr.io/google_containers/skydns:2015-03-11-001 container 0a0efd5f0aaa in the RC of the DNS.
The Skydns data source is from the gcr.io/google_containers/etcd:2.0.9 container 0fb60dcfb8b4.
[Email protected] Node2]# Docker exec-it 0fb etcdctl get/skydns/local/kube/svc/default/mysql-service/2f1020d6
{"Host": "10.254.162.44", "priority": Ten, "Weight": Ten, "ttl": "0", "Targetstrip"
[email protected] node2]# Docker exec-it 0fb etcdctl Get/skydns/local/kube/default/mysql-service
{"Host": "10.254.162.44", "priority": Ten, "Weight": Ten, "ttl": "0", "Targetstrip"
"Service synchronization Process"
The ETCD data is derived from the cfef318e4032 container created by gcr.io/google_containers/kube2sky:1.11.
The cfef318e4032 container looks at service changes through Watch KUBE-API service.
When the service is created/deleted/modified, the cfef318e4032 container obtains the corresponding service information and stores it in the Etcd container 0fb60dcfb8b4, which is then provided for SKYDNS use.
This article is from the "Jevic" blog, make sure to keep this source http://jevic.blog.51cto.com/2183736/1881898
Kubernetes Basics-Configuring Kubernetes Skydns Services