{"id":5643,"date":"2022-04-26T13:39:14","date_gmt":"2022-04-26T05:39:14","guid":{"rendered":"http:\/\/123.57.164.21\/?p=5643"},"modified":"2022-04-26T13:39:14","modified_gmt":"2022-04-26T05:39:14","slug":"k8s-%e9%9b%86%e7%be%a4%e9%87%8c%e7%9a%84%e4%b8%89%e7%a7%8dip%ef%bc%88nodeip%e3%80%81podip%e3%80%81clusterip%ef%bc%89","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=5643","title":{"rendered":"k8s-\u96c6\u7fa4\u91cc\u7684\u4e09\u79cdIP\uff08NodeIP\u3001PodIP\u3001ClusterIP\uff09"},"content":{"rendered":"\n<p>\u521d\u5b66k8s,\u5bf9\u96c6\u7fa4\u91cc\u9762\u7684IP\u771f\u7684\u4e0d\u662f\u5f88\u7406\u89e3\uff0c\u4e00\u4f1a\u662fPodIP,\u4e00\u4f1a\u662fClusterIP,\u603b\u7ed3\u4e00\u4e0b\u8fd9\u4e9bIP\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/so.csdn.net\/so\/search?q=Kubernetes&amp;spm=1001.2101.3001.7020\" target=\"_blank\" rel=\"noreferrer noopener\">Kubernetes<\/a>\u96c6\u7fa4\u91cc\u6709\u4e09\u79cdIP\u5730\u5740\uff0c\u5206\u522b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul><li>Node IP\uff1aNode\u8282\u70b9\u7684IP\u5730\u5740\uff0c\u5373\u7269\u7406\u7f51\u5361\u7684IP\u5730\u5740\u3002<\/li><li>Pod IP\uff1aPod\u7684IP\u5730\u5740\uff0c\u5373docker\u5bb9\u5668\u7684IP\u5730\u5740\uff0c\u6b64\u4e3a\u865a\u62dfIP\u5730\u5740\u3002<\/li><li>Cluster IP\uff1aService\u7684IP\u5730\u5740\uff0c\u6b64\u4e3a\u865a\u62dfIP\u5730\u5740\u3002<\/li><\/ul>\n\n\n\n<p><strong>Node IP<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u53ef\u4ee5\u662f\u7269\u7406\u673a\u7684IP\uff08\u4e5f\u53ef\u80fd\u662f\u865a\u62df\u673aIP\uff09\u3002\u6bcf\u4e2aService\u90fd\u4f1a\u5728Node\u8282\u70b9\u4e0a\u5f00\u901a\u4e00\u4e2a\u7aef\u53e3\uff0c\u5916\u90e8\u53ef\u4ee5\u901a\u8fc7NodeIP:NodePort\u5373\u53ef\u8bbf\u95eeService\u91cc\u7684Pod,\u548c\u6211\u4eec\u8bbf\u95ee\u670d\u52a1\u5668\u90e8\u7f72\u7684\u9879\u76ee\u4e00\u6837\uff0cIP:\u7aef\u53e3\/\u9879\u76ee\u540d<\/p>\n\n\n\n<p>\u5728kubernetes\u67e5\u8be2Node IP<\/p>\n\n\n\n<ul><li>1.kubectl get nodes<\/li><li>2.kubectl describe node nodeName<\/li><li>3.\u663e\u793a\u51fa\u6765\u7684InternalIP\u5c31\u662fNodeIP<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-162.png\" alt=\"\" class=\"wp-image-5645\" width=\"615\" height=\"301\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-162.png 838w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-162-300x147.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-162-768x376.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-162-830x406.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-162-230x113.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-162-350x171.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-162-480x235.png 480w\" sizes=\"(max-width: 615px) 100vw, 615px\" \/><\/figure><\/div>\n\n\n\n<p><strong>Pod IP<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Pod IP\u662f\u6bcf\u4e2aPod\u7684IP\u5730\u5740\uff0c\u4ed6\u662f<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=Docker&amp;spm=1001.2101.3001.7020\" target=\"_blank\">Docker<\/a> Engine\u6839\u636edocker\u7f51\u6865\u7684IP\u5730\u5740\u6bb5\u8fdb\u884c\u5206\u914d\u7684\uff0c\u901a\u5e38\u662f\u4e00\u4e2a\u865a\u62df\u7684\u4e8c\u5c42\u7f51\u7edc<\/p>\n\n\n\n<ul><li>\u540cService\u4e0b\u7684pod\u53ef\u4ee5\u76f4\u63a5\u6839\u636ePodIP\u76f8\u4e92\u901a\u4fe1<\/li><li>\u4e0d\u540cService\u4e0b\u7684pod\u5728\u96c6\u7fa4\u95f4pod\u901a\u4fe1\u8981\u501f\u52a9\u4e8e cluster ip<\/li><li>pod\u548c\u96c6\u7fa4\u5916\u901a\u4fe1\uff0c\u8981\u501f\u52a9\u4e8enode ip<\/li><\/ul>\n\n\n\n<p>\u5728kubernetes\u67e5\u8be2Pod IP<\/p>\n\n\n\n<ul><li>1.kubectl get pods<\/li><li>2.kubectl describe pod podName<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-163.png\" alt=\"\" class=\"wp-image-5646\" width=\"539\" height=\"245\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-163.png 862w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-163-300x137.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-163-768x351.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-163-830x379.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-163-230x105.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-163-350x160.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-163-480x219.png 480w\" sizes=\"(max-width: 539px) 100vw, 539px\" \/><\/figure><\/div>\n\n\n\n<p><strong>Cluster IP<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Service\u7684IP\u5730\u5740\uff0c\u6b64\u4e3a\u865a\u62dfIP\u5730\u5740\u3002\u5916\u90e8\u7f51\u7edc\u65e0\u6cd5ping\u901a\uff0c\u53ea\u6709kubernetes\u96c6\u7fa4\u5185\u90e8\u8bbf\u95ee\u4f7f\u7528\u3002<\/p>\n\n\n\n<p>\u5728kubernetes\u67e5\u8be2Cluster IP<br>kubectl -n \u547d\u540d\u7a7a\u95f4 get Service\u5373\u53ef\u770b\u5230ClusterIP<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-164.png\" alt=\"\" class=\"wp-image-5647\" width=\"538\" height=\"200\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-164.png 878w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-164-300x112.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-164-768x287.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-164-830x310.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-164-230x86.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-164-350x131.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-164-480x179.png 480w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/figure><\/div>\n\n\n\n<p>Cluster IP\u662f\u4e00\u4e2a\u865a\u62df\u7684IP\uff0c\u4f46\u66f4\u50cf\u662f\u4e00\u4e2a\u4f2a\u9020\u7684IP\u7f51\u7edc\uff0c\u539f\u56e0\u6709\u4ee5\u4e0b\u51e0\u70b9<\/p>\n\n\n\n<ul><li>Cluster IP\u4ec5\u4ec5\u4f5c\u7528\u4e8eKubernetes Service\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u5e76\u7531Kubernetes\u7ba1\u7406\u548c\u5206\u914dP\u5730\u5740<\/li><li>Cluster IP\u65e0\u6cd5\u88abping\uff0c\u4ed6\u6ca1\u6709\u4e00\u4e2a\u201c\u5b9e\u4f53\u7f51\u7edc\u5bf9\u8c61\u201d\u6765\u54cd\u5e94<\/li><li>Cluster IP\u53ea\u80fd\u7ed3\u5408Service Port\u7ec4\u6210\u4e00\u4e2a\u5177\u4f53\u7684\u901a\u4fe1\u7aef\u53e3\uff0c\u5355\u72ec\u7684Cluster IP\u4e0d\u5177\u5907\u901a\u4fe1\u7684\u57fa\u7840\uff0c\u5e76\u4e14\u4ed6\u4eec\u5c5e\u4e8eKubernetes\u96c6\u7fa4\u8fd9\u6837\u4e00\u4e2a\u5c01\u95ed\u7684\u7a7a\u95f4\u3002<\/li><li>\u5728\u4e0d\u540cService\u4e0b\u7684pod\u8282\u70b9\u5728\u96c6\u7fa4\u95f4\u76f8\u4e92\u8bbf\u95ee\u53ef\u4ee5\u901a\u8fc7Cluster IP<\/li><\/ul>\n\n\n\n<p><strong>\u4e09\u79cdIP\u7f51\u7edc\u95f4\u7684\u901a\u4fe1<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>service\u5730\u5740\u548cpod\u5730\u5740\u5728\u4e0d\u540c\u7f51\u6bb5\uff0cservice\u5730\u5740\u4e3a\u865a\u62df\u5730\u5740\uff0c\u4e0d\u914d\u5728pod\u4e0a\u6216\u4e3b\u673a\u4e0a\uff0c\u5916\u90e8\u8bbf\u95ee\u65f6\uff0c\u5148\u5230Node\u8282\u70b9\u7f51\u7edc\uff0c\u518d\u8f6c\u5230service\u7f51\u7edc\uff0c\u6700\u540e\u4ee3\u7406\u7ed9pod\u7f51\u7edc\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-165.png\" alt=\"\" class=\"wp-image-5648\" width=\"424\" height=\"291\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-165.png 756w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-165-300x206.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-165-230x158.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-165-350x241.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-165-480x330.png 480w\" sizes=\"(max-width: 424px) 100vw, 424px\" \/><\/figure><\/div>\n\n\n\n<p>Kubernetes\u5728\u5176\u6240\u6709\u8282\u70b9\u4e0a\u5f00\u653e\u4e00\u4e2a\u7aef\u53e3\u7ed9\u5916\u90e8\u8bbf\u95ee\uff08\u6240\u6709\u8282\u70b9\u4e0a\u90fd\u4f7f\u7528\u76f8\u540c\u7684\u7aef\u53e3\u53f7\uff09\uff0c \u5e76\u5c06\u4f20\u5165\u7684\u8fde\u63a5\u8f6c\u53d1\u7ed9\u4f5c\u4e3aService\u670d\u52a1\u5bf9\u8c61\u7684pod\u3002\u8fd9\u6837\u6211\u4eec\u7684pod\u5c31\u53ef\u4ee5\u88ab\u5916\u90e8\u8bf7\u6c42\u8bbf\u95ee\u5230<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-166-1024x653.png\" alt=\"\" class=\"wp-image-5649\" width=\"481\" height=\"306\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-166-1024x653.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-166-300x191.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-166-768x490.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-166-830x529.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-166-230x147.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-166-350x223.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-166-480x306.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/04\/\u56fe\u7247-166.png 1386w\" sizes=\"(max-width: 481px) 100vw, 481px\" \/><\/figure><\/div>\n\n\n\n<p><br>k8s\u66b4\u9732\u670d\u52a1\u7ed9\u5916\u90e8\u8bbf\u95ee\u6709\u4e09\u79cd\u65b9\u5f0f\uff0cNodePort\u3001LoadBalane\u3001Ingress\u4e09\u79cd\u66b4\u9732\u670d\u52a1\u7684\u65b9\u5f0f\uff0c\u4e0a\u56fe\u662f\u7528\u4e86NodePort\u7684\u65b9\u5f0f\uff0c\u7f3a\u70b9\u662f\u670d\u52a1\u4e00\u65e6\u591a\u8d77\u6765\uff0cNodePort \u5728\u6bcf\u4e2a\u8282\u70b9\u4e0a\u5f00\u542f\u7684\u7aef\u53e3\u6570\u91cf\u4f1a\u6781\u5176\u5e9e\u5927\uff0c\u96be\u4ee5\u7ef4\u62a4\uff0c\u8be6\u89e3k8s\u66b4\u9732\u670d\u52a1\u7684\u4e09\u79cd\u65b9\u5f0f\uff1ak8s-(\u4e03\uff09\u66b4\u9732\u670d\u52a1\u7684\u4e09\u79cd\u65b9\u5f0f<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u521d\u5b66k8s,\u5bf9\u96c6\u7fa4\u91cc\u9762\u7684IP\u771f\u7684\u4e0d\u662f\u5f88\u7406\u89e3\uff0c\u4e00\u4f1a\u662fPodIP,\u4e00\u4f1a\u662fClusterIP,\u603b\u7ed3\u4e00\u4e0b\u8fd9\u4e9bIP\u3002 K [&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\/5643"}],"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=5643"}],"version-history":[{"count":3,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/5643\/revisions"}],"predecessor-version":[{"id":5651,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/5643\/revisions\/5651"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}