博客
关于我
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/

    你可能感兴趣的文章
    openSUSE 13.1 Milestone 2 发布
    查看>>
    openSUSE推出独立 GUI 包管理工具:YQPkg,简化了整个软件包管理流程
    查看>>
    OpenVP共用账号 一个账号多台电脑登录
    查看>>
    OpenVSwtich(OVS)Vlan间路由实战 附实验环境
    查看>>
    Openwrt LuCI模块练习详细步骤
    查看>>
    openwrt_git_pull命令提示merger冲突时如何解决?
    查看>>
    OpenWrt包管理软件opkg的使用(极路由)
    查看>>
    OpenWrt固件编译刷机完全总结
    查看>>
    Open××× for Linux搭建之二
    查看>>
    Open×××有线网络时使用正常,无线网络时使用报错的解决方案
    查看>>
    Opera Mobile Classic Emulator
    查看>>
    Operation not supported on read-only collection 的解决方法 - [Windows Phone开发技巧系列1]
    查看>>
    OperationResult
    查看>>
    Operations Manager 2007 R2系列之仪表板(多)视图
    查看>>
    operator new and delete
    查看>>
    operator new 与 operator delete
    查看>>
    operator() error
    查看>>
    OPPO K3在哪里打开USB调试模式的完美方法
    查看>>
    oppo后端16连问
    查看>>
    Optional类:避免NullPointerException
    查看>>