CoreDNS部署
rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm #安装epel源 yum -y install unzip jq conntrack-tools #安装依赖工具 mkdir -p /server/yaml/Core_DNS #创建Coredns目录 cd /server/yaml/Core_DNS && wget https://github.com/coredns/deployment/archive/master.zip unzip master.zip cd deployment-master/kubernetes ./deploy.sh -r 10.0.0.0/24 -i 10.0.0.2 -d cluster.local | kubectl apply -f - kubectl get svc --namespace=kube-system
创建nslookup服务
cat >busybox.yaml<<EOF apiVersion: v1 kind: Pod metadata: name: busybox namespace: default spec: containers: - name: busybox image: busybox:1.28 command: - sleep - "3600" imagePullPolicy: IfNotPresent restartPolicy: Always EOF
创建并测试解析kubernetes.default
kubectl create -f busybox.yaml kubectl get pods busybox kubectl get pods busybox kubectl exec busybox -- cat /etc/resolv.conf kubectl exec -ti busybox -- nslookup kubernetes.default