root@cloud:~# kubectl get svc -o wide NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 6d2h <none> nginx-pod-service ClusterIP 10.100.23.74 <none> 8080/TCP 6s app=nginx root@cloud:~# curl 10.100.23.74:8080 <!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>
NodePort
NodePort 是 ClusterIP 的增强类型,它在 ClusterIP 的基础之上,在每个节点上使用一个相同的端口号将外部流量引入到该 Service 上来。示例: