Kubernetes1.15 部署 coredns

coredns.yaml文件如下所示

1# __MACHINE_GENERATED_WARNING__ 2 3apiVersion: v1 4kind: ServiceAccount 5metadata: 6 name: coredns 7 namespace: kube-system 8 labels: 9 kubernetes.io/cluster-service: "true" 10 addonmanager.kubernetes.io/mode: Reconcile 11--- 12apiVersion: rbac.authorization.k8s.io/v1 13kind: ClusterRole 14metadata: 15 labels: 16 kubernetes.io/bootstrapping: rbac-defaults 17 addonmanager.kubernetes.io/mode: Reconcile 18 name: system:coredns 19rules: 20- apiGroups: 21 - "" 22 resources: 23 - endpoints 24 - services 25 - pods 26 - namespaces 27 verbs: 28 - list 29 - watch 30- apiGroups: 31 - "" 32 resources: 33 - nodes 34 verbs: 35 - get 36--- 37apiVersion: rbac.authorization.k8s.io/v1 38kind: ClusterRoleBinding 39metadata: 40 annotations: 41 rbac.authorization.kubernetes.io/autoupdate: "true" 42 labels: 43 kubernetes.io/bootstrapping: rbac-defaults 44 addonmanager.kubernetes.io/mode: EnsureExists 45 name: system:coredns 46roleRef: 47 apiGroup: rbac.authorization.k8s.io 48 kind: ClusterRole 49 name: system:coredns 50subjects: 51- kind: ServiceAccount 52 name: coredns 53 namespace: kube-system 54--- 55apiVersion: v1 56kind: ConfigMap 57metadata: 58 name: coredns 59 namespace: kube-system 60 labels: 61 addonmanager.kubernetes.io/mode: EnsureExists 62data: 63 Corefile: | 64 .:53 { 65 errors 66 health 67 kubernetes cluster.local in-addr.arpa ip6.arpa { 68 pods insecure 69 upstream 70 fallthrough in-addr.arpa ip6.arpa 71 ttl 30 72 } 73 prometheus :9153 74 forward . /etc/resolv.conf 75 cache 30 76 loop 77 reload 78 loadbalance 79 } 80--- 81apiVersion: apps/v1 82kind: Deployment 83metadata: 84 name: coredns 85 namespace: kube-system 86 labels: 87 k8s-app: kube-dns 88 kubernetes.io/cluster-service: "true" 89 addonmanager.kubernetes.io/mode: Reconcile 90 kubernetes.io/name: "CoreDNS" 91spec: 92 # replicas: not specified here: 93 # 1. In order to make Addon Manager do not reconcile this replicas parameter. 94 # 2. Default is 1. 95 # 3. Will be tuned in real time if DNS horizontal auto-scaling is turned on. 96 strategy: 97 type: RollingUpdate 98 rollingUpdate: 99 maxUnavailable: 1 100 selector: 101 matchLabels: 102 k8s-app: kube-dns 103 template: 104 metadata: 105 labels: 106 k8s-app: kube-dns 107 annotations: 108 seccomp.security.alpha.kubernetes.io/pod: 'docker/default' 109 spec: 110 priorityClassName: system-cluster-critical 111 serviceAccountName: coredns 112 tolerations: 113 - key: "CriticalAddonsOnly" 114 operator: "Exists" 115 nodeSelector: 116 beta.kubernetes.io/os: linux 117 containers: 118 - name: coredns 119 image: k8s.gcr.io/coredns:1.3.1 120 imagePullPolicy: IfNotPresent 121 resources: 122 limits: 123 memory: 70Mi 124 requests: 125 cpu: 100m 126 memory: 70Mi 127 args: [ "-conf", "/etc/coredns/Corefile" ] 128 volumeMounts: 129 - name: config-volume 130 mountPath: /etc/coredns 131 readOnly: true 132 ports: 133 - containerPort: 53 134 name: dns 135 protocol: UDP 136 - containerPort: 53 137 name: dns-tcp 138 protocol: TCP 139 - containerPort: 9153 140 name: metrics 141 protocol: TCP 142 livenessProbe: 143 httpGet: 144 path: /health 145 port: 8080 146 scheme: HTTP 147 initialDelaySeconds: 60 148 timeoutSeconds: 5 149 successThreshold: 1 150 failureThreshold: 5 151 readinessProbe: 152 httpGet: 153 path: /health 154 port: 8080 155 scheme: HTTP 156 securityContext: 157 allowPrivilegeEscalation: false 158 capabilities: 159 add: 160 - NET_BIND_SERVICE 161 drop: 162 - all 163 readOnlyRootFilesystem: true 164 dnsPolicy: Default 165 volumes: 166 - name: config-volume 167 configMap: 168 name: coredns 169 items: 170 - key: Corefile 171 path: Corefile 172--- 173apiVersion: v1 174kind: Service 175metadata: 176 name: kube-dns 177 namespace: kube-system 178 annotations: 179 prometheus.io/port: "9153" 180 prometheus.io/scrape: "true" 181 labels: 182 k8s-app: kube-dns 183 kubernetes.io/cluster-service: "true" 184 addonmanager.kubernetes.io/mode: Reconcile 185 kubernetes.io/name: "CoreDNS" 186spec: 187 selector: 188 k8s-app: kube-dns 189 clusterIP: 10.0.0.2 190 ports: 191 - name: dns 192 port: 53 193 protocol: UDP 194 - name: dns-tcp 195 port: 53 196 protocol: TCP 197 - name: metrics 198 port: 9153 199 protocol: TCP

修改以上yaml文件中红色部分修改成自己对于的信息

kubectl apply -f coredns.yaml

执行apply  生成pod(需要替换镜像,不然会拉取失败)

1[root@k8s-master yaml]# kubectl get all -n kube-system | grep coredns 2pod/coredns-867ccfd476-9ghff 1/1 Running 13 42h 3pod/coredns-867ccfd476-p5md4 1/1 Running 15 42h 4deployment.apps/coredns 2/2 2 2 44h 5replicaset.apps/coredns-867ccfd476 2 2 2 44h 6[root@k8s-master yaml]#

创建测试的pod

1[root@k8s-master test]# cat my-apache.yaml 2apiVersion: extensions/v1beta1 3kind: Deployment 4metadata: 5 name: my-apache 6spec: 7 replicas: 2 8 template: 9 metadata: 10 labels: 11 run: my-apache 12 spec: 13 containers: 14 - name: my-apache 15 image: httpd:2.4 16 ports: 17 - containerPort: 80 18 19--- 20apiVersion: v1 21kind: Service 22metadata: 23 name: my-apache 24 labels: 25 run: my-apache 26spec: 27 type: NodePort 28 ports: 29 - port: 80 30 targetPort: 80 31 nodePort: 30002 32 selector: 33 run: my-apache

生成pod

[root@k8s-master test]# kubectl apply -f my-apache.yaml

查看pod运行状态

1[root@k8s-master test]# kubectl get pod 2NAME READY STATUS RESTARTS AGE 3my-apache-75f574f468-8psfw 1/1 Running 1 24h 4my-apache-75f574f468-msrrn 1/1 Running 0 24h 5[root@k8s-master test]#

已经全部运行

1[root@k8s-master test]# kubectl get svc 2NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE 3kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 2d 4my-apache NodePort 10.0.0.71 <none> 80:30002/TCP 24h 5[root@k8s-master test]# curl 10.0.0.71 6<html><body><h1>It works!</h1></body></html> 7[root@k8s-master test]#

由此可见dns服务是可用的

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )