{"id":206663,"date":"2025-06-12T10:18:52","date_gmt":"2025-06-12T02:18:52","guid":{"rendered":"https:\/\/server.hk\/cnblog\/206663\/"},"modified":"2025-06-12T10:18:52","modified_gmt":"2025-06-12T02:18:52","slug":"kubernetes-%e9%9b%86%e7%be%a4%e4%b8%ad%ef%bc%8c%e4%b8%ba%e4%bd%95%e4%bd%bf%e7%94%a8-netstat-%e5%91%bd%e4%bb%a4%e7%9c%8b%e4%b8%8d%e5%88%b0-nodeport-%e6%9c%8d%e5%8a%a1%e7%9a%84%e7%ab%af%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/206663\/","title":{"rendered":"Kubernetes \u96c6\u7fa4\u4e2d\uff0c\u4e3a\u4f55\u4f7f\u7528 netstat \u547d\u4ee4\u770b\u4e0d\u5230 NodePort \u670d\u52a1\u7684\u7aef\u53e3\uff1f"},"content":{"rendered":"<p><span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u5404\u4f4d\u5c0f\u4f19\u4f34\u4eec\uff0c\u5927\u5bb6\u597d\u5440\uff01\u770b\u770b\u4eca\u5929\u6211\u53c8\u7ed9\u5404\u4f4d\u5e26\u6765\u4e86\u4ec0\u4e48\u6587\u7ae0\uff1f\u672c\u6587\u6807\u9898<span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u662f<\/span><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aKubernetes \u96c6\u7fa4\u4e2d\uff0c\u4e3a\u4f55\u4f7f\u7528 netstat \u547d\u4ee4\u770b\u4e0d\u5230 NodePort \u670d\u52a1\u7684\u7aef\u53e3\uff1f\u300b<\/span>\uff0c\u5f88\u660e\u663e\u662f\u5173\u4e8e<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u7684\u6587\u7ae0\u54c8\u54c8\u54c8\uff0c\u5176\u4e2d\u5185\u5bb9\u4e3b\u8981\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u5982\u679c\u80fd\u5e2e\u5230\u4f60\uff0c\u89c9\u5f97\u5f88\u4e0d\u9519\u7684\u8bdd\uff0c\u6b22\u8fce\u5404\u4f4d\u591a\u591a\u70b9\u8bc4\u548c\u5206\u4eab\uff01<\/span>,<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241118\/1731929811673b26d30196f.jpg\" class=\"aligncenter\">,<br \/>\n<strong>NodePort \u670d\u52a1\u5728\u8282\u70b9\u4e0a\u4e3a\u4f55\u770b\u4e0d\u5230\u5176 NodePort \u7aef\u53e3<\/strong>,\u5728 Kubernetes \u96c6\u7fa4\u4e2d\uff0cNodePort \u7c7b\u578b\u7684 Service \u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a NodePort \u7aef\u53e3\u5c06\u670d\u52a1\u516c\u5f00\u5230\u96c6\u7fa4\u5916\u90e8\u3002\u7136\u800c\uff0c\u6709\u65f6\u4f1a\u51fa\u73b0\u8fd9\u6837\u7684\u60c5\u51b5\uff1a\u867d\u7136 curl localhost:NodePort \u53ef\u4ee5\u8bbf\u95ee\u670d\u52a1\uff0c\u4f46 netstat -tlp |grep NodePort \u5374\u770b\u4e0d\u5230\u8be5\u7aef\u53e3\u3002,\u8fd9\u662f\u56e0\u4e3a NodePort \u7aef\u53e3\u5e76\u4e0d\u662f\u76f4\u63a5\u5728\u8282\u70b9\u4e0a\u8fdb\u884c\u76d1\u542c\u3002\u76f8\u53cd\uff0c\u5b83\u901a\u8fc7 iptable \u89c4\u5219\u88ab\u8f6c\u53d1\u5230\u5b9e\u9645\u63d0\u4f9b\u670d\u52a1\u7684 Pod \u7684 IP \u5730\u5740\u548c\u7aef\u53e3\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u6ca1\u6709\u8fdb\u7a0b\u5728\u8fd9\u4e2a\u7279\u5b9a\u7684 NodePort \u7aef\u53e3\u4e0a\u76f4\u63a5\u76d1\u542c\u3002,\u56e0\u6b64\uff0cnetstat \u547d\u4ee4\u770b\u4e0d\u5230\u8fd9\u4e2a\u7aef\u53e3\uff0c\u56e0\u4e3a\u6ca1\u6709\u8fdb\u7a0b\u4f7f\u7528\u5b83\u3002\u76f8\u53cd\uff0c\u6570\u636e\u5305\u4f1a\u88ab iptable \u89c4\u5219\u91cd\u5b9a\u5411\u5230\u6b63\u786e\u7684 Pod\u3002,\u7406\u8bba\u8981\u638c\u63e1\uff0c\u5b9e\u64cd\u4e0d\u80fd\u843d\uff01\u4ee5\u4e0a\u5173\u4e8e\u300aKubernetes \u96c6\u7fa4\u4e2d\uff0c\u4e3a\u4f55\u4f7f\u7528 netstat \u547d\u4ee4\u770b\u4e0d\u5230 NodePort \u670d\u52a1\u7684\u7aef\u53e3\uff1f\u300b\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u5927\u5bb6\u90fd\u638c\u63e1\u4e86\u5427\uff01\u5982\u679c\u60f3\u8981\u7ee7\u7eed\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\uff0c\u90a3\u4e48\u5c31\u6765\u5173\u6ce8GOLANG\u516c\u4f17\u53f7\u5427\uff01,NodePort \u670d\u52a1\u5728\u8282\u70b9\u4e0a\u4e3a\u4f55\u770b\u4e0d\u5230\u5176 NodePort \u7aef\u53e3,<br \/>\n<span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u5404\u4f4d\u5c0f\u4f19\u4f34\u4eec\uff0c\u5927\u5bb6\u597d\u5440\uff01\u770b\u770b\u4eca\u5929\u6211\u53c8\u7ed9\u5404\u4f4d\u5e26\u6765\u4e86\u4ec0\u4e48\u6587\u7ae0\uff1f\u672c\u6587\u6807\u9898<span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u662f<\/span><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aKubernetes \u96c6\u7fa4\u4e2d\uff0c\u4e3a\u4f55\u4f7f\u7528 netstat \u547d\u4ee4\u770b\u4e0d\u5230 NodePort \u670d\u52a1\u7684\u7aef\u53e3\uff1f\u300b<\/span>\uff0c\u5f88\u660e\u663e\u662f\u5173\u4e8e<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u7684\u6587\u7ae0\u54c8\u54c8\u54c8\uff0c\u5176\u4e2d\u5185\u5bb9\u4e3b\u8981\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u5982\u679c\u80fd\u5e2e\u5230\u4f60\uff0c\u89c9\u5f97\u5f88\u4e0d\u9519\u7684\u8bdd\uff0c\u6b22\u8fce\u5404\u4f4d\u591a\u591a\u70b9\u8bc4\u548c\u5206\u4eab\uff01<\/span>,<br \/>\n<b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span> <span>Kubernetes \u96c6\u7fa4\u4e2d\uff0c\u4e3a\u4f55\u4f7f\u7528 netstat \u547d\u4ee4\u770b\u4e0d\u5230 NodePort \u670d\u52a1\u7684\u7aef\u53e3\uff1f<\/span><\/p>\n<h1>Kubernetes \u96c6\u7fa4\u4e2d\uff0c\u4e3a\u4f55\u4f7f\u7528 netstat \u547d\u4ee4\u770b\u4e0d\u5230 NodePort \u670d\u52a1\u7684\u7aef\u53e3\uff1f<\/h1>\n<p><span>2024-11-18 19:37:06<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p><span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u5404\u4f4d\u5c0f\u4f19\u4f34\u4eec\uff0c\u5927\u5bb6\u597d\u5440\uff01\u770b\u770b\u4eca\u5929\u6211\u53c8\u7ed9\u5404\u4f4d\u5e26\u6765\u4e86\u4ec0\u4e48\u6587\u7ae0\uff1f\u672c\u6587\u6807\u9898<span style=\"color: #222222;, sans-serif;background-color: #FFFFFF\">\u662f<\/span><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aKubernetes \u96c6\u7fa4\u4e2d\uff0c\u4e3a\u4f55\u4f7f\u7528 netstat \u547d\u4ee4\u770b\u4e0d\u5230 NodePort \u670d\u52a1\u7684\u7aef\u53e3\uff1f\u300b<\/span>\uff0c\u5f88\u660e\u663e\u662f\u5173\u4e8e<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\u7684\u6587\u7ae0\u54c8\u54c8\u54c8\uff0c\u5176\u4e2d\u5185\u5bb9\u4e3b\u8981\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u5982\u679c\u80fd\u5e2e\u5230\u4f60\uff0c\u89c9\u5f97\u5f88\u4e0d\u9519\u7684\u8bdd\uff0c\u6b22\u8fce\u5404\u4f4d\u591a\u591a\u70b9\u8bc4\u548c\u5206\u4eab\uff01<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241118\/1731929811673b26d30196f.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>NodePort \u670d\u52a1\u5728\u8282\u70b9\u4e0a\u4e3a\u4f55\u770b\u4e0d\u5230\u5176 NodePort \u7aef\u53e3<\/strong><\/p>\n<p>\u5728 Kubernetes \u96c6\u7fa4\u4e2d\uff0cNodePort \u7c7b\u578b\u7684 Service \u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a NodePort \u7aef\u53e3\u5c06\u670d\u52a1\u516c\u5f00\u5230\u96c6\u7fa4\u5916\u90e8\u3002\u7136\u800c\uff0c\u6709\u65f6\u4f1a\u51fa\u73b0\u8fd9\u6837\u7684\u60c5\u51b5\uff1a\u867d\u7136 curl localhost:NodePort \u53ef\u4ee5\u8bbf\u95ee\u670d\u52a1\uff0c\u4f46 netstat -tlp |grep NodePort \u5374\u770b\u4e0d\u5230\u8be5\u7aef\u53e3\u3002<\/p>\n<p>\u8fd9\u662f\u56e0\u4e3a NodePort \u7aef\u53e3\u5e76\u4e0d\u662f\u76f4\u63a5\u5728\u8282\u70b9\u4e0a\u8fdb\u884c\u76d1\u542c\u3002\u76f8\u53cd\uff0c\u5b83\u901a\u8fc7 iptable \u89c4\u5219\u88ab\u8f6c\u53d1\u5230\u5b9e\u9645\u63d0\u4f9b\u670d\u52a1\u7684 Pod \u7684 IP \u5730\u5740\u548c\u7aef\u53e3\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u6ca1\u6709\u8fdb\u7a0b\u5728\u8fd9\u4e2a\u7279\u5b9a\u7684 NodePort \u7aef\u53e3\u4e0a\u76f4\u63a5\u76d1\u542c\u3002<\/p>\n<p>\u56e0\u6b64\uff0cnetstat \u547d\u4ee4\u770b\u4e0d\u5230\u8fd9\u4e2a\u7aef\u53e3\uff0c\u56e0\u4e3a\u6ca1\u6709\u8fdb\u7a0b\u4f7f\u7528\u5b83\u3002\u76f8\u53cd\uff0c\u6570\u636e\u5305\u4f1a\u88ab iptable \u89c4\u5219\u91cd\u5b9a\u5411\u5230\u6b63\u786e\u7684 Pod\u3002<\/p>\n<p>\u7406\u8bba\u8981\u638c\u63e1\uff0c\u5b9e\u64cd\u4e0d\u80fd\u843d\uff01\u4ee5\u4e0a\u5173\u4e8e\u300aKubernetes \u96c6\u7fa4\u4e2d\uff0c\u4e3a\u4f55\u4f7f\u7528 netstat \u547d\u4ee4\u770b\u4e0d\u5230 NodePort \u670d\u52a1\u7684\u7aef\u53e3\uff1f\u300b\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u5927\u5bb6\u90fd\u638c\u63e1\u4e86\u5427\uff01\u5982\u679c\u60f3\u8981\u7ee7\u7eed\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\uff0c\u90a3\u4e48\u5c31\u6765\u5173\u6ce8GOLANG\u516c\u4f17\u53f7\u5427\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u79cb\u51ac\u5e38\u89c1\u7684\u6c1b\u56f4\u611f\u5143\u7d20\uff0c\u51fa\u95e8\u62cd\u6444\u65f6\u4e0d\u8981\u9519\u8fc7\n <\/dd>\n<\/dl>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u5982\u4f55\u8bbe\u7f6e\u7535\u8111\u9501\u5c4f\u5bc6\u7801\uff1f\u7535\u8111\u9501\u5c4f\u5bc6\u7801\u8bbe\u7f6e\u65b9\u6cd5\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5404\u4f4d\u5c0f\u4f19\u4f34\u4eec\uff0c\u5927\u5bb6\u597d\u5440\uff01\u770b\u770b\u4eca\u5929&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-206663","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/206663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=206663"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/206663\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=206663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=206663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=206663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}