CoreDNS:  k8s内部的DNS ,用于对pod对service做记录的,好让其他的pod做访问

这里不用做过多的阐述

官方kube-dns现在已经没有在维护了,从Kubernetes 1.11开始,可使用CoreDNS作为Kubernetes的DNS插件进入GA状态,Kubernetes推荐使用CoreDNS作为集群内的DNS服务。 CoreDNS从2017年初就成为了CNCF的的孵化项目,CoreDNS的特点就是十分灵活和可扩展的插件机制,各种插件实现

vim coredns.yaml

apiVersion: v1

kind: ServiceAccount

metadata:

name: coredns

namespace: kube-system

labels:

kubernetes.io/cluster-service: "true"

addonmanager.kubernetes.io/mode: Reconcile

---

apiVersion: rbac.authorization.k8s.io/v1

kind: ClusterRole

metadata:

labels:

kubernetes.io/bootstrapping: rbac-defaults

addonmanager.kubernetes.io/mode: Reconcile

name: system:coredns

rules:

- apiGroups:

- ""

resources:

- endpoints

- services

- pods

- namespaces

verbs:

- list

- watch

---

apiVersion: rbac.authorization.k8s.io/v1

kind: ClusterRoleBinding

metadata:

annotations:

rbac.authorization.kubernetes.io/autoupdate: "true"

labels:

kubernetes.io/bootstrapping: rbac-defaults

addonmanager.kubernetes.io/mode: EnsureExists

name: system:coredns

roleRef:

apiGroup: rbac.authorization.k8s.io

kind: ClusterRole

name: system:coredns

subjects:

- kind: ServiceAccount

name: coredns

namespace: kube-system

---

apiVersion: v1

kind: ConfigMap

metadata:

name: coredns

namespace: kube-system

labels:

addonmanager.kubernetes.io/mode: EnsureExists

data:

Corefile: |

.:53 {

errors

health

kubernetes cluster.local in-addr.arpa ip6.arpa {

pods insecure

upstream

fallthrough in-addr.arpa ip6.arpa

}

prometheus :9153

proxy . /etc/resolv.conf

cache 30

loop

reload

loadbalance

}

---

apiVersion: extensions/v1beta1

kind: Deployment

metadata:

name: coredns

namespace: kube-system

labels:

k8s-app: kube-dns

kubernetes.io/cluster-service: "true"

addonmanager.kubernetes.io/mode: Reconcile

kubernetes.io/name: "CoreDNS"

spec:

# replicas: not specified here:

# 1. In order to make Addon Manager do not reconcile this replicas parameter.

# 2. Default is 1.

# 3. Will be tuned in real time if DNS horizontal auto-scaling is turned on.

strategy:

type: RollingUpdate

rollingUpdate:

maxUnavailable: 1

selector:

matchLabels:

k8s-app: kube-dns

template:

metadata:

labels:

k8s-app: kube-dns

annotations:

seccomp.security.alpha.kubernetes.io/pod: 'docker/default'

spec:

serviceAccountName: coredns

tolerations:

- key: node-role.kubernetes.io/master

effect: NoSchedule

- key: "CriticalAddonsOnly"

operator: "Exists"

containers:

- name: coredns

image: coredns/coredns:1.2.2

imagePullPolicy: IfNotPresent

resources:

limits:

memory: 170Mi

requests:

cpu: 100m

memory: 70Mi

args: [ "-conf", "/etc/coredns/Corefile" ]

volumeMounts:

- name: config-volume

mountPath: /etc/coredns

readOnly: true

ports:

- containerPort: 53

name: dns

protocol: UDP

- containerPort: 53

name: dns-tcp

protocol: TCP

- containerPort: 9153

name: metrics

protocol: TCP

livenessProbe:

httpGet:

path: /health

port: 8080

scheme: HTTP

initialDelaySeconds: 60

timeoutSeconds: 5

successThreshold: 1

failureThreshold: 5

securityContext:

allowPrivilegeEscalation: false

capabilities:

add:

- NET_BIND_SERVICE

drop:

- all

readOnlyRootFilesystem: true

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

annotations:

prometheus.io/port: "9153"

prometheus.io/scrape: "true"

labels:

k8s-app: kube-dns

kubernetes.io/cluster-service: "true"

addonmanager.kubernetes.io/mode: Reconcile

kubernetes.io/name: "CoreDNS"

spec:

selector:

k8s-app: kube-dns

clusterIP: 10.0.0.2

ports:

- name: dns

port: 53

protocol: UDP

- name: dns-tcp

port: 53

protocol: TCP

[root@k8s-master ~]# kubectl create -f coredns.yaml

[root@k8s-master ~]# kubectl get pod,svc,deployment,rc -n kube-system

NAME                           READY   STATUS    RESTARTS   AGE

pod/coredns-5d7754fbcb-hm6vq   1/1     Running   0          3m36s

NAME               TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)         AGE

service/kube-dns   ClusterIP   10.0.0.2     <none>        53/UDP,53/TCP   97s

NAME                            READY   UP-TO-DATE   AVAILABLE   AGE

deployment.extensions/coredns   1/1     1            1           3m36s

最新文章

  1. [LeetCode] Implement Trie (Prefix Tree) 实现字典树(前缀树)
  2. MySQL 子查询与连接操作笔记
  3. Handlebars.js循环中索引(@index)使用技巧(访问父级索引)
  4. f
  5. .Net内存优化的几点经验
  6. Facade模式
  7. 在ASP.NET MVC中使用MySQL【并使用membership】
  8. 【高德地图API】如何解决坐标转换,坐标偏移?
  9. Qt 界面使用自己定义控件 &amp;quot;提升为&amp;quot;
  10. linux shell编程指南第十一章------------合并与分割2
  11. frame.bounds和center
  12. Python+Requests接口测试教程(1):Fiddler抓包工具
  13. Asp.net MVC在Razor中输出Html的两种方式
  14. 47.Odoo产品分析 (五) – 定制板块(2) – 为业务自定义odoo(2)
  15. python 标准库 glob ,python glob 学习
  16. java爬虫代理
  17. C和 C++的特点
  18. sql拼接显示table的多个列
  19. python-时间模块,random、os、sys、shutil、json和pickle模块
  20. matlab中mat文件简单存/取

热门文章

  1. PDCA
  2. Docker(一):Docker安装
  3. Redis安装教程及安装报错解决方案(大佬勿喷)
  4. Linux vmstat 使用说明
  5. 拥抱云原生,如何将开源项目用k8s部署?
  6. 一个简单的CSS示例
  7. C#访问Access数据库提示未安装ISAM
  8. 简单谈谈contextlib的使用
  9. SonarQube学习(一)- 使用Docker安装SonarQube(亲测可用)
  10. windows使用git bash 无法交互键盘上下键移动选择选项的解决方法