9、部署nginx测试
[root@k8s-master01 ~]#kubectl create deployment nginx --image nginx:alpine --replicas=3 deployment.apps/nginx created ? [root@k8s-master01 ~]#kubectl get pods NAME READY STATUS RESTARTS AGE nginx-55f494c486-4js9n 1/1 Running 0 58s nginx-55f494c486-fsgxq 1/1 Running 0 58s nginx-55f494c486-z2gzv 1/1 Running 0 58s ? [root@k8s-master01 ~]#kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx-55f494c486-4js9n 1/1 Running 0 4m31s 10.244.3.2 k8s-node01 <none> <none> nginx-55f494c486-fsgxq 1/1 Running 0 4m31s 10.244.4.2 k8s-node02 <none> <none> nginx-55f494c486-z2gzv 1/1 Running 0 4m31s 10.244.5.2 k8s-node03 <none> <none> ? [root@k8s-master01 ~]#curl 10.244.4.2 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } 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@k8s-master01 ~]#kubectl delete pods nginx-55f494c486-fsgxq pod "nginx-55f494c486-fsgxq" deleted ? [root@k8s-master01 ~]#kubectl get pods -owide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx-55f494c486-4js9n 1/1 Running 0 11m 10.244.3.2 k8s-node01 <none> <none> nginx-55f494c486-xqcph 1/1 Running 0 16s 10.244.4.3 k8s-node02 <none> <none> nginx-55f494c486-z2gzv 1/1 Running 0 11m 10.244.5.2 k8s-node03 <none> <none> ?
? [root@k8s-master01 ~]#kubectl create service nodeport nginx --tcp=80:80 service/nginx created ? [root@k8s-master01 ~]#kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 89m nginx NodePort 10.103.151.47 <none> 80:31901/TCP 18s [root@k8s-master01 ~]#curl 10.103.151.47 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } 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> ? #外部访问任意node几点ip加端口(注意 , 随机产生)都可以访问
经验总结扩展阅读
- 牛油果油和核桃油哪个更适合宝宝
- 椰乳和椰浆一样吗
- 小米10S、荣耀60和小米civi怎么选-购机建议
- vivoy31s和iqoou3哪个好_vivoy31s和iqoou3对比
- 皮新字组词|皮的新字和组词
- 牡蛎和生蚝一样吗
- 一个人煮粥放多少米和水
- 木薯淀粉和糯米粉一样吗
- 一手烟和二手烟哪个危害大
- 中元节和鬼节的区别