{"id":27147,"date":"2024-11-24T16:26:19","date_gmt":"2024-11-24T08:26:19","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27147\/"},"modified":"2024-11-24T16:26:19","modified_gmt":"2024-11-24T08:26:19","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88%e4%bd%bf%e7%94%a8-clusterip-ingress-%e6%97%a0%e6%b3%95%e4%bb%8e%e5%a4%96%e9%83%a8%e8%ae%bf%e9%97%ae%e5%86%85%e9%83%a8-mysql%ef%bc%8c%e8%80%8c%e4%bd%bf%e7%94%a8-nodeport-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27147\/","title":{"rendered":"\u4e3a\u4ec0\u4e48\u4f7f\u7528 ClusterIP + Ingress \u65e0\u6cd5\u4ece\u5916\u90e8\u8bbf\u95ee\u5185\u90e8 MySQL\uff0c\u800c\u4f7f\u7528 NodePort \u5374\u53ef\u4ee5\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173119957289067.jpg\" class=\"aligncenter\" title=\"\u4e3a\u4ec0\u4e48\u4f7f\u7528 ClusterIP + Ingress \u65e0\u6cd5\u4ece\u5916\u90e8\u8bbf\u95ee\u5185\u90e8 MySQL\uff0c\u800c\u4f7f\u7528 NodePort \u5374\u53ef\u4ee5\uff1f\u63d2\u56fe\" alt=\"\u4e3a\u4ec0\u4e48\u4f7f\u7528 ClusterIP + Ingress \u65e0\u6cd5\u4ece\u5916\u90e8\u8bbf\u95ee\u5185\u90e8 MySQL\uff0c\u800c\u4f7f\u7528 NodePort \u5374\u53ef\u4ee5\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>k8s \u4e2d\u4f7f\u7528 ClusterIP + Ingress \u4ece\u5916\u90e8\u8bbf\u95ee\u5185\u90e8 MySQL<\/strong><\/p>\n<p>\u4f60\u5728 minikube \u73af\u5883\u4e2d\u4f7f\u7528 ClusterIP \u548c Ingress \u914d\u7f6e MySQL \u96c6\u7fa4\u3002\u4f46\u662f\uff0c\u4f60\u65e0\u6cd5\u4ece\u5916\u90e8\u8bbf\u95ee MySQL\uff0c\u800c NodePort \u5374\u53ef\u4ee5\u5de5\u4f5c\u3002\u8fd9\u662f\u56e0\u4e3a\uff1a<\/p>\n<p><strong>\u4f7f\u7528 ClusterIP + Ingress<\/strong><\/p>\n<ul>\n<li>ClusterIP \u670d\u52a1\u521b\u5efa\u4e86\u4e00\u4e2a\u5185\u90e8 IP\uff0c\u4ec5\u96c6\u7fa4\u5185\u90e8\u7684\u53ef\u8bbf\u95ee\u3002<\/li>\n<li>Ingress \u5145\u5f53\u96c6\u7fa4\u5916\u90e8\u7684\u5165\u53e3\uff0c\u5c06\u5916\u90e8\u6d41\u91cf\u8def\u7531\u5230 ClusterIP \u670d\u52a1\u3002<\/li>\n<li>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cIngress \u53ea\u80fd\u8f6c\u53d1 HTTP\/HTTPS \u6d41\u91cf\u3002<\/li>\n<\/ul>\n<p>\u56e0\u6b64\uff0c\u4f7f\u7528 ClusterIP + Ingress \u4ece\u5916\u90e8\u8bbf\u95ee MySQL \u9700\u8981\u989d\u5916\u914d\u7f6e\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>\u901a\u8fc7 Service \u8d44\u6e90\u4e2d\u7684 annotations \u5b57\u6bb5\u542f\u7528 TCP \u6d41\u91cf\u4ee3\u7406\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Ingress\uff0c\u4ee5\u53ca\u4e00\u4e2a\u76d1\u542c TCP \u7aef\u53e3\u7684 IngressClass \u548c Service\u3002<\/li>\n<\/ul>\n<p><strong>\u4f7f\u7528 NodePort<\/strong><\/p>\n<ul>\n<li>NodePort \u670d\u52a1\u5c06\u96c6\u7fa4\u4e2d\u7684 3306 \u7aef\u53e3\u6620\u5c04\u5230\u5bbf\u4e3b\u673a\u4e0a\u7684 30001 \u7aef\u53e3\u3002<\/li>\n<li>\u8fd9\u5141\u8bb8\u901a\u8fc7 NodePort \u8bbf\u95ee MySQL\uff0c\u65e0\u9700\u989d\u5916\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<p>\u5728\u4f60\u7684\u7279\u5b9a\u60c5\u51b5\u4e0b\uff0c\u4f60\u4f7f\u7528 NodePort \u8bbf\u95ee\u4e86 MySQL\uff0c\u56e0\u4e3a\u4f60\u901a\u8fc7\u5bbf\u4e3b\u673a\u7684 IP \u548c\u7aef\u53e3\u76f4\u63a5\u8bbf\u95ee\uff0c\u800c\u6ca1\u6709\u4f7f\u7528 Ingress\u3002<\/p>\n<p><strong>\u53c2\u8003\uff1a<\/strong><\/p>\n<ul>\n<li>[\u4f7f\u7528 Ingress \u516c\u5f00\u670d\u52a1](https:\/\/kubernetes.io\/docs\/ingress-\/ingress-exposing-tcp-udp-services\/)<\/li>\n<li>[\u4f7f\u7528 NodePort \u670d\u52a1](https:\/\/kubernetes.io\/docs\/concepts\/services-networking\/service\/#nodeport)<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528 ClusterIP + Ingress \u65e0\u6cd5\u4ece\u5916\u90e8\u8bbf\u95ee\u5185\u90e8 MySQL\uff0c\u800c\u4f7f\u7528 NodePort \u5374\u53ef\u4ee5\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>k8s \u4e2d\u4f7f\u7528 ClusterIP + Ingress \u4ece\u5916\u90e8\u8bbf\u95ee\u5185\u90e8 MySQL \u4f60\u5728 minikube \u73af\u5883\u4e2d\u4f7f\u7528 ClusterIP \u548c Ingress \u914d\u7f6e MySQL \u96c6\u7fa4\u3002\u4f46\u662f\uff0c\u4f60\u65e0\u6cd5\u4ece\u5916\u90e8\u8bbf\u95ee MySQL\uff0c\u800c NodePort \u5374\u53ef\u4ee5\u5de5\u4f5c\u3002\u8fd9\u662f\u56e0\u4e3a\uff1a \u4f7f\u7528 ClusterIP + Ingress ClusterIP \u670d\u52a1\u521b\u5efa\u4e86\u4e00\u4e2a\u5185\u90e8 IP\uff0c\u4ec5\u96c6\u7fa4\u5185\u90e8\u7684\u53ef\u8bbf\u95ee\u3002 Ingress \u5145\u5f53\u96c6\u7fa4\u5916\u90e8\u7684\u5165\u53e3\uff0c\u5c06\u5916\u90e8\u6d41\u91cf\u8def\u7531\u5230 ClusterIP \u670d\u52a1\u3002 \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cIngress \u53ea\u80fd\u8f6c\u53d1 HTTP\/HTTPS \u6d41\u91cf\u3002 \u56e0\u6b64\uff0c\u4f7f\u7528 ClusterIP + Ingress \u4ece\u5916\u90e8\u8bbf\u95ee MySQL \u9700\u8981\u989d\u5916\u914d\u7f6e\uff0c\u4f8b\u5982\uff1a \u901a\u8fc7 Service \u8d44\u6e90\u4e2d\u7684 annotations \u5b57\u6bb5\u542f\u7528 TCP \u6d41\u91cf\u4ee3\u7406\u3002 \u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Ingress\uff0c\u4ee5\u53ca\u4e00\u4e2a\u76d1\u542c TCP \u7aef\u53e3\u7684 IngressClass \u548c Service\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-27147","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=27147"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27147\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}