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

    你可能感兴趣的文章
    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 resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    node.js+react写的一个登录注册 demo测试
    查看>>
    Node.js安装与配置指南:轻松启航您的JavaScript服务器之旅
    查看>>
    nodejs-mime类型
    查看>>
    npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
    查看>>
    npm和yarn的使用对比
    查看>>
    npm报错unable to access ‘https://github.com/sohee-lee7/Squire.git/‘
    查看>>
    npm的问题:config global `--global`, `--local` are deprecated. Use `--location=global` instead 的解决办法
    查看>>
    NR,NF,FNR
    查看>>
    nrf开发笔记一开发软件
    查看>>
    NSDateFormatter的替代方法
    查看>>
    NSOperation基本操作
    查看>>
    NSSet集合 无序的 不能重复的
    查看>>
    NT AUTHORITY\NETWORK SERVICE 权限问题
    查看>>
    ntko文件存取错误_苹果推送 macOS 10.15.4:iCloud 云盘文件夹共享终于来了
    查看>>