{"id":12319,"date":"2023-08-26T20:26:36","date_gmt":"2023-08-26T12:26:36","guid":{"rendered":"https:\/\/92it.top\/?p=12319"},"modified":"2023-08-26T22:27:28","modified_gmt":"2023-08-26T14:27:28","slug":"k8s%e6%b7%b1%e5%85%a5%e5%ad%a6%e4%b9%a0-k8s%e7%bd%91%e7%bb%9c%e7%9f%a5%e5%a4%9a%e5%b0%91","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=12319","title":{"rendered":"K8S\u6df1\u5165\u5b66\u4e60 K8S\u7f51\u7edc\u77e5\u591a\u5c11"},"content":{"rendered":"\n<p><strong>\u4e00\u3001Kubernetes\u7f51\u7edc\u6a21\u578b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6211\u4eec\u90fd\u77e5\u9053Kubernetes\u4f5c\u4e3a\u5bb9\u5668\u7f16\u6392\u5f15\u64ce\uff0c\u5b83\u6709\u4e00\u4e2a\u5f3a\u5927\u53c8\u590d\u6742\u7684\u7f51\u7edc\u6a21\u578b\uff0c\u4e5f\u7275\u5f15\u51fa\u4e86Pod\u7f51\u7edc\u3001Service\u7f51\u7edc\u3001ClusterIP\u3001NodePort\u3001Ingress\u7b49\u591a\u4e2a\u6982\u5ff5\u3002\u8fd9\u91cc\u6211\u4eec\u91c7\u7528\u6768\u6ce2\u8001\u5e08\uff08<a rel=\"noreferrer noopener\" href=\"https:\/\/me.csdn.net\/yang75108\" target=\"_blank\">\u67b6\u6784\u5e08\u6768\u6ce2<\/a>\uff09\u6a21\u4effTCP\/IP\u534f\u8bae\u6808\u603b\u7ed3\u7684\u4e00\u4e2aK8S\u7f51\u7edc\u6a21\u578b\u56fe\u6765\u770b\u770bK8S\u7684\u56db\u4e2a\u62bd\u8c61\u5c42\u6b21\uff0c\u4ece\u800c\u4e86\u89e3\u4e00\u4e0bK8S\u7684\u7f51\u7edc\u3002\u672c\u5c0f\u8282\u7684\u6587\u5b57\u4e3b\u8981\u5f15\u7528\u81ea\u6768\u6ce2\u8001\u5e08\u5173\u4e8eK8S\u7f51\u7edc\u6a21\u578b\u7684\u6587\u7ae0\u53caCloudMan\u7684\u300a\u6bcf\u59295\u5206\u949f\u73a9\u8f6cKubernetes\u300b\u4e00\u4e66\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-312-1024x565.png\" alt=\"\" class=\"wp-image-12320\" width=\"393\" height=\"217\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-312-1024x565.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-312-300x166.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-312-768x424.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-312-830x458.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-312-230x127.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-312-350x193.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-312-480x265.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-312.png 1330w\" sizes=\"(max-width: 393px) 100vw, 393px\" \/><\/figure><\/div>\n\n\n\n<p>\u6839\u636e\u4e0a\u56fe\u6a21\u578b\u4e2d\u5c55\u793a\u7684\u56db\u4e2a\u5c42\u6b21\uff0c\u4ece0\u52303\uff0c\u9664\u4e86\u7b2c0\u5c42\uff0c\u6bcf\u4e00\u5c42\u90fd\u662f\u6784\u5efa\u4e8e\u524d\u4e00\u5c42\u4e4b\u4e0a\u3002<\/p>\n\n\n\n<p><strong><strong>\u4e8c\u3001<\/strong>\u7b2c0\u5c42\uff1a\u8282\u70b9\u4e3b\u673a\u4e92\u901a\u4e92\u8054<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u4e3b\u8981\u4fdd\u8bc1K8S\u8282\u70b9(\u7269\u7406\u6216\u865a\u62df\u673a)\u4e4b\u95f4\u80fd\u591f\u6b63\u5e38IP\u5bfb\u5740\u548c\u4e92\u901a\u7684\u7f51\u7edc\uff0c\u8fd9\u4e2a\u4e00\u822c\u7531\u5e95\u5c42(\u516c\u6709\u4e91\u6216\u6570\u636e\u4e2d\u5fc3)\u7f51\u7edc\u57fa\u7840\u8bbe\u65bd\u652f\u6301\uff0c\u8fd9\u91cc\u6211\u4eec\u65e0\u9700\u8fc7\u591a\u5173\u5fc3\u3002<\/p>\n\n\n\n<p>\u7b2c0\u5c42<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=Node&amp;spm=1001.2101.3001.7020\" target=\"_blank\">Node<\/a>\u8282\u70b9\u7f51\u7edc\u6bd4\u8f83\u597d\u7406\u89e3\uff0c\u4e5f\u5c31\u662f\u4fdd\u8bc1K8s\u8282\u70b9(\u7269\u7406\u6216\u865a\u62df\u673a)\u4e4b\u95f4\u80fd\u591f\u6b63\u5e38IP\u5bfb\u5740\u548c\u4e92\u901a\u7684\u7f51\u7edc\uff0c\u8fd9\u4e2a\u4e00\u822c\u7531\u5e95\u5c42(\u516c\u6709\u4e91\u6216\u6570\u636e\u4e2d\u5fc3)\u7f51\u7edc\u57fa\u7840\u8bbe\u65bd\u652f\u6301\u3002\u7b2c0\u5c42\u6211\u4eec\u5047\u5b9a\u5df2\u7ecf\u5b58\u5728\uff0c\u6240\u4ee5\u4e0d\u5c55\u5f00\u3002<\/p>\n\n\n\n<p><strong>\u4e09<\/strong>\u3001<strong>\u7b2c1\u5c42\uff1aPod\u865a\u62df\u673a\u4e92\u8054<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5728\u4e00\u4e2aPod\u4e2d\u53ef\u4ee5\u8fd0\u884c\u4e00\u4e2a\u6216\u591a\u4e2a\u5bb9\u5668\uff0c\u4e14Pod\u4e2d\u6240\u6709\u5bb9\u5668\u4f7f\u7528\u540c\u4e00\u4e2a\u7f51\u7edcnamespace\uff0c\u5373\u76f8\u540c\u7684IP\u548c\u7aef\u53e3\u7a7a\u95f4\uff0c\u53ef\u4ee5\u76f4\u63a5\u7528localhost\u901a\u4fe1\uff0c\u800c\u4e14\u8fd8\u53ef\u4ee5\u5171\u4eab\u5b58\u50a8\uff08\u672c\u8d28\u662f\u901a\u8fc7\u5c06Volume\u6302\u8f7d\u5230Pod\u4e2d\u7684\u6bcf\u4e2a\u5bb9\u5668\uff09\u3002<\/p>\n\n\n\n<p>Pod\u76f8\u5f53\u4e8e\u662fK8s\u4e91\u5e73\u53f0\u4e2d\u7684\u865a\u62df\u673a\uff0c\u5b83\u662fK8s\u7684\u57fa\u672c\u8c03\u5ea6\u5355\u4f4d\u3002\u6240\u8c13Pod\u7f51\u7edc\uff0c\u5c31\u662f\u80fd\u591f\u4fdd\u8bc1K8s\u96c6\u7fa4\u4e2d\u7684\u6240\u6709Pods(\u5305\u62ec\u540c\u4e00\u8282\u70b9\u4e0a\u7684\uff0c\u4e5f\u5305\u62ec\u4e0d\u540c\u8282\u70b9\u4e0a\u7684Pods)\uff0c\u903b\u8f91\u4e0a\u770b\u8d77\u6765\u90fd\u5728\u540c\u4e00\u4e2a\u5e73\u9762\u7f51\u7edc\u5185\uff0c\u80fd\u591f\u76f8\u4e92\u505aIP\u5bfb\u5740\u548c\u901a\u4fe1\u7684\u7f51\u7edc\uff0c\u4e0b\u56fe\u662fPod\u7f51\u7edc\u7684\u7b80\u5316\u6982\u5ff5\u6a21\u578b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-313-1024x961.png\" alt=\"\" class=\"wp-image-12328\" width=\"368\" height=\"345\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-313-1024x961.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-313-300x281.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-313-768x721.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-313-830x779.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-313-230x216.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-313-350x328.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-313-480x450.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-313.png 1264w\" sizes=\"(max-width: 368px) 100vw, 368px\" \/><\/figure><\/div>\n\n\n\n<p>Pod\u7f51\u7edc\u6784\u5efa\u4e8eNode\u8282\u70b9\u7f51\u7edc\u4e4b\u4e0a\uff0c\u5b83\u53c8\u662f\u4e0a\u5c42Service\u7f51\u7edc\u7684\u57fa\u7840\u3002\u4e3a\u4e86\u8fdb\u4e00\u6b65\u7406\u89e3Pod\u7f51\u7edc\uff0c\u6211\u5c06\u5bf9\u540c\u4e00\u8282\u70b9\u4e0a\u7684Pod\u4e4b\u95f4\u7684\u7f51\u7edc\uff0c\u4ee5\u53ca\u4e0d\u540c\u8282\u70b9\u4e0a\u7684Pod\u4e4b\u95f4\u7f51\u7edc\uff0c\u5206\u522b\u8fdb\u884c\u5256\u6790\u3002<\/p>\n\n\n\n<p><strong>3.1 \u540c\u4e00\u8282\u70b9\u4e0a\u7684Pod\u7f51\u7edc<\/strong><\/p>\n\n\n\n<p>\u524d\u9762\u63d0\u5230\uff0cPod\u76f8\u5f53\u4e8e\u662fK8s\u4e91\u5e73\u53f0\u4e2d\u7684\u865a\u62df\u673a\uff0c\u5b9e\u9645\u4e00\u4e2aPod\u4e2d\u53ef\u4ee5\u4f4f\u4e00\u4e2a\u6216\u8005\u591a\u4e2a(\u5927\u591a\u6570\u573a\u666f\u4f4f\u4e00\u4e2a)\u5e94\u7528\u5bb9\u5668\uff0c\u8fd9\u4e9b\u5bb9\u5668\u5171\u4eabPod\u7684\u7f51\u7edc\u6808\u548c\u5176\u5b83\u8d44\u6e90\u5982Volume\u3002\u90a3\u4e48\u4ec0\u4e48\u662f\u5171\u4eab\u7f51\u7edc\u6808\uff1f\u540c\u4e00\u8282\u70b9\u4e0a\u7684Pod\u4e4b\u95f4\u5982\u4f55\u5bfb\u5740\u548c\u4e92\u901a\uff1f\u6211\u4ee5\u4e0b\u56fe\u6837\u4f8b\u6765\u89e3\u91ca\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-317-1024x935.png\" alt=\"\" class=\"wp-image-12341\" width=\"335\" height=\"305\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-317-1024x935.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-317-300x274.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-317-768x702.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-317-830x758.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-317-230x210.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-317-350x320.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-317-480x438.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-317.png 1202w\" sizes=\"(max-width: 335px) 100vw, 335px\" \/><\/figure><\/div>\n\n\n\n<p>\u4e0a\u56fe\u8282\u70b9\u4e0a\u5c55\u793a\u4e86Pod\u7f51\u7edc\u6240\u4f9d\u8d56\u76843\u4e2a\u7f51\u7edc\u8bbe\u5907\uff0ceth0\u662f\u8282\u70b9\u4e3b\u673a\u4e0a\u7684\u7f51\u5361\uff0c\u8fd9\u4e2a\u662f\u652f\u6301\u8be5\u8282\u70b9\u6d41\u91cf\u51fa\u5165\u7684\u8bbe\u5907\uff0c\u4e5f\u662f\u652f\u6301\u96c6\u7fa4\u8282\u70b9\u95f4IP\u5bfb\u5740\u548c\u4e92\u901a\u7684\u8bbe\u5907\u3002docker0\u662f\u4e00\u4e2a\u865a\u62df\u7f51\u6865\uff0c\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\u4e00\u4e2a\u865a\u62df\u4ea4\u6362\u673a\uff0c\u5b83\u662f\u652f\u6301\u8be5\u8282\u70b9\u4e0a\u7684Pod\u4e4b\u95f4\u8fdb\u884cIP\u5bfb\u5740\u548c\u4e92\u901a\u7684\u8bbe\u5907\u3002veth0\u5219\u662fPod1\u7684\u865a\u62df\u7f51\u5361\uff0c\u662f\u652f\u6301\u8be5Pod\u5185\u5bb9\u5668\u4e92\u901a\u548c\u5bf9\u5916\u8bbf\u95ee\u7684\u865a\u62df\u8bbe\u5907\u3002docker0\u7f51\u6865\u548cveth0\u7f51\u5361\uff0c\u90fd\u662flinux\u652f\u6301\u548c\u521b\u5efa\u7684\u865a\u62df\u7f51\u7edc\u8bbe\u5907\u3002<\/p>\n\n\n\n<p>\u4e0a\u56fePod1\u5185\u90e8\u4f4f\u4e863\u4e2a\u5bb9\u5668\uff0c\u5b83\u4eec\u90fd\u5171\u4eab\u4e00\u4e2a\u865a\u62df\u7f51\u5361veth0\u3002\u5185\u90e8\u7684\u8fd9\u4e9b\u5bb9\u5668\u53ef\u4ee5\u901a\u8fc7localhost\u76f8\u4e92\u8bbf\u95ee\uff0c\u4f46\u662f\u5b83\u4eec\u4e0d\u80fd\u5728\u540c\u4e00\u7aef\u53e3\u4e0a\u540c\u65f6\u5f00\u542f\u670d\u52a1\uff0c\u5426\u5219\u4f1a\u6709\u7aef\u53e3\u51b2\u7a81\uff0c\u8fd9\u5c31\u662f\u5171\u4eab\u7f51\u7edc\u6808\u7684\u610f\u601d\u3002Pod1\u4e2d\u8fd8\u6709\u4e00\u4e2a\u6bd4\u8f83\u7279\u6b8a\u7684\u53ebpause\u7684\u5bb9\u5668\uff0c\u8fd9\u4e2a\u5bb9\u5668\u8fd0\u884c\u7684\u552f\u4e00\u76ee\u7684\u662f\u4e3aPod\u5efa\u7acb\u5171\u4eab\u7684veth0\u7f51\u7edc\u63a5\u53e3\u3002\u5982\u679c\u4f60SSH\u5230K8s\u96c6\u7fa4\u4e2d\u4e00\u4e2a\u6709Pod\u8fd0\u884c\u7684\u8282\u70b9\u4e0a\u53bb\uff0c\u7136\u540e\u8fd0\u884cdocker ps\uff0c\u53ef\u4ee5\u770b\u5230\u901a\u8fc7pause\u547d\u4ee4\u8fd0\u884c\u7684\u5bb9\u5668\u3002<\/p>\n\n\n\n<p>Pod\u7684IP\u662f\u7531docker0\u7f51\u6865\u5206\u914d\u7684\uff0c\u4f8b\u5982\u4e0a\u56fedocker0\u7f51\u6865\u7684IP\u662f172.17.0.1\uff0c\u5b83\u7ed9\u7b2c\u4e00\u4e2aPod1\u5206\u914dIP\u4e3a172.17.0.2\u3002\u5982\u679c\u8be5\u8282\u70b9\u4e0a\u518d\u542f\u4e00\u4e2aPod2\uff0c\u90a3\u4e48\u76f8\u5e94\u7684\u5206\u914dIP\u4e3a172.17.0.3\uff0c\u5982\u679c\u518d\u542f\u52a8Pod\u53ef\u4f9d\u6b21\u7c7b\u63a8\u3002\u56e0\u4e3a\u8fd9\u4e9bPods\u90fd\u8fde\u5728\u540c\u4e00\u4e2a\u7f51\u6865\u4e0a\uff0c\u5728\u540c\u4e00\u4e2a\u7f51\u6bb5\u5185\uff0c\u5b83\u4eec\u53ef\u4ee5\u8fdb\u884cIP\u5bfb\u5740\u548c\u4e92\u901a\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-318-1024x927.png\" alt=\"\" class=\"wp-image-12342\" width=\"350\" height=\"316\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-318-1024x927.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-318-300x272.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-318-768x695.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-318-830x751.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-318-230x208.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-318-350x317.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-318-480x435.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-318.png 1224w\" sizes=\"(max-width: 350px) 100vw, 350px\" \/><\/figure><\/div>\n\n\n\n<p><br>\u4ece\u4e0a\u56fe\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u8282\u70b9\u5185Pod\u7f51\u7edc\u5728172.17.0.0\/24\u8fd9\u4e2a\u5730\u5740\u7a7a\u95f4\u5185\uff0c\u800c\u8282\u70b9\u4e3b\u673a\u572810.100.0.0\/24\u8fd9\u4e2a\u5730\u5740\u7a7a\u95f4\u5185\uff0c\u4e5f\u5c31\u662f\u8bf4Pod\u7f51\u7edc\u548c\u8282\u70b9\u7f51\u7edc\u4e0d\u5728\u540c\u4e00\u4e2a\u7f51\u7edc\u5185\uff0c\u90a3\u4e48\u4e0d\u540c\u8282\u70b9\u95f4\u7684Pod\u8be5\u5982\u4f55IP\u5bfb\u5740\u548c\u4e92\u901a\u5462\uff1f\u4e0b\u4e00\u8282\u6211\u4eec\u6765\u5206\u6790\u8fd9\u4e2a\u95ee\u9898\u3002<br><\/p>\n\n\n\n<p><strong>3.2 \u4e0d\u540c\u8282\u70b9\u95f4\u7684Pod\u7f51\u7edc<\/strong><\/p>\n\n\n\n<p>\u73b0\u5728\u5047\u8bbe\u6211\u4eec\u6709\u4e24\u4e2a\u8282\u70b9\u4e3b\u673a\uff0chost1(10.100.0.2)\u548chost2(10.100.0.3)\uff0c\u5b83\u4eec\u572810.100.0.0\/24\u8fd9\u4e2a\u5730\u5740\u7a7a\u95f4\u5185\u3002host1\u4e0a\u6709\u4e00\u4e2aPodX(172.17.0.2)\uff0chost2\u4e0a\u6709\u4e00\u4e2aPodY(172.17.1.3)\uff0cPod\u7f51\u7edc\u5728172.17.0.0\/16\u8fd9\u4e2a\u5730\u5740\u7a7a\u95f4\u5185\u3002\u6ce8\u610f\uff0cPod\u7f51\u7edc\u7684\u5730\u5740\uff0c\u662f\u7531K8s\u7edf\u4e00\u7ba1\u7406\u548c\u5206\u914d\u7684\uff0c\u4fdd\u8bc1\u96c6\u7fa4\u5185Pod\u7684IP\u5730\u5740\u552f\u4e00\u3002\u6211\u4eec\u53d1\u73b0\u8282\u70b9\u7f51\u7edc\u548cPod\u7f51\u7edc\u4e0d\u5728\u540c\u4e00\u4e2a\u7f51\u7edc\u5730\u5740\u7a7a\u95f4\u5185\uff0c\u90a3\u4e48host1\u4e0a\u7684PodX\u8be5\u5982\u4f55\u4e0ehost2\u4e0a\u7684PodY\u8fdb\u884c\u4e92\u901a\uff1f<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-319-1024x449.png\" alt=\"\" class=\"wp-image-12343\" width=\"478\" height=\"209\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-319-1024x449.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-319-300x131.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-319-768x337.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-319-830x364.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-319-230x101.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-319-350x153.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-319-480x210.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-319.png 1506w\" sizes=\"(max-width: 478px) 100vw, 478px\" \/><\/figure><\/div>\n\n\n\n<p>\u5b9e\u9645\u4e0a\u4e0d\u540c\u8282\u70b9\u95f4\u7684Pod\u7f51\u7edc\u4e92\u901a\uff0c\u6709\u5f88\u591a\u6280\u672f\u5b9e\u73b0\u65b9\u6848\uff0c\u5e95\u5c42\u7684\u6280\u672f\u7ec6\u8282\u4e5f\u5f88\u590d\u6742\u3002\u4e3a\u4e86\u7b80\u5316\u63cf\u8ff0\uff0c\u6211\u628a\u8fd9\u4e9b\u65b9\u6848\u5927\u4f53\u5206\u4e3a\u4e24\u7c7b\uff0c\u4e00\u7c7b\u662f\u8def\u7531\u65b9\u6848\uff0c\u53e6\u5916\u4e00\u7c7b\u662f\u8986\u76d6(Overlay)\u7f51\u7edc\u65b9\u6848\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u5e95\u5c42\u7684\u7f51\u7edc\u662f\u4f60\u53ef\u4ee5\u63a7\u5236\u7684\uff0c\u6bd4\u5982\u8bf4\u4f01\u4e1a\u5185\u90e8\u81ea\u5efa\u7684\u6570\u636e\u4e2d\u5fc3\uff0c\u5e76\u4e14\u4f60\u548c\u8fd0\u7ef4\u56e2\u961f\u7684\u5173\u7cfb\u6bd4\u8f83\u597d\uff0c\u53ef\u4ee5\u91c7\u7528\u8def\u7531\u65b9\u6848\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-320-1024x398.png\" alt=\"\" class=\"wp-image-12344\" width=\"448\" height=\"174\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-320-1024x398.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-320-300x116.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-320-768x298.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-320-830x322.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-320-230x89.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-320-350x136.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-320-480x186.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-320.png 1530w\" sizes=\"(max-width: 448px) 100vw, 448px\" \/><\/figure><\/div>\n\n\n\n<p>\u8fd9\u4e2a\u65b9\u6848\u7b80\u5355\u7406\u89e3\uff0c\u5c31\u662f\u901a\u8fc7\u8def\u7531\u8bbe\u5907\u4e3aK8s\u96c6\u7fa4\u7684Pod\u7f51\u7edc\u5355\u72ec\u5212\u5206\u7f51\u6bb5\uff0c\u5e76\u914d\u7f6e\u8def\u7531\u5668\u652f\u6301Pod\u7f51\u7edc\u7684\u8f6c\u53d1\u3002\u4f8b\u5982\u4e0a\u56fe\u4e2d\uff0c\u5bf9\u4e8e\u76ee\u6807\u4e3a172.17.1.0\/24\u8fd9\u4e2a\u8303\u56f4\u5185\u7684\u5305\uff0c\u8f6c\u53d1\u523010.100.0.3\u8fd9\u4e2a\u4e3b\u673a\u4e0a\uff0c\u540c\u6837\uff0c\u5bf9\u4e8e\u76ee\u6807\u4e3a172.17.0.0\/24\u8fd9\u4e2a\u8303\u56f4\u5185\u7684\u5305\uff0c\u8f6c\u53d1\u523010.100.0.2\u8fd9\u4e2a\u4e3b\u673a\u4e0a\u3002\u5f53\u4e3b\u673a\u7684eth0\u63a5\u53e3\u63a5\u6536\u5230\u6765\u81eaPod\u7f51\u7edc\u7684\u5305\uff0c\u5c31\u4f1a\u5411\u5185\u90e8\u7f51\u6865\u8f6c\u53d1\uff0c\u8fd9\u6837\u4e0d\u540c\u8282\u70b9\u95f4\u7684Pod\u5c31\u53ef\u4ee5\u76f8\u4e92IP\u5bfb\u5740\u548c\u901a\u4fe1\u3002\u8fd9\u79cd\u65b9\u6848\u4f9d\u8d56\u4e8e\u5e95\u5c42\u7684\u7f51\u7edc\u8bbe\u5907\uff0c\u4f46\u662f\u4e0d\u5f15\u5165\u989d\u5916\u6027\u80fd\u5f00\u9500\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u5e95\u5c42\u7684\u7f51\u7edc\u662f\u4f60\u65e0\u6cd5\u63a7\u5236\u7684\uff0c\u6bd4\u5982\u8bf4\u516c\u6709\u4e91\u7f51\u7edc\uff0c\u6216\u8005\u4f01\u4e1a\u7684\u8fd0\u7ef4\u56e2\u961f\u4e0d\u652f\u6301\u8def\u7531\u65b9\u6848\uff0c\u53ef\u4ee5\u91c7\u7528\u8986\u76d6(Overlay)\u7f51\u7edc\u65b9\u6848\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-321-1024x391.png\" alt=\"\" class=\"wp-image-12345\" width=\"423\" height=\"160\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-321-300x114.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-321-768x293.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-321-230x88.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-321-350x133.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-321-480x183.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-321.png 1526w\" sizes=\"(max-width: 423px) 100vw, 423px\" \/><\/figure><\/div>\n\n\n\n<p>\u6240\u8c13\u8986\u76d6\u7f51\u7edc\uff0c\u5c31\u662f\u5728\u73b0\u6709\u7f51\u7edc\u4e4b\u4e0a\u518d\u5efa\u7acb\u4e00\u4e2a\u865a\u62df\u7f51\u7edc\uff0c\u5b9e\u73b0\u6280\u672f\u6709\u5f88\u591a\uff0c\u4f8b\u5982flannel\/weavenet\u7b49\u7b49\uff0c\u8fd9\u4e9b\u65b9\u6848\u5927\u90fd\u91c7\u7528\u96a7\u9053\u5c01\u5305\u6280\u672f\u3002\u7b80\u5355\u7406\u89e3\uff0cPod\u7f51\u7edc\u7684\u6570\u636e\u5305\uff0c\u5728\u51fa\u8282\u70b9\u4e4b\u524d\uff0c\u4f1a\u5148\u88ab\u5c01\u88c5\u6210\u8282\u70b9\u7f51\u7edc\u7684\u6570\u636e\u5305\uff0c\u5f53\u6570\u636e\u5305\u5230\u8fbe\u76ee\u6807\u8282\u70b9\uff0c\u5305\u5185\u7684Pod\u7f51\u7edc\u6570\u636e\u5305\u4f1a\u88ab\u89e3\u5c01\u51fa\u6765\uff0c\u518d\u8f6c\u53d1\u7ed9\u8282\u70b9\u5185\u90e8\u7684Pod\u7f51\u7edc\u3002\u8fd9\u79cd\u65b9\u6848\u5bf9\u5e95\u5c42\u7f51\u7edc\u6ca1\u6709\u7279\u522b\u4f9d\u8d56\uff0c\u4f46\u662f\u5c01\u5305\u89e3\u5305\u4f1a\u5f15\u5165\u989d\u5916\u6027\u80fd\u5f00\u9500\u3002<\/p>\n\n\n\n<p><strong>3.3 CNI\u7b80\u4ecb<\/strong><\/p>\n\n\n\n<p>\u8003\u8651\u5230Pod\u7f51\u7edc\u5b9e\u73b0\u6280\u672f\u4f17\u591a\uff0c\u4e3a\u4e86\u7b80\u5316\u96c6\u6210\uff0cK8s\u652f\u6301CNI(Container Network Interface)\u6807\u51c6\uff0c\u4e0d\u540c\u7684Pod\u7f51\u7edc\u6280\u672f\u53ef\u4ee5\u901a\u8fc7CNI\u63d2\u4ef6\u5f62\u5f0f\u548cK8s\u8fdb\u884c\u96c6\u6210\u3002\u8282\u70b9\u4e0a\u7684Kubelet\u901a\u8fc7CNI\u6807\u51c6\u63a5\u53e3\u64cd\u4f5cPod\u7f51\u8def\uff0c\u4f8b\u5982\u6dfb\u52a0\u6216\u5220\u9664\u7f51\u7edc\u63a5\u53e3\u7b49\uff0c\u5b83\u4e0d\u9700\u8981\u5173\u5fc3Pod\u7f51\u7edc\u7684\u5177\u4f53\u5b9e\u73b0\u7ec6\u8282\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-332-1024x540.png\" alt=\"\" class=\"wp-image-12360\" width=\"486\" height=\"255\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-332-1024x540.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-332-300x158.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-332-768x405.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-332-830x437.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-332-230x121.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-332-350x184.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-332-480x253.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-332.png 1226w\" sizes=\"(max-width: 486px) 100vw, 486px\" \/><\/figure><\/div>\n\n\n\n<p><strong>3.4 \u603b\u7ed3<\/strong><\/p>\n\n\n\n<ul><li>K8s\u7684\u7f51\u7edc\u53ef\u4ee5\u62bd\u8c61\u6210\u56db\u5c42\u7f51\u7edc\uff0c\u7b2c0\u5c42\u8282\u70b9\u7f51\u7edc\uff0c\u7b2c1\u5c42Pod\u7f51\u7edc\uff0c\u7b2c2\u5c42Service\u7f51\u7edc\uff0c\u7b2c3\u5c42\u5916\u90e8\u63a5\u5165\u7f51\u7edc\u3002\u9664\u4e86\u7b2c0\u5c42\uff0c\u6bcf\u4e00\u5c42\u90fd\u6784\u5efa\u4e8e\u4e0a\u4e00\u5c42\u4e4b\u4e0a\u3002<\/li><li>\u4e00\u4e2a\u8282\u70b9\u5185\u7684Pod\u7f51\u7edc\u4f9d\u8d56\u4e8e\u865a\u62df\u7f51\u6865\u548c\u865a\u62df\u7f51\u5361\u7b49linux\u865a\u62df\u8bbe\u5907\uff0c\u4fdd\u8bc1\u540c\u4e00\u8282\u70b9\u4e0a\u7684Pod\u4e4b\u95f4\u53ef\u4ee5\u6b63\u5e38IP\u5bfb\u5740\u548c\u4e92\u901a\u3002\u4e00\u4e2aPod\u5185\u5bb9\u5668\u5171\u4eab\u8be5Pod\u7684\u7f51\u7edc\u6808\uff0c\u8fd9\u4e2a\u7f51\u7edc\u6808\u7531pause\u5bb9\u5668\u521b\u5efa\u3002<\/li><li>\u4e0d\u540c\u8282\u70b9\u95f4\u7684Pod\u7f51\u7edc\uff0c\u53ef\u4ee5\u91c7\u7528\u8def\u7531\u65b9\u6848\u5b9e\u73b0\uff0c\u4e5f\u53ef\u4ee5\u91c7\u7528\u8986\u76d6\u7f51\u7edc\u65b9\u6848\u3002\u8def\u7531\u65b9\u6848\u4f9d\u8d56\u4e8e\u5e95\u5c42\u7f51\u7edc\u8bbe\u5907\uff0c\u4f46\u6ca1\u6709\u989d\u5916\u6027\u80fd\u5f00\u9500\uff0c\u8986\u76d6\u7f51\u7edc\u65b9\u6848\u4e0d\u4f9d\u8d56\u4e8e\u5e95\u5c42\u7f51\u7edc\uff0c\u4f46\u6709\u989d\u5916\u5c01\u5305\u89e3\u5305\u5f00\u9500\u3002<\/li><li>CNI\u662f\u4e00\u4e2aPod\u7f51\u7edc\u96c6\u6210\u6807\u51c6\uff0c\u7b80\u5316K8s\u548c\u4e0d\u540cPod\u7f51\u7edc\u5b9e\u73b0\u6280\u672f\u7684\u96c6\u6210\u3002<\/li><\/ul>\n\n\n\n<p>\u6709\u4e86Pod\u7f51\u7edc\uff0cK8s\u96c6\u7fa4\u5185\u7684\u6240\u6709Pods\u5728\u903b\u8f91\u4e0a\u90fd\u53ef\u4ee5\u770b\u4f5c\u5728\u4e00\u4e2a\u5e73\u9762\u7f51\u7edc\u5185\uff0c\u53ef\u4ee5\u6b63\u5e38IP\u5bfb\u5740\u548c\u4e92\u901a\u3002\u4f46\u662fPod\u4ec5\u4ec5\u662fK8s\u4e91\u5e73\u53f0\u4e2d\u7684\u865a\u62df\u673a\u62bd\u8c61\uff0c\u6700\u7ec8\uff0c\u6211\u4eec\u9700\u8981\u5728K8s\u96c6\u7fa4\u4e2d\u8fd0\u884c\u7684\u662f\u5e94\u7528\u6216\u8005\u8bf4\u670d\u52a1(Service)\uff0c\u800c\u4e00\u4e2aService\u80cc\u540e\u4e00\u822c\u7531\u591a\u4e2aPods\u7ec4\u6210\u96c6\u7fa4\uff0c\u8fd9\u65f6\u5019\u5c31\u5f15\u5165\u4e86\u670d\u52a1\u53d1\u73b0(Service Discovery)\u548c\u8d1f\u8f7d\u5747\u8861(Load Balancing)\u7b49\u95ee\u9898\u3002<br><\/p>\n\n\n\n<p><strong>\u56db\u3001\u7b2c2\u5c42\uff1a\u670d\u52a1\u53d1\u73b0\u548c\u8d1f\u8f7d\u5747\u8861<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5728K8S\u96c6\u7fa4\u4e2d\uff0cPod\u7684IP\u5e76\u4e0d\u662f\u56fa\u5b9a\u7684\uff0c\u53ef\u80fd\u4f1a\u9891\u7e41\u5730\u9500\u6bc1\u548c\u521b\u5efa\u5b9e\u4f8b\uff0c\u4e3a\u4e86\u89e3\u51b3\u6b64\u95ee\u9898\uff0cService\u63d0\u4f9b\u4e86\u8bbf\u95eePod\u7684\u62bd\u8c61\u5c42\u3002\u5373\u65e0\u8bba\u540e\u7aefPod\u5982\u4f55\u53d8\u5316\uff0cService\u90fd\u4f5c\u4e3a\u7a33\u5b9a\u7684\u524d\u7aef\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\u3002\u6b64\u5916\uff0cService\u8fd8\u63d0\u4f9b\u4e86\u9ad8\u53ef\u7528\u548c\u8d1f\u8f7d\u5747\u8861\u7684\u529f\u80fd\uff0c\u5b83\u8d1f\u8d23\u5c06\u8bf7\u6c42\u8f6c\u53d1\u7ed9\u6b63\u786e\u7684Pod\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-314-1024x699.png\" alt=\"\" class=\"wp-image-12335\" width=\"420\" height=\"287\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-314-1024x699.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-314-300x205.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-314-768x525.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-314-830x567.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-314-230x157.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-314-350x239.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-314-480x328.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-314.png 1224w\" sizes=\"(max-width: 420px) 100vw, 420px\" \/><\/figure><\/div>\n\n\n\n<p><strong>4.1 Service\u7f51\u7edc\u6982\u5ff5\u6a21\u578b<\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u5047\u5b9a\u7b2c1\u5c42Pod\u7f51\u7edc\u5df2\u7ecf\u5b58\u5728\uff0c\u4e0b\u56fe\u662fK8s\u7684\u7b2c2\u5c42Service\u7f51\u7edc\u7684\u7b80\u5316\u6982\u5ff5\u6a21\u578b:<\/p>\n\n\n\n<p>\u6211\u4eec\u5047\u5b9a\u5728K8s\u96c6\u7fa4\u4e2d\u90e8\u7f72\u4e86\u4e00\u4e2aAccount-App\u5e94\u7528\uff0c\u8fd9\u4e2a\u5e94\u7528\u75314\u4e2aPod(\u865a\u62df\u673a)\u7ec4\u6210\u96c6\u7fa4\u4e00\u8d77\u63d0\u4f9b\u670d\u52a1\uff0c\u6bcf\u4e00\u4e2aPod\u90fd\u6709\u81ea\u5df1\u7684PodIP\u548c\u7aef\u53e3\u3002\u6211\u4eec\u518d\u5047\u5b9a\u96c6\u7fa4\u5185\u8fd8\u90e8\u7f72\u4e86\u5176\u5b83\u5e94\u7528\uff0c\u8fd9\u4e9b\u5e94\u7528\u4e2d\u6709\u4e9b\u662fAccount-App\u7684\u6d88\u8d39\u65b9\uff0c\u4e5f\u5c31\u8bf4\u6709Client Pod\u8981\u8bbf\u95eeAccount-App\u7684Pod\u96c6\u7fa4\u3002\u8fd9\u4e2a\u65f6\u5019\u81ea\u7136\u5f15\u5165\u4e86\u4e24\u4e2a\u95ee\u9898\uff1a<\/p>\n\n\n\n<ul><li>\u670d\u52a1\u53d1\u73b0(Service Discovery)\uff1a Client Pod\u5982\u4f55\u53d1\u73b0\u5b9a\u4f4dAccount-App\u96c6\u7fa4\u4e2dPod\u7684IP\uff1f\u51b5\u4e14Account-App\u96c6\u7fa4\u4e2dPod\u7684IP\u662f\u6709\u53ef\u80fd\u4f1a\u53d8\u7684(\u82f1\u6587\u53ebephemeral)\uff0c\u8fd9\u79cd\u53d8\u5316\u5305\u62ec\u9884\u671f\u7684\uff0c\u6bd4\u5982Account-App\u91cd\u65b0\u53d1\u5e03\uff0c\u6216\u8005\u975e\u9884\u671f\u7684\uff0c\u4f8b\u5982Account-App\u96c6\u7fa4\u4e2d\u6709Pod\u6302\u4e86\uff0cK8s\u5bf9Account-App\u8fdb\u884c\u91cd\u65b0\u8c03\u5ea6\u90e8\u7f72\u3002<\/li><li>\u8d1f\u8f7d\u5747\u8861(Load Balancing)\uff1aClient Pod\u5982\u4f55\u4ee5\u67d0\u79cd\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u53bb\u8bbf\u95eeAccount-App\u96c6\u7fa4\u4e2d\u7684\u4e0d\u540cPod\u5b9e\u4f8b\uff1f\u4ee5\u5b9e\u73b0\u8d1f\u8f7d\u5206\u644a\u548cHA\u9ad8\u53ef\u7528\u3002<\/li><\/ul>\n\n\n\n<p>\u5b9e\u9645\u4e0a\uff0cK8s\u901a\u8fc7\u5728Client\u548cAccount-App\u7684Pod\u96c6\u7fa4\u4e4b\u95f4\u5f15\u5165\u4e00\u5c42Account-Serivce\u62bd\u8c61\uff0c\u6765\u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898\uff1a<\/p>\n\n\n\n<ul><li>\u670d\u52a1\u53d1\u73b0\uff1aAccount-Service\u63d0\u4f9b\u7edf\u4e00\u7684ClusterIP\u6765\u89e3\u51b3\u670d\u52a1\u53d1\u73b0\u95ee\u9898\uff0cClient\u53ea\u9700\u901a\u8fc7ClusterIP\u5c31\u53ef\u4ee5\u8bbf\u95eeAccount-App\u7684Pod\u96c6\u7fa4\uff0c\u4e0d\u9700\u8981\u5173\u5fc3\u96c6\u7fa4\u4e2d\u7684\u5177\u4f53Pod\u6570\u91cf\u548cPodIP\uff0c\u5373\u4f7f\u662fPodIP\u53d1\u751f\u53d8\u5316\u4e5f\u4f1a\u88abClusterIP\u6240\u5c4f\u853d\u3002\u6ce8\u610f\uff0c\u8fd9\u91cc\u7684ClusterIP\u5b9e\u9645\u662f\u4e2a\u865a\u62dfIP\uff0c\u4e5f\u79f0Virtual IP(VIP)\u3002<\/li><li>\u8d1f\u8f7d\u5747\u8861\uff1aAccount-Service\u62bd\u8c61\u5c42\u5177\u6709\u8d1f\u8f7d\u5747\u8861\u7684\u80fd\u529b\uff0c\u652f\u6301\u4ee5\u4e0d\u540c\u7b56\u7565\u53bb\u8bbf\u95eeAccount-App\u96c6\u7fa4\u4e2d\u7684\u4e0d\u540cPod\u5b9e\u4f8b\uff0c\u4ee5\u5b9e\u73b0\u8d1f\u8f7d\u5206\u644a\u548cHA\u9ad8\u53ef\u7528\u3002K8s\u4e2d\u9ed8\u8ba4\u7684\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u662fRoundRobin\uff0c\u4e5f\u53ef\u4ee5\u5b9a\u5236\u5176\u5b83\u590d\u6742\u7b56\u7565\u3002<\/li><\/ul>\n\n\n\n<p>K8s\u4e2d\u4e3a\u4f55\u8981\u5f15\u5165Service\u62bd\u8c61\uff1f\u80cc\u540e\u7684\u539f\u7406\u662f\u4ec0\u4e48\uff1f\u540e\u9762\u6211\u5c06\u4ee5\u6280\u672f\u6f14\u8fdb\u89c6\u89d2\u6765\u89e3\u91ca\u8fd9\u4e9b\u95ee\u9898\u3002<\/p>\n\n\n\n<p><strong>4.2 \u670d\u52a1\u53d1\u73b0\u6280\u672f\u6f14\u8fdb<\/strong><\/p>\n\n\n\n<p>DNS\u57df\u540d\u670d\u52a1\u662f\u4e00\u79cd\u8f83\u8001\u4e14\u6210\u719f\u7684\u6807\u51c6\u6280\u672f\uff0c\u5b9e\u9645\u4e0aDNS\u53ef\u4ee5\u8ba4\u4e3a\u662f\u6700\u65e9\u7684\u4e00\u79cd\u670d\u52a1\u53d1\u73b0\u6280\u672f\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-322-1024x634.png\" alt=\"\" class=\"wp-image-12348\" width=\"422\" height=\"261\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-322-1024x634.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-322-300x186.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-322-768x476.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-322-1536x951.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-322-830x514.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-322-230x142.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-322-350x217.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-322-480x297.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-322.png 1644w\" sizes=\"(max-width: 422px) 100vw, 422px\" \/><\/figure><\/div>\n\n\n\n<p>\u5728K8s\u4e2d\u5f15\u5165DNS\u5b9e\u73b0\u670d\u52a1\u53d1\u73b0\u5176\u5b9e\u5e76\u4e0d\u590d\u6742\uff0c\u5b9e\u9645K8s\u672c\u8eab\u5c31\u652f\u6301Kube-DNS\u7ec4\u4ef6\u3002\u5047\u8bbeK8s\u5f15\u5165DNS\u505a\u670d\u52a1\u53d1\u73b0(\u5982\u4e0a\u56fe\u6240\u793a)\uff0c\u8fd0\u884c\u65f6\uff0cK8s\u53ef\u4ee5\u628aAccount-App\u7684Pod\u96c6\u7fa4\u4fe1\u606f(IP+Port\u7b49)\u81ea\u52a8\u6ce8\u518c\u5230DNS\uff0cClient\u5e94\u7528\u5219\u901a\u8fc7\u57df\u540d\u67e5\u8be2DNS\u53d1\u73b0\u76ee\u6807Pod\uff0c\u7136\u540e\u53d1\u8d77\u8c03\u7528\u3002\u8fd9\u4e2a\u65b9\u6848\u4e0d\u4ec5\u7b80\u5355\uff0c\u800c\u4e14\u5bf9Client\u4e5f\u65e0\u4fb5\u5165(\u76ee\u524d\u51e0\u4e4e\u6240\u6709\u7684\u64cd\u4f5c\u7cfb\u7edf\u90fd\u81ea\u5e26DNS\u5ba2\u6237\u7aef)\u3002\u4f46\u662f\u57fa\u4e8eDNS\u7684\u670d\u52a1\u53d1\u73b0\u4e5f\u6709\u5982\u4e0b\u95ee\u9898\uff1a<\/p>\n\n\n\n<ul><li>\u4e0d\u540cDNS\u5ba2\u6237\u7aef\u5b9e\u73b0\u529f\u80fd\u6709\u5dee\u5f02\uff0c\u6709\u4e9b\u5ba2\u6237\u7aef\u6bcf\u6b21\u8c03\u7528\u90fd\u4f1a\u53bb\u67e5\u8be2DNS\u670d\u52a1\uff0c\u9020\u6210\u4e0d\u5fc5\u8981\u7684\u5f00\u9500\uff0c\u800c\u6709\u4e9b\u5ba2\u6237\u7aef\u5219\u4f1a\u7f13\u5b58DNS\u4fe1\u606f\uff0c\u9ed8\u8ba4\u8d85\u65f6\u65f6\u95f4\u8f83\u957f\uff0c\u5f53\u76ee\u6807PodIP\u53d1\u751f\u53d8\u5316\u65f6(\u5728\u5bb9\u5668\u4e91\u73af\u5883\u4e2d\u662f\u5e38\u6001)\uff0c\u5b58\u5728\u7f13\u5b58\u5237\u65b0\u4e0d\u53ca\u65f6\uff0c\u4f1a\u5bfc\u81f4\u8bbf\u95eePod\u5931\u6548\u3002<\/li><li>DNS\u5ba2\u6237\u7aef\u5b9e\u73b0\u7684\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u4e00\u822c\u90fd\u6bd4\u8f83\u7b80\u5355\uff0c\u5927\u90fd\u662fRoundRobin\uff0c\u6709\u4e9b\u5219\u4e0d\u652f\u6301\u8d1f\u8f7d\u5747\u8861\u8c03\u7528\u3002<\/li><\/ul>\n\n\n\n<p>\u8003\u8651\u5230\u4e0a\u8ff0\u4e0d\u540cDNS\u5ba2\u6237\u7aef\u5b9e\u73b0\u7684\u5dee\u5f02\uff0c\u4e0d\u5728K8s\u63a7\u5236\u8303\u56f4\u5185\uff0c\u6240\u4ee5K8s\u6ca1\u6709\u76f4\u63a5\u91c7\u7528DNS\u6280\u672f\u505a\u670d\u52a1\u53d1\u73b0\u3002\u6ce8\u610f\uff0c\u5b9e\u9645K8s\u662f\u5f15\u5165Kube-DNS\u652f\u6301\u901a\u8fc7\u57df\u540d\u8bbf\u95ee\u670d\u52a1\u7684\uff0c\u4e0d\u8fc7\u8fd9\u662f\u5efa\u7acb\u5728CusterIP\/Service\u7f51\u7edc\u4e4b\u4e0a\uff0c\u8fd9\u4e2a\u6211\u540e\u9762\u4f1a\u5c55\u5f00\u3002<\/p>\n\n\n\n<p>\u53e6\u5916\u4e00\u79cd\u8f83\u65b0\u7684\u670d\u52a1\u53d1\u73b0\u6280\u672f\uff0c\u662f\u5f15\u5165Service Registry+Client\u914d\u5408\u5b9e\u73b0\uff0c\u5728\u5f53\u4e0b\u5fae\u670d\u52a1\u65f6\u4ee3\uff0c\u8fd9\u662f\u4e00\u4e2a\u6bd4\u8f83\u6d41\u884c\u7684\u505a\u6cd5\u3002\u76ee\u524d\u4e3b\u6d41\u7684\u4ea7\u54c1\uff0c\u5982Netflix\u5f00\u6e90\u7684Eureka + Ribbon\uff0cHashiCorp\u5f00\u6e90\u7684Consul\uff0c\u8fd8\u6709\u963f\u91cc\u65b0\u5f00\u6e90Nacos\u7b49\uff0c\u90fd\u662f\u8fd9\u4e2a\u65b9\u6848\u7684\u5178\u578b\u4ee3\u8868\u3002<br><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-323-1024x625.png\" alt=\"\" class=\"wp-image-12349\" width=\"468\" height=\"285\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-323-1024x625.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-323-300x183.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-323-768x469.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-323-1536x937.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-323-830x506.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-323-230x140.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-323-350x214.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-323-480x293.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-323.png 1688w\" sizes=\"(max-width: 468px) 100vw, 468px\" \/><\/figure><\/div>\n\n\n\n<p>\u5728K8s\u4e2d\u5f15\u5165Service Registry\u5b9e\u73b0\u670d\u52a1\u53d1\u73b0\u4e5f\u4e0d\u590d\u6742\uff0cK8s\u81ea\u8eab\u5e26\u5206\u5e03\u5f0f\u5b58\u50a8etcd\u5c31\u53ef\u4ee5\u5b9e\u73b0Service Registry\u3002\u5047\u8bbeK8s\u5f15\u5165Service Registry\u505a\u670d\u52a1\u53d1\u73b0(\u5982\u4e0a\u56fe\u6240\u793a)\uff0c\u8fd0\u884c\u65f6K8s\u53ef\u4ee5\u628aAccount-App\u548cPod\u96c6\u7fa4\u4fe1\u606f(IP + Port\u7b49)\u81ea\u52a8\u6ce8\u518c\u5230Service Registry\uff0cClient\u5e94\u7528\u5219\u901a\u8fc7Service Registry\u67e5\u8be2\u53d1\u73b0\u76ee\u6807Pod\uff0c\u7136\u540e\u53d1\u8d77\u8c03\u7528\u3002\u8fd9\u4e2a\u65b9\u6848\u4e5f\u4e0d\u590d\u6742\uff0c\u800c\u4e14\u5ba2\u6237\u7aef\u53ef\u4ee5\u5b9e\u73b0\u7075\u6d3b\u7684\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\uff0c\u4f46\u662f\u9700\u8981\u5f15\u5165\u5ba2\u6237\u7aef\u914d\u5408\uff0c\u5bf9\u5ba2\u6237\u5e94\u7528\u6709\u4fb5\u5165\u6027\uff0c\u6240\u4ee5K8s\u4e5f\u6ca1\u6709\u76f4\u63a5\u91c7\u7528\u8fd9\u79cd\u65b9\u6848\u3002<\/p>\n\n\n\n<p>K8s\u867d\u7136\u6ca1\u6709\u76f4\u63a5\u91c7\u7528\u4e0a\u8ff0\u65b9\u6848\uff0c\u4f46\u662f\u5b83\u7684Service\u7f51\u7edc\u5b9e\u73b0\u662f\u5728\u4e0a\u9762\u4e24\u79cd\u6280\u672f\u7684\u57fa\u7840\u4e0a\u6269\u5c55\u6f14\u8fdb\u51fa\u6765\u7684\u3002\u5b83\u878d\u5408\u4e86\u4e0a\u8ff0\u65b9\u6848\u7684\u4f18\u70b9\uff0c\u540c\u65f6\u89e3\u51b3\u4e86\u4e0a\u8ff0\u65b9\u6848\u7684\u4e0d\u8db3\uff0c\u4e0b\u8282\u6211\u4f1a\u8be6\u7ec6\u5256\u6790K8s\u7684Service\u7f51\u7edc\u7684\u5b9e\u73b0\u539f\u7406\u3002<\/p>\n\n\n\n<p><strong>4.3 K8s\u7684Service\u7f51\u7edc\u539f\u7406<\/strong><\/p>\n\n\n\n<p>\u524d\u9762\u63d0\u5230\uff0cK8s\u7684\u670d\u52a1\u53d1\u73b0\u673a\u5236\u662f\u5728\u4e0a\u8282\u8bb2\u7684Service Registry + DNS\u57fa\u7840\u4e0a\u53d1\u5c55\u6f14\u8fdb\u51fa\u6765\u7684\uff0c\u4e0b\u56fe\u5c55\u793aK8s\u670d\u52a1\u53d1\u73b0\u7684\u7b80\u5316\u539f\u7406\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-324-1024x513.png\" alt=\"\" class=\"wp-image-12350\" width=\"458\" height=\"229\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-324-1024x513.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-324-300x150.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-324-768x385.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-324-830x416.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-324-230x115.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-324-350x175.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-324-480x240.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-324.png 1446w\" sizes=\"(max-width: 458px) 100vw, 458px\" \/><\/figure><\/div>\n\n\n\n<p><br>\u5728K8s\u5e73\u53f0\u7684\u6bcf\u4e2aWorker\u8282\u70b9\u4e0a\uff0c\u90fd\u90e8\u7f72\u6709\u4e24\u4e2a\u7ec4\u4ef6\uff0c\u4e00\u4e2a\u53ebKubelet\uff0c\u53e6\u5916\u4e00\u4e2a\u53ebKube-Proxy\uff0c\u8fd9\u4e24\u4e2a\u7ec4\u4ef6+Master\u662fK8s\u5b9e\u73b0\u670d\u52a1\u6ce8\u518c\u548c\u53d1\u73b0\u7684\u5173\u952e\u3002\u4e0b\u9762\u6211\u4eec\u770b\u4e0b\u7b80\u5316\u7684\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u6d41\u7a0b\u3002<\/p>\n\n\n\n<ul><li>\u9996\u5148\uff0c\u5728\u670d\u52a1Pod\u5b9e\u4f8b\u53d1\u5e03\u65f6(\u53ef\u4ee5\u5bf9\u5e94K8s\u53d1\u5e03\u4e2d\u7684Kind: Deployment)\uff0cKubelet\u4f1a\u8d1f\u8d23\u542f\u52a8Pod\u5b9e\u4f8b\uff0c\u542f\u52a8\u5b8c\u6210\u540e\uff0cKubelet\u4f1a\u628a\u670d\u52a1\u7684PodIP\u5217\u8868\u6c47\u62a5\u6ce8\u518c\u5230Master\u8282\u70b9\u3002<\/li><li>\u5176\u6b21\uff0c\u901a\u8fc7\u670d\u52a1Service\u7684\u53d1\u5e03(\u5bf9\u5e94K8s\u53d1\u5e03\u4e2d\u7684Kind: Service)\uff0cK8s\u4f1a\u4e3a\u670d\u52a1\u5206\u914dClusterIP\uff0c\u76f8\u5173\u4fe1\u606f\u4e5f\u8bb0\u5f55\u5728Master\u4e0a\u3002<\/li><li>\u7b2c\u4e09\uff0c\u5728\u670d\u52a1\u53d1\u73b0\u9636\u6bb5\uff0cKube-Proxy\u4f1a\u76d1\u542cMaster\u5e76\u53d1\u73b0\u670d\u52a1ClusterIP\u548cPodIP\u5217\u8868\u6620\u5c04\u5173\u7cfb\uff0c\u5e76\u4e14\u4fee\u6539\u672c\u5730\u7684linux iptables\u8f6c\u53d1\u89c4\u5219\uff0c\u6307\u793aiptables\u5728\u63a5\u6536\u5230\u76ee\u6807\u4e3a\u67d0\u4e2aClusterIP\u8bf7\u6c42\u65f6\uff0c\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u5e76\u8f6c\u53d1\u5230\u5bf9\u5e94\u7684PodIP\u4e0a\u3002<\/li><li>\u8fd0\u884c\u65f6\uff0c\u5f53\u6709\u6d88\u8d39\u8005Pod\u9700\u8981\u8bbf\u95ee\u67d0\u4e2a\u76ee\u6807\u670d\u52a1\u5b9e\u4f8b\u7684\u65f6\u5019\uff0c\u5b83\u901a\u8fc7ClusterIP\u53d1\u8d77\u8c03\u7528\uff0c\u8fd9\u4e2aClusterIP\u4f1a\u88ab\u672c\u5730iptables\u673a\u5236\u622a\u83b7\uff0c\u7136\u540e\u901a\u8fc7\u8d1f\u8f7d\u5747\u8861\uff0c\u8f6c\u53d1\u5230\u76ee\u6807\u670d\u52a1Pod\u5b9e\u4f8b\u4e0a\u3002<\/li><\/ul>\n\n\n\n<p>\u5b9e\u9645\u6d88\u8d39\u8005Pod\u4e5f\u5e76\u4e0d\u76f4\u63a5\u8c03\u670d\u52a1\u7684ClusterIP\uff0c\u800c\u662f\u5148\u8c03\u7528\u670d\u52a1\u540d\uff0c\u56e0\u4e3aClusterIP\u4e5f\u4f1a\u53d8(\u4f8b\u5982\u9488\u5bf9TEST\/UAT\/PROD\u7b49\u4e0d\u540c\u73af\u5883\u7684\u53d1\u5e03\uff0cClusterIP\u4f1a\u4e0d\u540c)\uff0c\u53ea\u6709\u670d\u52a1\u540d\u4e00\u822c\u4e0d\u53d8\u3002\u4e3a\u4e86\u5c4f\u853dClusterIP\u7684\u53d8\u5316\uff0cK8s\u5728\u6bcf\u4e2aWorker\u8282\u70b9\u4e0a\u8fd8\u5f15\u5165\u4e86\u4e00\u4e2aKubeDNS\u7ec4\u4ef6\uff0c\u5b83\u4e5f\u76d1\u542cMaster\u5e76\u53d1\u73b0\u670d\u52a1\u540d\u548cClusterIP\u4e4b\u95f4\u6620\u5c04\u5173\u7cfb\uff0c\u8fd9\u6837\uff0c \u6d88\u8d39\u8005Pod\u901a\u8fc7KubeDNS\u53ef\u4ee5\u95f4\u63a5\u53d1\u73b0\u670d\u52a1\u7684ClusterIP\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f\uff0cK8s\u7684\u670d\u52a1\u53d1\u73b0\u673a\u5236\u548c\u76ee\u524d\u5fae\u670d\u52a1\u4e3b\u6d41\u7684\u670d\u52a1\u53d1\u73b0\u673a\u5236(\u5982Eureka + Ribbon)\u603b\u4f53\u539f\u7406\u7c7b\u4f3c\uff0c\u4f46\u662f\u4e5f\u6709\u663e\u8457\u533a\u522b(\u8fd9\u4e9b\u533a\u522b\u4e3b\u8981\u4f53\u73b0\u5728\u5ba2\u6237\u7aef)\uff1a<\/p>\n\n\n\n<ul><li>\u9996\u5148\uff0c\u4e24\u8005\u90fd\u662f\u91c7\u7528\u5ba2\u6237\u7aef\u4ee3\u7406(Proxy)\u673a\u5236\u3002\u548cRibbon\u4e00\u6837\uff0cK8s\u7684\u4ee3\u7406\u8f6c\u53d1\u548c\u8d1f\u8f7d\u5747\u8861\u4e5f\u662f\u5728\u5ba2\u6237\u7aef\u5b9e\u73b0\u7684\uff0c\u4f46Ribbon\u662f\u4ee5Lib\u5e93\u7684\u5f62\u5f0f\u5d4c\u5165\u5728\u5ba2\u6237\u5e94\u7528\u4e2d\u7684\uff0c\u5bf9\u5ba2\u6237\u5e94\u7528\u6709\u4fb5\u5165\u6027\uff0c\u800cK8s\u7684Kube-Proxy\u662f\u72ec\u7acb\u7684\uff0c\u6bcf\u4e2aWorker\u8282\u70b9\u4e0a\u6709\u4e00\u4e2a\uff0c\u5b83\u5bf9\u5ba2\u6237\u5e94\u7528\u65e0\u4fb5\u5165\u3002K8s\u7684\u505a\u6cd5\u7c7b\u4f3cServiceMesh\u4e2d\u7684\u8fb9\u8f66(sidecar)\u505a\u6cd5\u3002<\/li><li>\u7b2c\u4e8c\uff0cRibbon\u7684\u4ee3\u7406\u8f6c\u53d1\u662f\u7a7f\u900f\u7684\uff0c\u800cK8s\u4e2d\u7684\u4ee3\u7406\u8f6c\u53d1\u662fiptables\u8f6c\u53d1\uff0c\u867d\u7136K8s\u4e2d\u6709Kube-Proxy\uff0c\u4f46\u5b83\u53ea\u662f\u8d1f\u8d23\u670d\u52a1\u53d1\u73b0\u548c\u4fee\u6539iptables(\u6216ipvs)\u89c4\u5219\uff0c\u5b9e\u9645\u8bf7\u6c42\u662f\u4e0d\u7a7f\u900fKube-Proxy\u7684\u3002\u6ce8\u610f\u65e9\u671fK8s\u4e2d\u7684Kube-Proxy\u4ee3\u7406\u662f\u7a7f\u900f\u7684\uff0c\u8003\u8651\u5230\u6709\u6027\u80fd\u635f\u8017\u548c\u5355\u70b9\u95ee\u9898\uff0c\u540e\u7eed\u7684\u7248\u672c\u5c31\u6539\u6210\u4e0d\u7a7f\u900f\u4e86\u3002<\/li><li>\u7b2c\u4e09\uff0cRibbon\u5b9e\u73b0\u670d\u52a1\u540d\u5230\u670d\u52a1\u5b9e\u4f8bIP\u5730\u5740\u7684\u6620\u5c04\uff0c\u5b83\u53ea\u6709\u4e00\u5c42\u6620\u5c04\u3002\u800cK8s\u4e2d\u6709\u4e24\u5c42\u6620\u5c04\uff0cKube-Proxy\u5b9e\u73b0ClusterIP->PodIP\u7684\u6620\u5c04\uff0cKube-DNS\u5b9e\u73b0ServiceName->ClusterIP\u7684\u6620\u5c04\u3002<\/li><\/ul>\n\n\n\n<p>\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u5bf9\u6bd4\u76ee\u524d\u5fae\u670d\u52a1\u4e3b\u6d41\u7684\u670d\u52a1\u53d1\u73b0\u673a\u5236\uff0cK8s\u7684\u670d\u52a1\u53d1\u73b0\u673a\u5236\u62bd\u8c61\u5f97\u66f4\u597d\uff0c\u5b83\u901a\u8fc7ClusterIP\u7edf\u4e00\u5c4f\u853d\u670d\u52a1\u53d1\u73b0\u548c\u8d1f\u8f7d\u5747\u8861\uff0c\u4e00\u4e2a\u670d\u52a1\u4e00\u4e2aClusterIP\uff0c\u8fd9\u4e2a\u6a21\u578b\u548c\u4f20\u7edf\u7684IP\u7f51\u7edc\u6a21\u578b\u66f4\u8d34\u8fd1\u548c\u6613\u4e8e\u7406\u89e3\u3002ClusterIP\u4e5f\u662f\u4e00\u4e2aIP\uff0c\u4f46\u8fd9\u4e2aIP\u540e\u9762\u8ddf\u7684\u4e0d\u662f\u4e00\u4e2a\u670d\u52a1\u5b9e\u4f8b\uff0c\u800c\u662f\u4e00\u4e2a\u670d\u52a1\u96c6\u7fa4\uff0c\u6240\u4ee5\u53eb\u96c6\u7fa4ClusterIP\u3002\u540c\u65f6\uff0c\u5b83\u5bf9\u5ba2\u6237\u5e94\u7528\u65e0\u4fb5\u5165\uff0c\u4e14\u4e0d\u7a7f\u900f\u6ca1\u6709\u989d\u5916\u6027\u80fd\u635f\u8017\u3002<\/p>\n\n\n\n<p><strong>4.4 \u603b\u7ed3\u4e00\u4e0b<\/strong><\/p>\n\n\n\n<ul><li>K8s\u7684Service\u7f51\u7edc\u6784\u5efa\u4e8ePod\u7f51\u7edc\u4e4b\u4e0a\uff0c\u5b83\u4e3b\u8981\u76ee\u7684\u662f\u89e3\u51b3\u670d\u52a1\u53d1\u73b0(Service Discovery)\u548c\u8d1f\u8f7d\u5747\u8861(Load Balancing)\u95ee\u9898\u3002<\/li><li>K8s\u901a\u8fc7\u4e00\u4e2aServiceName+ClusterIP\u7edf\u4e00\u5c4f\u853d\u670d\u52a1\u53d1\u73b0\u548c\u8d1f\u8f7d\u5747\u8861\uff0c\u5e95\u5c42\u6280\u672f\u662f\u5728DNS+Service Registry\u57fa\u7840\u4e0a\u53d1\u5c55\u6f14\u8fdb\u51fa\u6765\u3002<\/li><li>K8s\u7684\u670d\u52a1\u53d1\u73b0\u548c\u8d1f\u8f7d\u5747\u8861\u662f\u5728\u5ba2\u6237\u7aef\u901a\u8fc7Kube-Proxy + iptables\u8f6c\u53d1\u5b9e\u73b0\uff0c\u5b83\u5bf9\u5e94\u7528\u65e0\u4fb5\u5165\uff0c\u4e14\u4e0d\u7a7f\u900fProxy\uff0c\u6ca1\u6709\u989d\u5916\u6027\u80fd\u635f\u8017\u3002<\/li><li>K8s\u670d\u52a1\u53d1\u73b0\u673a\u5236\uff0c\u53ef\u4ee5\u8ba4\u4e3a\u662f\u73b0\u4ee3\u5fae\u670d\u52a1\u53d1\u73b0\u673a\u5236\u548c\u4f20\u7edfLinux\u5185\u6838\u673a\u5236\u7684\u4f18\u96c5\u7ed3\u5408\u3002<\/li><\/ul>\n\n\n\n<p>\u6709\u4e86Service\u62bd\u8c61\uff0cK8s\u4e2d\u90e8\u7f72\u7684\u5e94\u7528\u90fd\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a\u62bd\u8c61\u7684ClusterIP\u8fdb\u884c\u5bfb\u5740\u8bbf\u95ee\uff0c\u5e76\u4e14\u6d88\u8d39\u65b9\u4e0d\u9700\u8981\u5173\u5fc3\u8fd9\u4e2aClusterIP\u540e\u9762\u7a76\u7adf\u6709\u591a\u5c11\u4e2aPod\u5b9e\u4f8b\uff0c\u5b83\u4eec\u7684PodIP\u662f\u4ec0\u4e48\uff0c\u4f1a\u4e0d\u4f1a\u53d8\u5316\uff0c\u5982\u4f55\u4ee5\u8d1f\u8f7d\u5747\u8861\u65b9\u5f0f\u53bb\u8bbf\u95ee\u7b49\u95ee\u9898\u3002\u4f46\u662f\uff0cK8s\u7684Service\u7f51\u7edc\u53ea\u662f\u4e00\u4e2a\u96c6\u7fa4\u5185\u53ef\u89c1\u7684\u5185\u90e8\u7f51\u7edc\uff0c\u96c6\u7fa4\u5916\u90e8\u662f\u770b\u4e0d\u5230Service\u7f51\u7edc\u7684\uff0c\u4e5f\u65e0\u6cd5\u76f4\u63a5\u8bbf\u95ee\u3002\u800c\u6211\u4eec\u53d1\u5e03\u5e94\u7528\uff0c\u6709\u4e9b\u662f\u9700\u8981\u66b4\u9732\u51fa\u53bb\uff0c\u8981\u8ba9\u5916\u7f51\u751a\u81f3\u516c\u7f51\u80fd\u591f\u8bbf\u95ee\u7684\uff0c\u8fd9\u6837\u624d\u80fd\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\u3002K8s\u5982\u4f55\u5c06\u5185\u90e8\u670d\u52a1\u66b4\u9732\u51fa\u53bb? \uff0c \u8bf7\u63a5\u7740\u5f80\u4e0b\u770b\u3002<br><\/p>\n\n\n\n<p><strong>\u4e94\u3001\u7b2c3\u5c42\uff1a\u5916\u90e8\u6d41\u91cf\u63a5\u5165<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>K8s\u7684Service\u7f51\u7edc\u53ea\u662f\u4e00\u4e2a\u96c6\u7fa4\u5185\u90e8\u7f51\u7edc\uff0c\u96c6\u7fa4\u5916\u90e8\u662f\u65e0\u6cd5\u76f4\u63a5\u8bbf\u95ee\u7684\u3002\u4e3a\u6b64\uff0c\u60f3\u8981\u5c06\u5e94\u7528\u66b4\u9732\u51fa\u53bb\u8ba9\u516c\u7f51\u80fd\u591f\u8bbf\u95ee\uff0cK8S\u63d0\u4f9b\u4e86\u4e24\u79cd\u65b9\u5f0f\uff1a<\/p>\n\n\n\n<p>\u5728\u8bb2\u5230K8s\u5982\u4f55\u63a5\u5165\u5916\u90e8\u6d41\u91cf\u7684\u65f6\u5019\uff0c\u5927\u5bb6\u5e38\u5e38\u4f1a\u542c\u5230NodePort\uff0cLoadBalancer\u548cIngress\u7b49\u6982\u5ff5\uff0c\u8fd9\u4e9b\u6982\u5ff5\u90fd\u662f\u548cK8s\u5916\u90e8\u6d41\u91cf\u63a5\u5165\u76f8\u5173\u7684\uff0c\u5b83\u4eec\u65e2\u662f\u4e0d\u540c\u6982\u5ff5\uff0c\u540c\u65f6\u53c8\u6709\u5173\u8054\u6027\u3002\u4e0b\u9762\u6211\u4eec\u5206\u522b\u89e3\u91ca\u8fd9\u4e9b\u6982\u5ff5\u548c\u5b83\u4eec\u4e4b\u95f4\u7684\u5173\u7cfb\u3002<\/p>\n\n\n\n<p><strong>5.1 NodePort<\/strong><\/p>\n\n\n\n<p>\u5148\u63d0\u524d\u5f3a\u8c03\u4e00\u4e0b\uff0cNodePort\u662fK8s\u5c06\u5185\u90e8\u670d\u52a1\u5bf9\u5916\u66b4\u9732\u7684\u57fa\u7840\uff0c\u540e\u9762\u7684LoadBalancer\u5e95\u5c42\u6709\u8d56\u4e8eNodePort\u3002<\/p>\n\n\n\n<p>\u4e4b\u524d\u6211\u4eec\u8bb2\u4e86K8s\u7f51\u7edc\u76844\u5c42\u62bd\u8c61\uff0cService\u7f51\u7edc\u5728\u7b2c2\u5c42\uff0c\u8282\u70b9\u7f51\u7edc\u5728\u7b2c0\u5c42\u3002\u5b9e\u9645\u4e0a\uff0c\u53ea\u6709\u8282\u70b9\u7f51\u7edc\u662f\u53ef\u4ee5\u76f4\u63a5\u5bf9\u5916\u66b4\u9732\u7684\uff0c\u5177\u4f53\u66b4\u9732\u65b9\u5f0f\u8981\u770b\u6570\u636e\u4e2d\u5fc3\u6216\u516c\u6709\u4e91\u7684\u5e95\u5c42\u7f51\u7edc\u90e8\u7f72\uff0c\u4f46\u4e0d\u7ba1\u91c7\u7528\u4f55\u79cd\u90e8\u7f72\uff0c\u8282\u70b9\u7f51\u7edc\u5bf9\u5916\u66b4\u9732\u662f\u5b8c\u5168\u6ca1\u6709\u95ee\u9898\u7684\u3002\u90a3\u4e48\u73b0\u5728\u7684\u95ee\u9898\u662f\uff0c\u7b2c2\u5c42\u7684Service\u7f51\u7edc\u5982\u4f55\u901a\u8fc7\u7b2c0\u5c42\u7684\u8282\u70b9\u7f51\u7edc\u66b4\u9732\u51fa\u53bb\uff1f\u6211\u4eec\u53ef\u4ee5\u56de\u770b\u4e00\u4e0bK8s\u670d\u52a1\u53d1\u73b0\u7684\u539f\u7406\u56fe\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u7136\u540e\u4e0d\u59a8\u601d\u8003\u4e00\u4e0b\uff0cK8s\u96c6\u7fa4\u4e2d\u6709\u54ea\u4e00\u4e2a\u89d2\u8272\uff0c\u5373\u638c\u63e1Service\u7f51\u7edc\u7684\u6240\u6709\u4fe1\u606f\uff0c\u53ef\u4ee5\u548cService\u7f51\u7edc\u4ee5\u53caPod\u7f51\u7edc\u4e92\u901a\u4e92\u8054\uff0c\u540c\u65f6\u53c8\u53ef\u4ee5\u548c\u8282\u70b9\u7f51\u7edc\u6253\u901a\uff1f<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-325-1024x497.png\" alt=\"\" class=\"wp-image-12353\" width=\"465\" height=\"225\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-325-1024x497.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-325-300x146.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-325-768x373.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-325-830x403.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-325-230x112.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-325-350x170.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-325-480x233.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-325.png 1306w\" sizes=\"(max-width: 465px) 100vw, 465px\" \/><\/figure><\/div>\n\n\n\n<p>\u7b54\u6848\u662fKube-Proxy\u3002\u4e0a\u4e00\u7bc7\u6211\u4eec\u63d0\u5230Kube-Proxy\u662fK8s\u5185\u90e8\u670d\u52a1\u53d1\u73b0\u7684\u4e00\u4e2a\u5173\u952e\u7ec4\u4ef6\uff0c\u4e8b\u5b9e\u4e0a\uff0c\u5b83\u8fd8\u662fK8s\u5c06\u5185\u90e8\u670d\u52a1\u66b4\u9732\u51fa\u53bb\u7684\u5173\u952e\u7ec4\u4ef6\u3002Kube-Proxy\u5728K8s\u96c6\u7fa4\u4e2d\u6240\u6709Worker\u8282\u70b9\u4e0a\u90fd\u90e8\u7f72\u6709\u4e00\u4e2a\uff0c\u5b83\u638c\u63e1Service\u7f51\u7edc\u7684\u6240\u6709\u4fe1\u606f\uff0c\u77e5\u9053\u600e\u4e48\u548cService\u7f51\u7edc\u4ee5\u53caPod\u7f51\u7edc\u4e92\u901a\u4e92\u8054\u3002\u5982\u679c\u8981\u5c06Kube-Proxy\u548c\u8282\u70b9\u7f51\u7edc\u6253\u901a(\u4ece\u800c\u5c06\u67d0\u4e2a\u670d\u52a1\u901a\u8fc7Kube-Proxy\u66b4\u9732\u51fa\u53bb)\uff0c\u53ea\u9700\u8981\u8ba9Kube-Proxy\u5728\u8282\u70b9\u4e0a\u66b4\u9732\u4e00\u4e2a\u76d1\u542c\u7aef\u53e3\u5373\u53ef\u3002\u8fd9\u79cd\u901a\u8fc7Kube-Proxy\u5728\u8282\u70b9\u4e0a\u66b4\u9732\u4e00\u4e2a\u76d1\u542c\u7aef\u53e3\uff0c\u5c06K8s\u5185\u90e8\u670d\u52a1\u901a\u8fc7Kube-Proxy\u66b4\u9732\u51fa\u53bb\u7684\u65b9\u5f0f\uff0c\u672f\u8bed\u5c31\u53ebNodePort(\u987e\u540d\u601d\u4e49\uff0c\u7aef\u53e3\u66b4\u9732\u5728\u8282\u70b9\u4e0a)\u3002\u4e0b\u56fe\u662f\u901a\u8fc7NodePort\u66b4\u9732\u670d\u52a1\u7684\u7b80\u5316\u6982\u5ff5\u6a21\u578b\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-326-1024x615.png\" alt=\"\" class=\"wp-image-12354\" width=\"472\" height=\"283\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-326-1024x615.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-326-300x180.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-326-768x461.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-326-830x499.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-326-230x138.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-326-350x210.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-326-480x288.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-326.png 1322w\" sizes=\"(max-width: 472px) 100vw, 472px\" \/><\/figure><\/div>\n\n\n\n<p>\u5982\u679c\u6211\u4eec\u8981\u5c06K8s\u5185\u90e8\u7684\u4e00\u4e2a\u670d\u52a1\u901a\u8fc7NodePort\u65b9\u5f0f\u66b4\u9732\u51fa\u53bb\uff0c\u53ef\u4ee5\u5c06\u670d\u52a1\u53d1\u5e03(kind: Service)\u7684type\u8bbe\u5b9a\u4e3aNodePort\uff0c\u540c\u65f6\u6307\u5b9a\u4e00\u4e2a30000~32767\u8303\u56f4\u5185\u7684\u7aef\u53e3\u3002\u670d\u52a1\u53d1\u5e03\u4ee5\u540e\uff0cK8s\u5728\u6bcf\u4e2aWorker\u8282\u70b9\u4e0a\u90fd\u4f1a\u5f00\u542f\u8fd9\u4e2a\u76d1\u542c\u7aef\u53e3\u3002\u8fd9\u4e2a\u7aef\u53e3\u7684\u80cc\u540e\u662fKube-Proxy\uff0c\u5f53K8s\u5916\u90e8\u6709Client\u8981\u8bbf\u95eeK8s\u96c6\u7fa4\u5185\u7684\u67d0\u4e2a\u670d\u52a1\uff0c\u5b83\u901a\u8fc7\u8fd9\u4e2a\u670d\u52a1\u7684NodePort\u7aef\u53e3\u53d1\u8d77\u8c03\u7528\uff0c\u8fd9\u4e2a\u8c03\u7528\u901a\u8fc7Kube-Proxy\u8f6c\u53d1\u5230\u5185\u90e8\u7684Servcie\u62bd\u8c61\u5c42\uff0c\u7136\u540e\u518d\u8f6c\u53d1\u5230\u76ee\u6807Pod\u4e0a\u3002Kube-Proxy\u8f6c\u53d1\u4ee5\u53ca\u4e4b\u540e\u7684\u73af\u8282\uff0c\u53ef\u4ee5\u548c\u4e0a\u4e00\u7bc7\u300aKubernetes\u7f51\u7edc\u4e09\u90e8\u66f2\uff5eService\u7f51\u7edc\u300b\u7684\u5185\u5bb9\u5bf9\u63a5\u8d77\u6765\u3002\u6ce8\u610f\uff0c\u4e3a\u4e86\u76f4\u89c2\u5f62\u8c61\uff0c\u4e0a\u56fe\u7684Service\u5728K8s\u96c6\u7fa4\u4e2d\u88ab\u753b\u6210\u4e00\u4e2a\u72ec\u7acb\u7ec4\u4ef6\uff0c\u5b9e\u9645\u662f\u6ca1\u6709\u72ec\u7acbService\u8fd9\u6837\u4e00\u4e2a\u7ec4\u4ef6\u7684\uff0c\u53ea\u662f\u4e00\u4e2a\u62bd\u8c61\u6982\u5ff5\uff0c\u5982\u679c\u8981\u7406\u89e3\u8fd9\u4e2a\u62bd\u8c61\u7684\u5e95\u5c42\u5b9e\u73b0\u7ec6\u8282\uff0c\u53ef\u4ee5\u56de\u5934\u770b\u4e0a\u4e00\u56fe\u7684K8s\u670d\u52a1\u53d1\u73b0\u539f\u7406\u3002<\/p>\n\n\n\n<p><strong>5.2 LoadBalancer<\/strong><\/p>\n\n\n\n<p>\u4e0a\u9762\u6211\u4eec\u63d0\u5230\uff0c\u5c06K8s\u5185\u90e8\u7684\u670d\u52a1\u901a\u8fc7NodePort\u65b9\u5f0f\u66b4\u9732\u51fa\u53bb\uff0cK8s\u4f1a\u5728\u6bcf\u4e2aWorker\u8282\u70b9\u4e0a\u90fd\u5f00\u542f\u5bf9\u5e94\u7684NodePort\u7aef\u53e3\u3002\u903b\u8f91\u4e0a\u770b\uff0cK8s\u96c6\u7fa4\u4e2d\u7684\u6240\u6709\u8282\u70b9\u90fd\u4f1a\u66b4\u9732\u8fd9\u4e2a\u670d\u52a1\uff0c\u6216\u8005\u8bf4\u8fd9\u4e2a\u670d\u52a1\u662f\u4ee5\u96c6\u7fa4\u65b9\u5f0f\u66b4\u9732\u7684(\u5b9e\u9645\u652f\u6301\u8fd9\u4e2a\u670d\u52a1\u7684Pod\u53ef\u80fd\u5c31\u5206\u5e03\u5728\u5176\u4e2d\u6709\u9650\u51e0\u4e2a\u8282\u70b9\u4e0a\uff0c\u4f46\u662f\u56e0\u4e3a\u6240\u6709\u8282\u70b9\u4e0a\u90fd\u6709Kube-Proxy\uff0c\u6240\u4ee5\u6240\u6709\u8282\u70b9\u90fd\u77e5\u9053\u8be5\u5982\u4f55\u8f6c\u53d1)\u3002\u65e2\u7136\u662f\u96c6\u7fa4\uff0c\u5c31\u4f1a\u6d89\u53ca\u8d1f\u8f7d\u5747\u8861\u95ee\u9898\uff0c\u8c01\u8d1f\u8d23\u5bf9\u8fd9\u4e2a\u670d\u52a1\u7684\u8d1f\u8f7d\u5747\u8861\u8bbf\u95ee\uff1f\u7b54\u6848\u662f\u9700\u8981\u5f15\u5165\u8d1f\u8f7d\u5747\u8861\u5668(Load Balancer)\u3002\u4e0b\u56fe\u662f\u901a\u8fc7LoadBalancer\uff0c\u5c06\u670d\u52a1\u5bf9\u5916\u66b4\u9732\u7684\u6982\u5ff5\u6a21\u578b\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-327-1024x777.png\" alt=\"\" class=\"wp-image-12355\" width=\"457\" height=\"346\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-327-1024x777.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-327-300x228.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-327-768x583.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-327-830x630.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-327-230x175.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-327-350x266.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-327-480x364.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-327.png 1296w\" sizes=\"(max-width: 457px) 100vw, 457px\" \/><\/figure><\/div>\n\n\n\n<p><br>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u5957\u963f\u91cc\u4e91K8s\u73af\u5883\uff0c\u8981\u5c06K8s\u5185\u90e8\u7684\u4e00\u4e2a\u670d\u52a1\u901a\u8fc7LoadBalancer\u65b9\u5f0f\u66b4\u9732\u51fa\u53bb\uff0c\u53ef\u4ee5\u5c06\u670d\u52a1\u53d1\u5e03(Kind: Service)\u7684type\u8bbe\u5b9a\u4e3aLoadBalancer\u3002\u670d\u52a1\u53d1\u5e03\u540e\uff0c\u963f\u91cc\u4e91K8s\u4e0d\u4ec5\u4f1a\u81ea\u52a8\u521b\u5efa\u670d\u52a1\u7684NodePort\u7aef\u53e3\u8f6c\u53d1\uff0c\u540c\u65f6\u4f1a\u81ea\u52a8\u5e2e\u6211\u4eec\u7533\u8bf7\u4e00\u4e2aSLB\uff0c\u6709\u72ec\u7acb\u516c\u7f51IP\uff0c\u5e76\u4e14\u963f\u91cc\u4e91K8s\u4f1a\u5e2e\u6211\u4eec\u81ea\u52a8\u628aSLB\u6620\u5c04\u5230\u540e\u53f0K8s\u96c6\u7fa4\u7684\u5bf9\u5e94NodePort\u4e0a\u3002\u8fd9\u6837\uff0c\u901a\u8fc7SLB\u7684\u516c\u7f51IP\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8bbf\u95ee\u5230K8s\u5185\u90e8\u670d\u52a1\uff0c\u963f\u91cc\u4e91SLB\u8d1f\u8f7d\u5747\u8861\u5668\u4f1a\u5728\u80cc\u540e\u505a\u8d1f\u8f7d\u5747\u8861\u3002<\/p>\n\n\n\n<p>\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff0c\u5982\u679c\u662f\u5728\u672c\u5730\u5f00\u53d1\u6d4b\u8bd5\u73af\u5883\u91cc\u5934\u642d\u5efa\u7684K8s\uff0c\u4e00\u822c\u4e0d\u652f\u6301Load Balancer\u4e5f\u6ca1\u5fc5\u8981\uff0c\u56e0\u4e3a\u901a\u8fc7NodePort\u505a\u6d4b\u8bd5\u8bbf\u95ee\u5c31\u591f\u4e86\u3002\u4f46\u662f\u5728\u751f\u4ea7\u73af\u5883\u6216\u8005\u516c\u6709\u4e91\u4e0a\u7684K8s\uff0c\u4f8b\u5982GCP\u6216\u8005\u963f\u91cc\u4e91K8s\uff0c\u57fa\u672c\u90fd\u652f\u6301\u81ea\u52a8\u521b\u5efaLoad Balancer\u3002<br><\/p>\n\n\n\n<p><strong>5.3 Ingress<\/strong><\/p>\n\n\n\n<p>\u6709\u4e86\u524d\u9762\u7684NodePort + LoadBalancer\uff0c\u5c06K8s\u5185\u90e8\u670d\u52a1\u66b4\u9732\u5230\u5916\u7f51\u751a\u81f3\u516c\u7f51\u7684\u9700\u6c42\u5c31\u5df2\u7ecf\u5b9e\u73b0\u4e86\uff0c\u90a3\u4e48\u4e3a\u5565\u8fd8\u8981\u5f15\u5165Ingress\u8fd9\u6837\u4e00\u4e2a\u6982\u5ff5\u5462\uff1f\u5b83\u8d77\u4ec0\u4e48\u4f5c\u7528\uff1f<\/p>\n\n\n\n<p>\u6211\u4eec\u77e5\u9053\u5728\u516c\u6709\u4e91(\u963f\u91cc\u4e91\/AWS\/GCP)\u4e0a\uff0c\u516c\u7f51LB+IP\u662f\u9700\u8981\u82b1\u94b1\u4e70\u7684\u3002\u6211\u4eec\u56de\u770b\u4e0a\u56fe\u7684\u901a\u8fc7LoadBalancer(\u7b80\u79f0LB)\u66b4\u9732\u670d\u52a1\u7684\u65b9\u5f0f\uff0c\u53d1\u73b0\u8981\u66b4\u9732\u4e00\u4e2a\u670d\u52a1\u5c31\u9700\u8981\u8d2d\u4e70\u4e00\u4e2a\u72ec\u7acb\u7684LB+IP\uff0c\u5982\u679c\u8981\u66b4\u9732\u5341\u4e2a\u670d\u52a1\u5c31\u9700\u8981\u8d2d\u4e70\u5341\u4e2aLB+IP\uff0c\u663e\u7136\uff0c\u4ece\u6210\u672c\u8003\u8651\u8fd9\u662f\u4e0d\u5212\u7b97\u4e5f\u4e0d\u53ef\u6269\u5c55\u7684\u3002\u90a3\u4e48\uff0c\u6709\u6ca1\u6709\u529e\u6cd5\u53ea\u9700\u8d2d\u4e70\u4e00\u4e2a(\u6216\u8005\u5c11\u91cf)\u7684LB+IP\uff0c\u4f46\u662f\u5374\u53ef\u4ee5\u6309\u9700\u66b4\u9732\u66f4\u591a\u670d\u52a1\u51fa\u53bb\u5462\uff1f\u7b54\u6848\u5176\u5b9e\u4e0d\u590d\u6742\uff0c\u5c31\u662f\u60f3\u529e\u6cd5\u5728K8\u5185\u90e8\u90e8\u7f72\u4e00\u4e2a\u72ec\u7acb\u7684\u53cd\u5411\u4ee3\u7406\u670d\u52a1\uff0c\u8ba9\u5b83\u505a\u4ee3\u7406\u8f6c\u53d1\u3002\u8c37\u6b4c\u7ed9\u8fd9\u4e2a\u5185\u90e8\u72ec\u7acb\u90e8\u7f72\u7684\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u8d77\u4e86\u4e00\u4e2a\u5947\u602a\u7684\u540d\u5b57\uff0c\u5c31\u53ebIngress\uff0c\u5b83\u7684\u7b80\u5316\u6982\u5ff5\u6a21\u578b\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-328-1024x779.png\" alt=\"\" class=\"wp-image-12356\" width=\"463\" height=\"353\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-328-1024x779.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-328-300x228.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-328-768x585.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-328-830x632.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-328-230x175.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-328-350x266.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-328-480x365.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-328.png 1298w\" sizes=\"(max-width: 463px) 100vw, 463px\" \/><\/figure><\/div>\n\n\n\n<p>Ingress\u5c31\u662f\u4e00\u4e2a\u7279\u6b8a\u7684Service\uff0c\u901a\u8fc7\u8282\u70b9\u7684<strong>HostPort(80\/443)<\/strong>\u66b4\u9732\u51fa\u53bb\uff0c\u524d\u7f6e\u4e00\u822c\u4e5f\u6709LB\u505a\u8d1f\u8f7d\u5747\u8861\u3002Ingress\u8f6c\u53d1\u5230\u5185\u90e8\u7684\u5176\u5b83\u670d\u52a1\uff0c\u662f\u901a\u8fc7\u96c6\u7fa4\u5185\u7684Service\u62bd\u8c61\u5c42\/ClusterIP\u8fdb\u884c\u8f6c\u53d1\uff0c\u6700\u7ec8\u8f6c\u53d1\u5230\u76ee\u6807\u670d\u52a1Pod\u4e0a\u3002Ingress\u7684\u8f6c\u53d1\u53ef\u4ee5\u57fa\u4e8ePath\u8f6c\u53d1\uff0c\u4e5f\u53ef\u4ee5\u57fa\u4e8e\u57df\u540d\u8f6c\u53d1\u7b49\u65b9\u5f0f\uff0c\u57fa\u672c\u4e0a\u4f60\u53ea\u9700\u7ed9\u5b83\u8bbe\u7f6e\u597d\u8f6c\u53d1\u8def\u7531\u8868\u5373\u53ef\uff0c\u529f\u80fd\u548cNginx\u65e0\u672c\u8d28\u5dee\u522b\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f\uff0c\u4e0a\u56fe\u7684Ingress\u6982\u5ff5\u6a21\u578b\u662f\u4e00\u79cd\u66f4\u62bd\u8c61\u7684\u753b\u6cd5\uff0c\u9690\u53bb\u4e86K8s\u96c6\u7fa4\u4e2d\u7684\u8282\u70b9\uff0c\u5b9e\u9645HostPort\u662f\u66b4\u9732\u5728\u8282\u70b9\u4e0a\u7684\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\uff0cIngress\u5e76\u4e0d\u662f\u4ec0\u4e48\u795e\u5947\u7684\u4e1c\u897f\uff0c\u9996\u5148\uff0c\u5b83\u672c\u8d28\u4e0a\u5c31\u662fK8s\u96c6\u7fa4\u4e2d\u7684\u4e00\u4e2a\u6bd4\u8f83\u7279\u6b8a\u7684Service(\u53d1\u5e03Kind: Ingress)\u3002\u5176\u6b21\uff0c\u8fd9\u4e2aService\u63d0\u4f9b\u7684\u529f\u80fd\u4e3b\u8981\u5c31\u662f7\u5c42\u53cd\u5411\u4ee3\u7406(\u4e5f\u53ef\u4ee5\u63d0\u4f9b\u5b89\u5168\u8ba4\u8bc1\uff0c\u76d1\u63a7\uff0c\u9650\u6d41\u548cSSL\u8bc1\u4e66\u7b49\u9ad8\u7ea7\u529f\u80fd)\uff0c\u529f\u80fd\u7c7b\u4f3cNginx\u3002\u7b2c\u4e09\uff0c\u8fd9\u4e2aService\u5bf9\u5916\u66b4\u9732\u51fa\u53bb\u662f\u901a\u8fc7HostPort(80\/443)\uff0c\u53ef\u4ee5\u548c\u4e0a\u9762LoadBalancer\u5bf9\u63a5\u8d77\u6765\u3002\u6709\u4e86\u8fd9\u4e2aIngress Service\uff0c\u6211\u4eec\u53ef\u4ee5\u505a\u5230\u53ea\u9700\u8d2d\u4e70\u4e00\u4e2aLB+IP\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7Ingress\u5c06\u5185\u90e8\u591a\u4e2a(\u751a\u81f3\u5168\u90e8)\u670d\u52a1\u66b4\u9732\u51fa\u53bb\uff0cIngress\u4f1a\u5e2e\u5fd9\u505a\u4ee3\u7406\u8f6c\u53d1\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u54ea\u4e9b\u8f6f\u4ef6\u53ef\u4ee5\u505a\u8fd9\u4e2aIngress\uff1f\u4f20\u7edf\u7684Nginx\/Haproxy\u53ef\u4ee5\uff0c\u73b0\u4ee3\u7684\u5fae\u670d\u52a1\u7f51\u5173Zuul\/SpringCloudGateway\/Kong\/Envoy\/Traefik\u7b49\u7b49\u90fd\u53ef\u4ee5\u3002\u5f53\u7136\uff0c\u8c37\u6b4c\u522b\u51fa\u5fc3\u88c1\u7ed9\u8fd9\u4e2a\u4e1c\u4e1c\u8d77\u540d\u53ebIngress\uff0c\u5b83\u8fd8\u662f\u505a\u4e86\u4e00\u4e9b\u5305\u88c5\uff0c\u4ee5\u7b80\u5316\u5bf9Ingress\u7684\u64cd\u4f5c\u3002\u5982\u679c\u4f60\u7406\u89e3\u4e86\u539f\u7406\uff0c\u90a3\u4e48\u5b8c\u5168\u53ef\u4ee5\u7528Zuul\u6216\u8005SpringCloudGateway\uff0c\u6216\u8005\u81ea\u5df1\u5b9a\u5236\u5f00\u53d1\u4e00\u4e2a\u53cd\u5411\u4ee3\u7406\uff0c\u6765\u66ff\u4ee3\u8fd9\u4e2aIngress\u3002\u90e8\u7f72\u7684\u65f6\u5019\u4ee5\u666e\u901aService\u90e8\u7f72\uff0c\u5c06type\u8bbe\u5b9a\u4e3aLoadBalancer\u5373\u53ef\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-329-1024x773.png\" alt=\"\" class=\"wp-image-12357\" width=\"502\" height=\"379\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-329-1024x773.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-329-300x227.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-329-768x580.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-329-830x627.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-329-230x174.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-329-350x264.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-329-480x363.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-329.png 1316w\" sizes=\"(max-width: 502px) 100vw, 502px\" \/><\/figure><\/div>\n\n\n\n<p>\u6ce8\u610f\uff0cIngress\u662f\u4e00\u4e2a7\u5c42\u53cd\u5411\u4ee3\u7406\uff0c\u5982\u679c\u4f60\u8981\u66b4\u9732\u7684\u662f4\u5c42\u670d\u52a1\uff0c\u8fd8\u662f\u9700\u8981\u8d70\u72ec\u7acbLB+IP\u65b9\u5f0f\u3002<\/p>\n\n\n\n<p><strong>5.4 Kubectl Proxy &amp; Port Forward<\/strong><\/p>\n\n\n\n<p>\u4e0a\u9762\u63d0\u5230\u7684\u670d\u52a1\u66b4\u9732\u65b9\u6848\uff0c\u5305\u62ecNodePort\/LoadBalancer\/Ingress\uff0c\u4e3b\u8981\u9488\u5bf9\u6b63\u5f0f\u751f\u4ea7\u73af\u5883\u3002\u5982\u679c\u5728\u672c\u5730\u5f00\u53d1\u6d4b\u8bd5\u73af\u5883\uff0c\u9700\u8981\u5bf9\u672c\u5730\u90e8\u7f72\u7684K8s\u73af\u5883\u4e2d\u7684\u670d\u52a1\u6216\u8005Pod\u8fdb\u884c\u5feb\u901f\u8c03\u8bd5\u6216\u6d4b\u8bd5\uff0c\u8fd8\u6709\u51e0\u79cd\u7b80\u6613\u529e\u6cd5\uff0c\u8fd9\u8fb9\u4e00\u5e76\u7b80\u5355\u4ecb\u7ecd\u4e0b\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-330-1024x626.png\" alt=\"\" class=\"wp-image-12358\" width=\"463\" height=\"282\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-330-1024x626.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-330-300x183.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-330-768x469.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-330-830x507.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-330-230x141.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-330-350x214.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-330-480x293.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-330.png 1270w\" sizes=\"(max-width: 463px) 100vw, 463px\" \/><\/figure><\/div>\n\n\n\n<ul><li>\u529e\u6cd5\u4e00\uff0c\u901a\u8fc7kubectl proxy\u547d\u4ee4\uff0c\u5728\u672c\u673a\u4e0a\u5f00\u542f\u4e00\u4e2a\u4ee3\u7406\u670d\u52a1\uff0c\u901a\u8fc7\u8fd9\u4e2a\u4ee3\u7406\u670d\u52a1\uff0c\u53ef\u4ee5\u8bbf\u95eeK8s\u96c6\u7fa4\u5185\u7684\u4efb\u610f\u670d\u52a1\u3002\u80cc\u540e\uff0c\u8fd9\u4e2aKubectl\u4ee3\u7406\u670d\u52a1\u901a\u8fc7Master\u4e0a\u7684API Server\u95f4\u63a5\u8bbf\u95eeK8s\u96c6\u7fa4\u5185\u670d\u52a1\uff0c\u56e0\u4e3aMaster\u77e5\u9053\u96c6\u7fa4\u5185\u6240\u6709\u670d\u52a1\u4fe1\u606f\u3002\u8fd9\u79cd\u65b9\u5f0f\u53ea\u9650\u4e8e7\u5c42HTTP\u8f6c\u53d1\u3002<\/li><li>\u529e\u6cd5\u4e8c\uff0c\u901a\u8fc7kubectl port-forward\u547d\u4ee4\uff0c\u5b83\u53ef\u4ee5\u5728\u672c\u673a\u4e0a\u5f00\u542f\u4e00\u4e2a\u8f6c\u53d1\u7aef\u53e3\uff0c\u95f4\u63a5\u8f6c\u53d1\u5230K8s\u5185\u90e8\u7684\u67d0\u4e2aPod\u7684\u7aef\u53e3\u4e0a\u3002\u8fd9\u6837\u6211\u4eec\u901a\u8fc7\u672c\u673a\u7aef\u53e3\u5c31\u53ef\u4ee5\u8bbf\u95eeK8s\u96c6\u7fa4\u5185\u7684\u67d0\u4e2aPod\u3002\u8fd9\u79cd\u65b9\u5f0f\u662fTCP\u8f6c\u53d1\uff0c\u4e0d\u9650\u4e8eHTTP\u3002<\/li><li>\u529e\u6cd5\u4e09\uff0c\u901a\u8fc7kubectl exec\u547d\u4ee4\u76f4\u63a5\u8fde\u5230Pod\u4e0a\u53bb\u6267\u884clinux\u547d\u4ee4\uff0c\u529f\u80fd\u7c7b\u4f3cdocker exec\u3002<\/li><\/ul>\n\n\n\n<p><strong>\u516d\u3001\u603b\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ul><li>NodePort\u662fK8s\u5185\u90e8\u670d\u52a1\u5bf9\u5916\u66b4\u9732\u7684\u57fa\u7840\uff0cLoadBalancer\u5e95\u5c42\u6709\u8d56\u4e8eNodePort\u3002NodePort\u80cc\u540e\u662fKube-Proxy\uff0cKube-Proxy\u662f\u6c9f\u901aService\u7f51\u7edc\u3001Pod\u7f51\u7edc\u548c\u8282\u70b9\u7f51\u7edc\u7684\u6865\u6881\u3002<\/li><li>\u5c06K8s\u670d\u52a1\u901a\u8fc7NodePort\u5bf9\u5916\u66b4\u9732\u662f\u4ee5\u96c6\u7fa4\u65b9\u5f0f\u66b4\u9732\u7684\uff0c\u6bcf\u4e2a\u8282\u70b9\u4e0a\u90fd\u4f1a\u66b4\u9732\u76f8\u5e94\u7684NodePort\uff0c\u901a\u8fc7LoadBalancer\u53ef\u4ee5\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u8bbf\u95ee\u3002\u516c\u6709\u4e91(\u5982\u963f\u91cc\u4e91\/AWS\/GCP)\u63d0\u4f9b\u7684K8s\uff0c\u90fd\u652f\u6301\u81ea\u52a8\u90e8\u7f72LB\uff0c\u4e14\u63d0\u4f9b\u516c\u7f51\u53ef\u8bbf\u95eeIP\uff0cLB\u80cc\u540e\u5bf9\u63a5NodePort\u3002<\/li><li>Ingress\u626e\u6f14\u7684\u89d2\u8272\u662f\u5bf9K8s\u5185\u90e8\u670d\u52a1\u8fdb\u884c\u96c6\u4e2d\u53cd\u5411\u4ee3\u7406\uff0c\u901a\u8fc7Ingress\uff0c\u6211\u4eec\u53ef\u4ee5\u540c\u65f6\u5bf9\u5916\u66b4\u9732K8s\u5185\u90e8\u7684\u591a\u4e2a\u670d\u52a1\uff0c\u4f46\u662f\u53ea\u9700\u8981\u8d2d\u4e701\u4e2a(\u6216\u8005\u5c11\u91cf)LB\u3002Ingress\u672c\u8d28\u4e5f\u662f\u4e00\u79cdK8s\u7684\u7279\u6b8aService\uff0c\u5b83\u4e5f\u901a\u8fc7HostPort(80\/443)\u5bf9\u5916\u66b4\u9732\u3002<\/li><li>\u901a\u8fc7Kubectl Proxy\u6216\u8005Port Forward\uff0c\u53ef\u4ee5\u5728\u672c\u5730\u73af\u5883\u5feb\u901f\u8c03\u8bd5\u8bbf\u95eeK8s\u4e2d\u7684\u670d\u52a1\u6216Pod\u3002<\/li><li>K8s\u7684Service\u53d1\u5e03\u4e3b\u8981\u67093\u79cdtype\uff0ctype=ClusterIP\uff0c\u8868\u793a\u4ec5\u5185\u90e8\u53ef\u8bbf\u95ee\u670d\u52a1\uff0ctype=NodePort\uff0c\u8868\u793a\u901a\u8fc7NodePort\u5bf9\u5916\u66b4\u9732\u670d\u52a1\uff0ctype=LoadBalancer\uff0c\u8868\u793a\u901a\u8fc7LoadBalancer\u5bf9\u5916\u66b4\u9732\u670d\u52a1(\u5e95\u5c42\u5bf9\u63a5NodePort\uff0c\u4e00\u822c\u516c\u6709\u4e91\u624d\u652f\u6301)\u3002<\/li><\/ul>\n\n\n\n<p>\u81f3\u6b64\uff0cKubernetes\u7f51\u7edc\u4e09\u90e8\u66f2\u5168\u90e8\u8bb2\u89e3\u5b8c\u6210\uff0c\u5e0c\u671b\u8fd9\u4e09\u7bc7\u6587\u7ae0\u5bf9\u4f60\u7406\u89e3\u548c\u7528\u597dK8s\u6709\u5e2e\u52a9\u3002\u4e0b\u8868\u662f\u5bf9\u4e09\u90e8\u66f2\u7684\u6d53\u7f29\u603b\u7ed3\uff0c\u662f\u5e0c\u671b\u5927\u5bb6\u5e26\u8d70\u8bb0\u4f4f\u7684\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-331.png\" alt=\"\" class=\"wp-image-12359\" width=\"493\" height=\"234\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-331.png 1000w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-331-300x142.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-331-768x364.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-331-830x393.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-331-230x109.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-331-350x166.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/08\/\u56fe\u7247-331-480x228.png 480w\" sizes=\"(max-width: 493px) 100vw, 493px\" \/><\/figure><\/div>\n\n\n\n<p><strong>More\uff1a<\/strong>\u5173\u4e8eK8S\u7f51\u7edc\u7684\u66f4\u591a\u57fa\u672c\u539f\u7406\u4e0e\u8bb2\u89e3\uff0c<strong>\u5f3a\u529b\u63a8\u8350<\/strong>\u9605\u8bfb\u6ce2\u6ce2\u8001\u5e08\u7684\u4ee5\u4e0b\u6587\u7ae0\uff1a<\/p>\n\n\n\n<ul><li><a href=\"https:\/\/blog.csdn.net\/yang75108\/article\/details\/101101384\" target=\"_blank\" rel=\"noreferrer noopener\">Kubernetes\u7f51\u7edc\u4e09\u90e8\u66f2-Pod\u7f51\u7edc<\/a>\uff08From \u6768\u6ce2\u8001\u5e08\uff09<\/li><li><a href=\"https:\/\/blog.csdn.net\/yang75108\/article\/details\/101267444\" target=\"_blank\" rel=\"noreferrer noopener\">Kubernetes\u7f51\u7edc\u4e09\u90e8\u66f2-Service\u7f51\u7edc<\/a>\uff08From \u6768\u6ce2\u8001\u5e08\uff09<\/li><li><a href=\"https:\/\/blog.csdn.net\/yang75108\/article\/details\/101268208\" target=\"_blank\" rel=\"noreferrer noopener\">Kubernetes\u7f51\u7edc\u4e09\u90e8\u66f2-\u5916\u90e8\u63a5\u5165\u7f51\u7edc<\/a>\uff08From \u6768\u6ce2\u8001\u5e08\uff09<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001Kubernetes\u7f51\u7edc\u6a21\u578b \u6211\u4eec\u90fd\u77e5\u9053Kubernetes\u4f5c\u4e3a\u5bb9\u5668\u7f16\u6392\u5f15\u64ce\uff0c\u5b83\u6709\u4e00\u4e2a\u5f3a\u5927\u53c8\u590d\u6742\u7684\u7f51\u7edc\u6a21\u578b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12319"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12319"}],"version-history":[{"count":9,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12319\/revisions"}],"predecessor-version":[{"id":12362,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/12319\/revisions\/12362"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}