1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| # 生成yaml kubectl run my-nginx-2 --image=daocloud.io/library/nginx --restart=Never --dry-run=client -o yaml > my-nginx-2.yaml
# 创建pod [root@kubernetes-master study]# kubectl apply -f pod-nginx-2.yaml pod/my-nginx-2 created
# 查看pod [root@kubernetes-master study]# kubectl get pod NAME READY STATUS RESTARTS AGE my-nginx-2 1/1 Running 0 9s
# 查看详细信息 [root@kubernetes-master study]# kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES my-nginx-2 1/1 Running 0 17s 10.10.20.232 kubernetes-node1 <none> <none>
# 测试访问podip [root@kubernetes-master study]# curl 10.10.20.232 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p>
<p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p> </body> </html>
# 删除pod [root@kubernetes-master study]# kubectl delete -f pod-nginx-2.yaml pod "my-nginx-2" deleted
|