Open Source- CoreDNS — 008. «DNS-, (middleware), - DNS». , CoreDNS CNCF (Cloud Native Computing Foundation), Kubernetes, Prometheus, CNI, containerd, rkt , , « » (cloud native).
CoreDNS, ?
CoreDNS
CoreDNS — DNS-, 2016 ( Apache License v2) - Caddy, Go. HTTP- Caddy httpserver, Handler ( HTTP-) Middleware ( , Handler , — ). CoreDNS, : «CoreDNS — DNS-, middleware».
CoreDNS SkyDNS — service discovery, NoSQL- etcd DNS- ( SRV-) . SkyDNS etcd, , DNS-, «» . , SkyDNS 7 ( etcd 3) , CoreDNS .
CoreDNS etcd , DNS-. Kubernetes (, , , etcd… ), CoreDNS kube-dns. ( , , .)
: DNS-: SkyDNS, CoreDNS, kube-dns — , . , , -, kube-dns SkyDNS DNS-, Kubernetes. -, CoreDNS SkyDNS — Miek Gieben — SRE Google, Go DNS-. CoreDNS «» kube-dns, .
CoreDNS
UDP/TCP, TLS (RFC 7858) gRPC. :
- DNS-, (DNS DNSSEC) ;
- DNS- ( AXFR);
- ( ).
CoreDNS:
- ;
- rewrite (qtype, qclass, qname);
- ;
- (health checking) ;
- Prometheus;
- ;
- .
( ) , ( Caddy/CoreDNS) — middleware. , middleware.
CoreDNS, middleware
John Belamaric, Infoblox CoreDNS, :
DNS-, , DNS. CoreDNS , . , cloud-native.
CoreDNS CNCF?
:
— CoreDNS DNS- service discovery cloud-native. CNCF cloud-native. , [ ]. — CNCF, CoreDNS .
CNCF Chris Aniszczyk (COO CNCF), , «CoreDNS cloud-native CNCF», «CoreDNS — Kubernetes».
: CoreDNS (inception) CNCF, : , , incubating graduated.
.
CoreDNS Service Discovery Kubernetes
, CoreDNS kube-dns — Kubernetes, . — , Service Discovery DNS Kubernetes. , « Kube-DNS CoreDNS». 1.0.0 kube-dns — CoreDNS 005 (, , , kube-dns).
CoreDNS Service Discovery Kubernetes, (
ConfigMap
Deployment
) Bash- deploy.sh . , ( ):
$ ./deploy.sh 10.3.0.0/24 cluster.local
-
10.3.0.0/24
— CIDRs ; -
cluster.local
( ) — .
:
apiVersion: v1 kind: ConfigMap metadata: name: coredns namespace: kube-system data: Corefile: | .:53 { errors log stdout health kubernetes cluster.local { cidrs 10.3.0.0/24 } proxy . /etc/resolv.conf cache 30 } --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: coredns namespace: kube-system labels: k8s-app: coredns kubernetes.io/cluster-service: "true" kubernetes.io/name: "CoreDNS" spec: replicas: 1 selector: matchLabels: k8s-app: coredns template: metadata: labels: k8s-app: coredns annotations: scheduler.alpha.kubernetes.io/critical-pod: '' scheduler.alpha.kubernetes.io/tolerations: '[{"key":"CriticalAddonsOnly", "operator":"Exists"}]' spec: containers: - name: coredns image: coredns/coredns:latest imagePullPolicy: Always args: [ "-conf", "/etc/coredns/Corefile" ] volumeMounts: - name: config-volume mountPath: /etc/coredns ports: - containerPort: 53 name: dns protocol: UDP - containerPort: 53 name: dns-tcp protocol: TCP livenessProbe: httpGet: path: /health port: 8080 scheme: HTTP initialDelaySeconds: 60 timeoutSeconds: 5 successThreshold: 1 failureThreshold: 5 dnsPolicy: Default volumes: - name: config-volume configMap: name: coredns items: - key: Corefile path: Corefile --- apiVersion: v1 kind: Service metadata: name: kube-dns namespace: kube-system labels: k8s-app: coredns kubernetes.io/cluster-service: "true" kubernetes.io/name: "CoreDNS" spec: selector: k8s-app: coredns clusterIP: 10.3.0.10 ports: - name: dns port: 53 protocol: UDP - name: dns-tcp port: 53 protocol: TCP
(
Corefile
)
cidrs 10.3.0.0/24
Kubernetes middleware CoreDNS, PTR-
0.3.10.in-addr.arpa
.
Kubernetes:
$ ./deploy.sh 10.3.0.0/24 | kubectl apply -f -
configmap "coredns" created
deployment "coredns" created
service "kube-dns" configured
… , DNS- :
$ kubectl run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools
Waiting for pod default/dnstools to be running, status is Pending, pod ready: false
If you don't see a command prompt, try pressing enter.
# host kubernetes
kubernetes.default.svc.cluster.local has address 10.3.0.1
# host kube-dns.kube-system
kube-dns.kube-system.svc.cluster.local has address 10.3.0.10
# host 10.3.0.1
1.0.3.10.in-addr.arpa domain name pointer kubernetes.default.svc.cluster.local.
# host 10.3.0.10
10.0.3.10.in-addr.arpa domain name pointer kube-dns.kube-system.svc.cluster.local.
CoreDNS? CoreDNS, DNS-:
# CoreDNS
$ kubectl get --namespace kube-system pods
NAME READY STATUS RESTARTS AGE
coredns-3558181428-0zhnh 1/1 Running 0 2m
coredns-3558181428-xri9i 1/1 Running 0 2m
heapster-v1.2.0-4088228293-a8gkc 2/2 Running 0 126d
kube-apiserver-10.222.243.77 1/1 Running 2 126d
kube-controller-manager-10.222.243.77 1/1 Running 2 126d
kube-proxy-10.222.243.77 1/1 Running 2 126d
kube-proxy-10.222.243.78 1/1 Running 0 126d
kube-scheduler-10.222.243.77 1/1 Running 2 126d
kubernetes-dashboard-v1.4.1-gi2xr 1/1 Running 0 24d
tiller-deploy-3299276078-e8phb 1/1 Running 0 24d
#
$ kubectl logs --namespace kube-system coredns-3558181428-0zhnh
2017/02/23 14:48:29 [INFO] Kubernetes middleware configured without a label selector. No label-based filtering will be performed.
.:53
2017/02/23 14:48:29 [INFO] CoreDNS-005
CoreDNS-005
10.2.6.127 - [23/Feb/2017:14:49:44 +0000] "AAAA IN kubernetes.default.svc.cluster.local. udp 54 false 512" NOERROR 107 544.128µs
10.2.6.127 - [23/Feb/2017:14:49:44 +0000] "MX IN kubernetes.default.svc.cluster.local. udp 54 false 512" NOERROR 107 7.576897ms
10.2.6.127 - [23/Feb/2017:14:49:52 +0000] "A IN kube-dns.kube-system.default.svc.cluster.local. udp 64 false 512" NXDOMAIN 117 471.176µs
23/Feb/2017:14:49:52 +0000 [ERROR 0 kube-dns.kube-system.default.svc.cluster.local. A] no items found
10.2.6.127 - [23/Feb/2017:14:50:00 +0000] "PTR IN 10.0.3.10.in-addr.arpa. udp 40 false 512" NOERROR 92 752.956µs
#
$ kubectl logs --namespace kube-system coredns-3558181428-xri9i
2017/02/23 14:48:29 [INFO] Kubernetes middleware configured without a label selector. No label-based filtering will be performed.
.:53
2017/02/23 14:48:29 [INFO] CoreDNS-005
CoreDNS-005
10.2.6.127 - [23/Feb/2017:14:49:44 +0000] "A IN kubernetes.default.svc.cluster.local. udp 54 false 512" NOERROR 70 1.10732ms
10.2.6.127 - [23/Feb/2017:14:49:52 +0000] "A IN kube-dns.kube-system.svc.cluster.local. udp 56 false 512" NOERROR 72 409.74µs
10.2.6.127 - [23/Feb/2017:14:49:52 +0000] "AAAA IN kube-dns.kube-system.svc.cluster.local. udp 56 false 512" NOERROR 109 210.817µs
10.2.6.127 - [23/Feb/2017:14:49:52 +0000] "MX IN kube-dns.kube-system.svc.cluster.local. udp 56 false 512" NOERROR 109 796.703µs
10.2.6.127 - [23/Feb/2017:14:49:56 +0000] "PTR IN 1.0.3.10.in-addr.arpa. udp 39 false 512" NOERROR 89 694.649µs
DNS- ( )
log stdout
Corefile
.
: , Google Container Engine (GKE) - , kube-dns. , /.
CoreDNS Minikube
Kubernetes Minikube : addon manager ( ) , kube-dns. CoreDNS, .
, minikube:
$ minikube addons list
- dashboard: enabled
- default-storageclass: enabled
- kube-dns: enabled
- heapster: disabled
- ingress: disabled
- registry-creds: disabled
- addon-manager: enabled
$ minikube addons disable kube-dns
kube-dns was successfully disabled
$ minikube addons list
- heapster: disabled
- ingress: disabled
- registry-creds: disabled
- addon-manager: enabled
- dashboard: enabled
- default-storageclass: enabled
- kube-dns: disabled
CoreDNS Kubernetes (..
kubectl apply -f
).
ReplicationController
kube-dns, :
$ kubectl get -n kube-system pods
NAME READY STATUS RESTARTS AGE
coredns-980047985-g2748 1/1 Running 1 36m
kube-addon-manager-minikube 1/1 Running 0 9d
kube-dns-v20-qzvr2 3/3 Running 0 1m
kubernetes-dashboard-ks1jp 1/1 Running 0 9d
$ kubectl delete -n kube-system rc kube-dns-v20
replicationcontroller "kube-dns-v20" deleted
CoreDNS — , ( SkyDNS), (Kubernetes Go), CNCF , , .
:
- « service mesh [ ]?» ( linkerd — CNCF);
- «Container Networking Interface (CNI) — Linux-» ( CNCF);
- « Kubernetes ( )» ( Kubernetes ).