{"id":1614,"date":"2020-06-12T00:15:30","date_gmt":"2020-06-11T16:15:30","guid":{"rendered":"http:\/\/39.97.231.10\/?p=1614"},"modified":"2020-06-12T00:15:30","modified_gmt":"2020-06-11T16:15:30","slug":"kubernetes-kubectl-expose%e5%91%bd%e4%bb%a4%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=1614","title":{"rendered":"Kubernetes kubectl expose\u547d\u4ee4\u8be6\u89e3"},"content":{"rendered":"<header class=\\\"entry-header\\\"><\/header>\n<div class=\\\"entry-content\\\">\n<div id=\\\"toc_container\\\" class=\\\"no_bullets\\\">\n<span style=\\\"color: #1e73be; font-size: 1.30769rem;\\\">kubectl expose<\/span>\n<\/div>\n<p>\u5c06\u8d44\u6e90\u66b4\u9732\u4e3a\u65b0\u7684Kubernetes Service\u3002<br \/>\n\u6307\u5b9adeployment\u3001service\u3001replica set\u3001replication controller\u6216pod\u00a0\uff0c\u5e76\u4f7f\u7528\u8be5\u8d44\u6e90\u7684\u9009\u62e9\u5668\u4f5c\u4e3a\u6307\u5b9a\u7aef\u53e3\u4e0a\u65b0\u670d\u52a1\u7684\u9009\u62e9\u5668\u3002deployment \u6216\u00a0replica set\u53ea\u6709\u5f53\u5176\u9009\u62e9\u5668\u53ef\u8f6c\u6362\u4e3aservice\u652f\u6301\u7684\u9009\u62e9\u5668\u65f6\uff0c\u5373\u5f53\u9009\u62e9\u5668\u4ec5\u5305\u542bmatchLabels\u7ec4\u4ef6\u65f6\u624d\u4f1a\u4f5c\u4e3a\u66b4\u9732\u65b0\u7684Service\u3002<br \/>\n\u8d44\u6e90\u5305\u62ec(\u4e0d\u533a\u5206\u5927\u5c0f\u5199)\uff1a<br \/>\npod\uff08po\uff09\uff0cservice\uff08svc\uff09\uff0creplication controller\uff08rc\uff09\uff0cdeployment\uff08deploy\uff09\uff0creplica set\uff08rs\uff09<\/p>\n<h3><span id=\\\"i\\\">\u8bed\u6cd5<\/span><\/h3>\n<pre>$ expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP] [--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type]<\/pre>\n<h3><span id=\\\"i-2\\\">\u793a\u4f8b<\/span><\/h3>\n<p>\u4e3aRC\u7684nginx\u521b\u5efaservice\uff0c\u5e76\u901a\u8fc7Service\u768480\u7aef\u53e3\u8f6c\u53d1\u81f3\u5bb9\u5668\u76848000\u7aef\u53e3\u4e0a\u3002<\/p>\n<pre>kubectl expose rc nginx --port=80 --target-port=8000<\/pre>\n<p>\u7531\u201cnginx-controller.yaml\u201d\u4e2d\u6307\u5b9a\u7684type\u548cname\u6807\u8bc6\u7684RC\u521b\u5efaService\uff0c\u5e76\u901a\u8fc7Service\u768480\u7aef\u53e3\u8f6c\u53d1\u81f3\u5bb9\u5668\u76848000\u7aef\u53e3\u4e0a\u3002<\/p>\n<pre>kubectl expose -f nginx-controller.yaml --port=80 --target-port=8000<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>kubectl expose \u5c06\u8d44\u6e90\u66b4\u9732\u4e3a\u65b0\u7684Kubernetes Service\u3002 \u6307\u5b9adeployment &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=1614\"> <span class=\"screen-reader-text\">Kubernetes kubectl expose\u547d\u4ee4\u8be6\u89e3<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[104,123],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"kubectl expose \u5c06\u8d44\u6e90\u66b4\u9732\u4e3a\u65b0\u7684Kubernetes Service\u3002 \u6307\u5b9adeployment&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1614"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1614"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1614\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1614"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}