安装最新版CoreDNS
安装最新版CoreDNS(不建议) git clone https://github.com/coredns/deployment.git
cd deployment/kubernetes
./deploy.sh 10.9.0.0/24 cluster.local | kubectl apply -f -
./deploy.sh -s -i 10.96.0.10 | kubectl apply -f - serviceaccount/coredns created clusterrole.rbac.authorization.k8s.io/system:coredns created clusterrolebinding.rbac.authorization.k8s.io/system:coredns created configmap/coredns created deployment.apps/coredns created service/kube-dns created 查看状态
kubectl get po -n kube-system -l k8s-app=kube-dns
NAME READY STATUS RESTARTS AGE coredns-85b4878f78-h29kh 1/1 Running 0 8h
校验是否成功
部署curl
apiVersion: v1
kind: Pod
metadata:
name: busybox
namespace: default
spec:
containers:
- name: busybox
image: yauritux/busybox-curl
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
restartPolicy: Always
进入容器 kubectl exec -it busybox -- /bin/sh
测试已部署的 get18600 是否可访问
curl get18600.default.svc:18600
DNS服务是Kubernetes赖以实现服务发现的核心组件之一,默认情况下只会创建一个DNS Pod,在生产环境中我们需要对coredns进行扩容。 有两种方式:
手动扩容 kubectl –namespace=kube-system scale deployment coredns –replicas= 使用DNS Horizontal Autoscaler