k8s kubernetes常用deploy模板 并验证( 二 )

执行deploy配置文件root@hello:~# kubectl apply -f deploy.yaml deployment.apps/hostname-test-cby createdroot@hello:~# mkdir /htmlroot@hello:~# echo 123 > /html/index.htmlroot@hello:~# kubectl  get pod  -o wideNAME                               READY   STATUS    RESTARTS   AGE   IP              NODE         NOMINATED NODE   READINESS GATEShostname-test-cby-86df45bf-9fx5n   1/1     Running   0          43s   172.17.125.38   k8s-node01   <none>           <none>hostname-test-cby-86df45bf-cmv2b   1/1     Running   0          43s   172.17.125.37   k8s-node01   <none>           <none>hostname-test-cby-86df45bf-f6drb   1/1     Running   0          43s   172.17.125.41   k8s-node01   <none>           <none>hostname-test-cby-86df45bf-g79x2   1/1     Running   0          43s   172.27.14.232   k8s-node02   <none>           <none>hostname-test-cby-86df45bf-h6blv   1/1     Running   0          43s   172.27.14.233   k8s-node02   <none>           <none>hostname-test-cby-86df45bf-hqjnj   1/1     Running   0          43s   172.17.125.40   k8s-node01   <none>           <none>hostname-test-cby-86df45bf-jt2rz   1/1     Running   0          43s   172.27.14.236   k8s-node02   <none>           <none>hostname-test-cby-86df45bf-s5jjn   1/1     Running   0          43s   172.27.14.235   k8s-node02   <none>           <none>hostname-test-cby-86df45bf-vfkbt   1/1     Running   0          43s   172.17.125.39   k8s-node01   <none>           <none>hostname-test-cby-86df45bf-z2x2b   1/1     Running   0          43s   172.27.14.234   k8s-node02   <none>           <none>root@hello:~# 进入pod进行检查# 访问测试root@hello:~# curl 172.17.125.38123root@hello:~# root@hello:~# kubectl  exec hostname-test-cby-86df45bf-9fx5n -it -- /bin/bash root@hostname-test-cby-86df45bf-9fx5n:/# # 查看DNS解析root@hostname-test-cby-86df45bf-9fx5n:/# cat /etc/resolv.conf search default.svc.cluster.local svc.cluster.local cluster.localnameserver 10.96.0.10options ndots:5root@hostname-test-cby-86df45bf-9fx5n:/# # 查看host配置已生效root@hostname-test-cby-86df45bf-9fx5n:/# cat /etc/hosts # Kubernetes-managed hosts file.127.0.0.1       localhost::1     localhost ip6-localhost ip6-loopbackfe00::0 ip6-localnetfe00::0 ip6-mcastprefixfe00::1 ip6-allnodesfe00::2 ip6-allrouters172.27.14.197   hostname-test-cby-86df45bf-9fx5n# Entries added by HostAliases.192.168.1.1     cby     cby.chenby.cn192.168.1.10    chenby  chenby.chenby.cnroot@hostname-test-cby-86df45bf-9fx5n:/## 查看环境变量root@hostname-test-cby-86df45bf-9fx5n:/# echo $cbychenbyroot@hostname-test-cby-86df45bf-9fx5n:/#


推荐阅读