博客
关于我
CoreDNS介绍
阅读量:421 次
发布时间:2019-03-06

本文共 1359 字,大约阅读时间需要 4 分钟。

CoreDNS配置与验证指南

busybox的槽点

在开始使用CoreDNS之前,确保你的环境配置正确是关键。某些工具如busybox的nslookup命令可能会给你带来不便。例如,运行以下命令可能会返回错误信息:

kubectl run busybox1 --rm -it --image=docker.io/busybox /bin/sh

如果发现nslookup命令无法正常查询到kubernetes.default,尝试使用更现代化的dig命令进行验证:

kubectl run dig --rm -it --image=docker.io/azukiapp/dig /bin/sh

通过dig命令可以更直观地观察DNS解析情况。


CoreDNS概述

CoreDNS自Kubernetes 1.11版本起正式GA发布,取代了传统的kube-dns,成为Kubernetes生态系统的默认DNS解决方案。CoreDNS支持与Kubernetes服务集成,能够自动处理Cluster Domain和Service CIDR配置。


配置文件解析

CoreDNS的配置主要通过ConfigMap进行管理。默认配置文件如下:

# kubectl -n kube-system get configmap coredns -oyamlapiVersion: v1data:  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        reload    }

配置选项说明

项目 含义
errors 记录DNS解析错误信息
health 提供健康检查端口(http://localhost:8080/health)
kubernetes 自动解析Kubernetes服务域名和IP范围,默认为cluster.local10.95.0.0/12
prometheus 启用Prometheus监控(默认端口:9153)
proxy 使用宿主机resolv.conf解析未知域名
cache DNS缓存时间(30秒)
reload 配置更改后自动重新加载CoreDNS

检查CoreDNS运行状态

确保CoreDNS组件正常运行是验证配置的关键步骤。

查看Pod状态

kubectl -n kube-system get pods -o wide

查看部署状态

kubectl -n kube-system get deployments

参考资料

  • Kubernetes官方文档:CoreDNS配置
  • CoreDNS GitHub仓库:CoreDNS源码
  • Kubernetes Best Practices:DNS配置
  • 转载地址:http://jqrkz.baihongyu.com/

    你可能感兴趣的文章
    Nginx配置参数中文说明
    查看>>
    Nio ByteBuffer组件读写指针切换原理与常用方法
    查看>>
    NIO Selector实现原理
    查看>>
    NISP一级,NISP二级报考说明,零基础入门到精通,收藏这篇就够了
    查看>>
    NI笔试——大数加法
    查看>>
    NLP 基于kashgari和BERT实现中文命名实体识别(NER)
    查看>>
    NMAP网络扫描工具的安装与使用
    查看>>
    NN&DL4.3 Getting your matrix dimensions right
    查看>>
    NN&DL4.8 What does this have to do with the brain?
    查看>>
    No 'Access-Control-Allow-Origin' header is present on the requested resource.
    查看>>
    No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
    查看>>
    No module named cv2
    查看>>
    No module named tensorboard.main在安装tensorboardX的时候遇到的问题
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
    查看>>
    Node JS: < 一> 初识Node JS
    查看>>
    Node-RED中实现HTML表单提交和获取提交的内容
    查看>>
    node.js 怎么新建一个站点端口
    查看>>
    Node.js 文件系统的各种用法和常见场景
    查看>>