创建一个busybox测试pod
[root@k8s-master-1 ~]# cat<<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: busybox namespace: default spec: containers: - name: busybox image: busybox:1.28.4 command: - sleep - "3600" imagePullPolicy: IfNotPresent restartPolicy: Always EOF [root@k8s-master-1 ~]# kubectl get pods NAME READY STATUS RESTARTS AGE argo-rollouts-6f6b9bd669-dw5zd 1/1 Running 0 19h busybox 1/1 Running 0 33m
测试解析集群内部
# 如果解析报错看下busybox:1.31.1 版本是否有问题,改为 1.28.4这个就行 [root@k8s-master-1 ~]# kubectl exec -it busybox -- nslookup kubernetes Server: 172.17.0.10 Address 1: 172.17.0.10 kube-dns.kube-system.svc.cluster.local Name: kubernetes Address 1: 172.17.0.1 kubernetes.default.svc.cluster.local
创建一个nginx测试是否通过
[root@k8s-master-1 ~]# kubectl create deployment nginx --image=nginx deployment.apps/nginx created [root@k8s-master-1 ~]# kubectl expose deployment nginx --port=80 --type=NodePort service/nginx exposed [root@k8s-master-1 ~]# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE argo-rollouts-metrics ClusterIP 172.17.79.54 <none> 8090/TCP 20h kubernetes ClusterIP 172.17.0.1 <none> 443/TCP 22h nginx NodePort 172.17.243.13 <none> 80:31236/TCP 5s [root@k8s-master-1 ~]# kubectl exec -it busybox -- nslookup nginx.default.svc.cluster.local. Server: 172.17.0.10 Address 1: 172.17.0.10 kube-dns.kube-system.svc.cluster.local Name: nginx.default.svc.cluster.local. Address 1: 172.17.243.13 nginx.default.svc.cluster.local [root@k8s-master-1 ~]# curl 172.17.243.13 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; }
原创文章,作者:站长,如若转载,请注明出处:https://wsppx.cn/2398/%e7%bd%91%e7%ab%99%e9%83%a8%e7%bd%b2/