apiVersion: v1 kind: ServiceAccount metadata: name: cluster-dns namespace: kube-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: cluster-dns rules: - apiGroups: - "" resources: - endpoints - services - pods - namespaces verbs: - list - watch - apiGroups: - discovery.k8s.io resources: - endpointslices verbs: - list - watch --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: cluster-dns roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-dns subjects: - kind: ServiceAccount name: cluster-dns namespace: kube-system --- apiVersion: v1 kind: ConfigMap metadata: name: dns-config namespace: kube-system data: Corefile: | .:53 { errors health ready kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } hosts /etc/coredns/NodeHosts { ttl 60 reload 15s fallthrough } prometheus :9153 cache 30 loop reload loadbalance import /etc/coredns/custom/*.override forward . /etc/resolv.conf } import /etc/coredns/custom/*.server NodeHosts: | 10.210.99.194 ********-n100 10.133.210.151 ********-opi5p 10.149.70.251 ********-2697 10.100.10.13 ********-y520 10.151.204.207 ********-nas --- apiVersion: v1 kind: Service metadata: name: kube-dns namespace: kube-system labels: k8s-app: kube-dns kubernetes.io/cluster-service: "true" kubernetes.io/name: CoreDNS spec: clusterIP: 10.97.104.110 ports: - name: dns port: 53 protocol: UDP targetPort: 53 - name: dns-tcp port: 53 protocol: TCP targetPort: 53 - name: metrics port: 9153 protocol: TCP targetPort: 9153 selector: k8s-app: kube-dns --- apiVersion: apps/v1 kind: Deployment metadata: name: cluster-dns namespace: kube-system labels: k8s-app: kube-dns kubernetes.io/name: CoreDNS spec: replicas: 2 revisionHistoryLimit: 0 selector: matchLabels: k8s-app: kube-dns strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 1 type: RollingUpdate template: metadata: labels: k8s-app: kube-dns spec: containers: - name: coredns image: rancher/mirrored-coredns-coredns:1.15.0@sha256:0a9d8c8ddf34347eb59aad9a8784f0710de88d6d112726d11d271f9bc6daca26 imagePullPolicy: IfNotPresent args: - -conf - /etc/coredns/Corefile ports: - containerPort: 53 name: dns protocol: UDP - containerPort: 53 name: dns-tcp protocol: TCP - containerPort: 9153 name: metrics protocol: TCP livenessProbe: failureThreshold: 3 httpGet: path: /health port: 8080 scheme: HTTP initialDelaySeconds: 60 periodSeconds: 10 timeoutSeconds: 1 readinessProbe: failureThreshold: 3 httpGet: path: /ready port: 8181 scheme: HTTP periodSeconds: 2 timeoutSeconds: 1 resources: limits: memory: 170Mi requests: cpu: 100m memory: 70Mi securityContext: allowPrivilegeEscalation: false capabilities: add: - NET_BIND_SERVICE drop: - all readOnlyRootFilesystem: true volumeMounts: - mountPath: /etc/coredns name: config-volume readOnly: true - mountPath: /etc/coredns/custom name: custom-config-volume readOnly: true dnsPolicy: Default nodeSelector: kubernetes.io/os: linux priorityClassName: system-cluster-critical serviceAccountName: cluster-dns terminationGracePeriodSeconds: 30 tolerations: - key: CriticalAddonsOnly operator: Exists - effect: NoSchedule key: node-role.kubernetes.io/control-plane operator: Exists topologySpreadConstraints: - labelSelector: matchLabels: k8s-app: kube-dns maxSkew: 1 topologyKey: kubernetes.io/hostname whenUnsatisfiable: DoNotSchedule - labelSelector: matchLabels: k8s-app: kube-dns maxSkew: 1 topologyKey: topology.kubernetes.io/zone whenUnsatisfiable: ScheduleAnyway volumes: - configMap: items: - key: Corefile path: Corefile - key: NodeHosts path: NodeHosts name: dns-config name: config-volume - configMap: name: coredns-custom optional: true name: custom-config-volume --- apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: cluster-dns namespace: kube-system spec: minAvailable: 1 selector: matchLabels: k8s-app: kube-dns