{"id":1024,"date":"2021-07-29T20:24:20","date_gmt":"2021-07-29T12:24:20","guid":{"rendered":"https:\/\/egonlin.com\/?p=1024"},"modified":"2022-03-28T17:34:30","modified_gmt":"2022-03-28T09:34:30","slug":"label%e6%a0%87%e7%ad%be","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=1024","title":{"rendered":"label\u6807\u7b7e"},"content":{"rendered":"<h2>Label\u6807\u7b7e<\/h2>\n<h3>1\u3001\u4ecb\u7ecd<\/h3>\n<pre><code class=\"language-bash\">    Label\u662fkubernetes\u7cfb\u7edf\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u6982\u5ff5\u3002\u5b83\u7684\u4f5c\u7528\u5c31\u662f\u5728\u8d44\u6e90\u4e0a\u6dfb\u52a0\u6807\u8bc6\uff0c\u7528\u6765\u5bf9\u5b83\u4eec\u8fdb\u884c\u533a\u5206\u548c\u9009\u62e9\u3002Label\u7684\u7279\u70b9:\n\n    \u4e00\u4e2aLabel\u4f1a\u4ee5key\/value\u952e\u503c\u5bf9\u7684\u5f62\u5f0f\u9644\u52a0\u5230\u5404\u79cd\u5bf9\u8c61\u4e0a\uff0c\u5982Node\u3001Pod\u3001Service\u7b49\u7b49\n    \u4e00\u4e2a\u8d44\u6e90\u5bf9\u8c61\u53ef\u4ee5\u5b9a\u4e49\u4efb\u610f\u6570\u91cf\u7684Label\uff0c\u540c\u4e00\u4e2aLabel\u4e5f\u53ef\u4ee5\u88ab\u6dfb\u52a0\u5230\u4efb\u610f\u6570\u91cf\u7684\u8d44\u6e90\u5bf9\u8c61\u4e0a\u53bb.\n    Label\u901a\u5e38\u5728\u8d44\u6e90\u5bf9\u8c61\u5b9a\u4e49\u65f6\u786e\u5b9a\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u5728\u5bf9\u8c61\u521b\u5efa\u540e\u52c3\u6001\u6dfb\u52a0\u6216\u8005\u5220\u9664\n    \u53ef\u4ee5\u901a\u8fc7Label\u5b9e\u73b0\u8d44\u6e90\u7684\u591a\u7ef4\u5ea6\u5206\u7ec4\uff0c\u4ee5\u4fbf\u7075\u6d3b\u3001\u65b9\u4fbf\u5730\u8fdb\u884c\u8d44\u6e90\u5206\u914d\u3001\u8c03\u5ea6\u3001\u914d\u7f6e\u3001\u90e8\u7f72\u7b49\u7ba1\u7406\u5de5\u4f5c\u3002\n\n    k8s\u5f53\u505a\u6807\u7b7e\u662f\u7528\u6765\u7ba1\u7406\uff08\u8bc6\u522b\u4e00\u7cfb\u5217\uff09\u5bb9\u5668\uff0c\u65b9\u4fbf\u4e0e\u7ba1\u7406\u548c\u76d1\u63a7\u62e5\u6709\u540c\u4e00\u6807\u7b7e\u7684\u6240\u6709\u5bb9\u5668<\/code><\/pre>\n<h3>2\u3001\u5e38\u89c1\u6807\u7b7e<\/h3>\n<pre><code class=\"language-bash\">\u7248\u672c\u6807\u7b7e\uff1a&quot;release&quot;:&quot;stable&quot;,&quot;release&quot;:&quot;canary&quot;\n\u73af\u5883\u6807\u7b7e\uff1a&quot;environment&quot;:&quot;dev&quot;,&quot;environment&quot;:&quot;production&quot;\n\u67b6\u6784\u6807\u7b7e\uff1a&quot;tier&quot;:&quot;frontend&quot;,&quot;tier&quot;:&quot;backend&quot;,&quot;tier&quot;:&quot;middleware&quot;\n\u5206\u533a\u6807\u7b7e\uff1a&quot;partition&quot;:&quot;customerA&quot;,&quot;partition&quot;:&quot;customerB&quot;\n\u8d28\u91cf\u7ba1\u63a7\u6807\u7b7e\uff1a&quot;track&quot;:&quot;daily&quot;,&quot;track&quot;:&quot;weekly&quot;<\/code><\/pre>\n<h3>3\u3001\u4f7f\u7528<\/h3>\n<pre><code class=\"language-bash\">[root@k8s-master-01 ~]# vim test1.yaml\napiVersion: v1\nkind: Pod\nmetadata:\n  name: test-tag\n  labels:\n    release: stable\nspec:\n  containers:\n    - name: nginx\n      image: nginx\n\n[root@k8s-master-01 ~]# kubectl create -f test1.yaml\npod\/test-tag created\n<\/code><\/pre>\n<h3>4\u3001\u67e5\u770blabel<\/h3>\n<pre><code class=\"language-bash\">[root@k8s-master-01 ~]# kubectl get pod --show-labels\nNAME       READY   STATUS    RESTARTS   AGE     LABELS\ntest-pod   2\/2     Running   0          4h50m   app=test-pod\ntest-tag   1\/1     Running   0          55s     release=stable<\/code><\/pre>\n<h3>5\u3001\u6dfb\u52a0\u6807\u7b7e<\/h3>\n<p><\/p><div id=\"rml_readmorelogin_placeholder\" style=\"position:relative;\"><div id=\"rml_fade_content\" style=\"position: absolute;\r\ntop:-10em;\r\nwidth:100%;\r\nheight:10em;\r\nbackground: -webkit-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -moz-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -o-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -ms-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\"><\/div><div class=\"wpf-controller aru_rml_from_in_post\" style=\"background-color:#eeeeee;border:5px solid #cce6ff;\" id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><h2 id=\"Header\">\u67e5\u770b\u66f4\u591a<\/h2><div id=\"Message\"><p>\u8054\u7cfb\u7ba1\u7406\u5458\u5fae\u4fe1tutu19192010\uff0c\u6ce8\u518c\u8d26\u53f7<\/p>\n<\/div><div id=\"StatusBarHeader\"><\/div><form id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><input name=\"post_id\" value=\"1024\" type=\"hidden\"\/><input name=\"_init_callback\" value=\"InitLogin\" type=\"hidden\"\/><input name=\"post_id\" value=\"1024\" type=\"hidden\"\/><input name=\"rt_ype\" value=\"1\" type=\"hidden\"\/><input name=\"nonce\" value=\"8f581322cd\" type=\"hidden\"\/><input name=\"_wpnonce\" value=\"ee095c8387\" type=\"hidden\"\/><input name=\"_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_proxy_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_view\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginView\" type=\"hidden\"\/><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\" width=\"400px\"><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Username:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"username\" value=\"\" type=\"text\"\/><\/td><\/tr><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Password:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"password\" value=\"\" type=\"password\"\/><\/td><\/tr><\/tbody><\/table><p class=\"wpf-table-placeholder submit\"><button class=\"wp_plugin_framework_ajax_button\" type=\"button\" style=\"background-color:#4D90FE;;color:#ffffff;;border:1px solid #3079ed;\" name=\"_event\" value=\"ButtonLogin\">Log in<\/button><\/p><\/td><td class=\"wpf-table-placeholder-input\"><\/td><\/tr><\/tbody><\/table><\/form><div id=\"ButtonStartRegister\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=register\">Register<\/a><\/div><div id=\"Link1\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=lostpassword\">Forgotten username or password?<\/a><\/div><div id=\"StatusBarFooter\"><\/div><\/div><\/div><div id=aru_remaining_content><\/div>","protected":false},"excerpt":{"rendered":"<p>Label\u6807\u7b7e 1\u3001\u4ecb\u7ecd Label\u662fkubernetes\u7cfb\u7edf\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u6982\u5ff5\u3002\u5b83\u7684\u4f5c\u7528\u5c31\u662f\u5728\u8d44\u6e90\u4e0a\u6dfb\u52a0\u6807\u8bc6\uff0c [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[126],"tags":[21,133,134,135,19,22,132,20],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/1024"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1024"}],"version-history":[{"count":0,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/1024\/revisions"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}