1,新建一个yaml文件。

apiVersion: v1
kind: Pod
metadata:
  name: busybox
  namespace: default
spec:
  containers:
  - image: busybox
    command:
      - sleep
      - "3600"
    imagePullPolicy: IfNotPresent
    name: busybox
  restartPolicy: Always

2,用kubectl apply -f命令生成这个pod

kubectl  apply -f dns-test-busybox.yaml

3,确认pod启动正常

kubectl get pods busybox

4,运行kubectl exec -it命令查看测试结果.

kubectl exec -ti busybox -- nslookup kubernetes.default

大约结果如下:

Server: 10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

Name: kubernetes.default
Address 1: 10.96.0.1 kubernetes.default.svc.cluster.local

如何简单的测试kubernetes的dns add-ons是否工作正常?-LMLPHP

05-11 22:55