coredns 排错记

简介: 核心链接https://kubernetes.io/docs/ta...

核心链接


https://kubernetes.io/docs/ta...


CoreDNS 安装

apiVersion: v1
kind: ServiceAccount
metadata:
  name: coredns
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  labels:
    kubernetes.io/bootstrapping: rbac-defaults
  name: system:coredns
rules:
- apiGroups:
  - ""
  resources:
  - endpoints
  - services
  - pods
  - namespaces
  verbs:
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  annotations:
    rbac.authorization.kubernetes.io/autoupdate: "true"
  labels:
    kubernetes.io/bootstrapping: rbac-defaults
  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
data:
  Corefile: |
    .:53 {
        log
        errors
        health
        kubernetes cluster.local 172.0.0.0/8 in-addr.arpa ip6.arpa {
          pods insecure
          upstream
          fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        proxy . /etc/resolv.conf
        cache 30
        reload
    }
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: coredns
  namespace: kube-system
  labels:
    k8s-app: coredns
    kubernetes.io/name: "CoreDNS"
spec:
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
  selector:
    matchLabels:
      k8s-app: coredns
  template:
    metadata:
      labels:
        k8s-app: coredns
    spec:
      serviceAccountName: coredns
      tolerations:
        - key: "CriticalAddonsOnly"
          operator: "Exists"
      containers:
      - name: coredns
        image: hub.issll.com/kubernetes/coredns:1.1.0
        imagePullPolicy: IfNotPresent
        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: 8081
            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: 172.21.0.2
  ports:
  - name: dns
    port: 53
    protocol: UDP
  - name: dns-tcp
    port: 53
    protocol: TCP

在master结点上执行

kubectl apply -f coredns.yaml


主要修改文件


nodes结点上的/etc/resolv.conf

$ cat /etc/resolv.conf 
    # Generated by NetworkManager
    search default.svc.cluster.local middleware.svc.cluster.local svc.cluster.local cluster.local
    nameserver 192.168.1.254


打印每个pods上的出错日志

for p in $(kubectl get pods --namespace=kube-system -l k8s-app=coredns -o name); do kubectl logs --namespace=kube-system $p; done


用busybox 检验coredns解析效果

 

kubectl exec -ti busybox -- nslookup redis-master

因为结点上的search 域的设定,等于

kubectl exec -ti busybox -- nslookup redis-master.middleware.svc.cluster.local

这里 redis-master 是布署在 middleware 命名空间下的一个pod


CoreDNS 已知 Bug

重新加载时,在启动新服务器实例之前停止运行状况处理程序。如果新服务器无法启动,则初始服务器实例仍然可用且仍然提供DNS查询,但Health处理程序保持关闭状态。在成功重新加载或完全重新启动CoreDNS之前,Health运行状况不会回复HTTP请求。


后记


在新 pod 创建后, CoreDNS 更新有问题, 需要解决

相关文章
下载整个Yum源的所有安装包到本地指定目录
下载整个Yum源的所有安装包到本地指定目录
2282 0
|
12月前
|
存储 IDE 开发工具
ESXi 8.0 中已弃用且不受支持的设备 (88172) | Devices deprecated and unsupported in ESXi 8.0
ESXi 8.0 中已弃用且不受支持的设备 (88172) | Devices deprecated and unsupported in ESXi 8.0
442 19
|
Prometheus Kubernetes 网络协议
k8s学习笔记之CoreDNS
k8s学习笔记之CoreDNS
【qt】 QGridLayout布局管理器怎么用?
【qt】 QGridLayout布局管理器怎么用?
672 0
|
算法 物联网 5G
UWB定位的7种算法
UWB定位系统基于超宽带技术,通过纳秒级脉冲实现高精度厘米级甚至毫米级定位。其7种主要算法包括:1) TOA(到达时间),利用信号传播时间计算距离;2) TDOA(到达时间差),通过多个基站的时间差确定位置;3) RSSI(接收信号强度),估算距离但精度较低;4) AOA(角度到达),测量信号入射角度;5) 混合算法,结合多种算法提高精度;6) 最小二乘法,处理多基站数据减少误差;7) 卡尔曼滤波,动态跟踪目标位置;8) 粒子滤波,适应复杂非线性环境。这些算法各具特点,适用于不同场景,如工业制造、智能仓储和室内定位等。
1173 11
|
数据安全/隐私保护 Docker 容器
配置Harbor支持https功能实战篇
关于如何配置Harbor支持HTTPS功能的详细教程。
1071 13
配置Harbor支持https功能实战篇
|
存储 Docker 容器
入职必会-开发环境搭建50-Docker必会搭建Docker私有仓库
Docker官方的Docker hub(https://hub.docker.com)是一个用于管理公共镜像的仓库,我们可以从上面拉取镜像到本地也可以把我们自己的镜像推送上去。但是有时候我们的服务器无法访问互联网或者不希望将自己的镜像放到公网当中,那么我们就需要搭建自己的Docker私有仓库来存储和管理自己的Docker镜像。
320 1
入职必会-开发环境搭建50-Docker必会搭建Docker私有仓库
|
Linux Docker Windows
Docker配置https证书案例
本文介绍了如何为Docker的Harbor服务配置HTTPS证书,包括安装Docker和Harbor、修改配置文件以使用证书、生成自签名证书、配置证书以及验证配置的步骤。
1405 3
Docker配置https证书案例
|
并行计算 Serverless 应用服务中间件
函数计算操作报错合集之部署Stable Diffusion启动失败,是什么导致的
Serverless 应用引擎(SAE)是阿里云提供的Serverless PaaS平台,支持Spring Cloud、Dubbo、HSF等主流微服务框架,简化应用的部署、运维和弹性伸缩。在使用SAE过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
727 7
|
Kubernetes 负载均衡 网络协议
在K8S中,Service的类型有哪些?
在K8S中,Service的类型有哪些?