{"id":102,"date":"2024-06-21T14:26:52","date_gmt":"2024-06-21T06:26:52","guid":{"rendered":"https:\/\/www.sretalk.com\/?p=102"},"modified":"2024-06-26T00:39:49","modified_gmt":"2024-06-25T16:39:49","slug":"kubernetes-%e5%88%97%e5%87%ba%e6%89%80%e6%9c%89%e7%9b%b8%e5%85%b3%e7%9a%84%e8%b5%84%e6%ba%90","status":"publish","type":"post","link":"https:\/\/www.sretalk.com\/?p=102","title":{"rendered":"Kubernetes \u5217\u51fa\u6240\u6709\u76f8\u5173\u7684\u8d44\u6e90"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">\u4e00 \u6982\u8ff0<\/h1>\n\n\n\n<p>\u5728\u5b66\u4e60\u8fd0\u7ef4 K8S \u65f6\uff0c\u73b0\u5728\u6bd4\u8f83\u4e3b\u6d41\u7684\u90e8\u7f72\u662f\u901a\u8fc7 helm \u4ed3\u5e93\u7684\u65b9\u5f0f\u8fdb\u884c\u53d1\u5e03\u5e94\u7528\uff0c\u5f53\u4e00\u4e2a helm \u53d1\u5e03\u540e\uff0c\u5e76\u4e0d\u4e00\u5b9a\u80fd\u77e5\u9053 helm \u5728\u6211\u7684 K8S \u96c6\u7fa4\u4e2d\u521b\u5efa\u4e86\u54ea\u4e9b\u8d44\u6e90\uff0c\u8fd9\u65f6\u5019\u5c31\u60f3\u627e\u51fa\u8fd9\u4e2a helm \u6240\u914d\u7f6e\u7684\u6240\u6709 K8S \u76f8\u5173\u7684\u8d44\u6e90\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite>\u5c1d\u8bd5\u901a\u8fc7 <code>kubectl get all -l xxxxx=xxxx<\/code> \u7684\u65b9\u5f0f\uff0c\u7ecf\u8fc7\u5bf9\u6bd4\u540e\u53d1\u73b0\u8fd8\u662f\u4f1a\u6709\u4e9b\u7f3a\u5c11\u3002<\/cite><\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e8c \u64cd\u4f5c<\/h1>\n\n\n\n<p>1\u3001\u7ecf\u8fc7\u67e5\u8be2\u8d44\u6599\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>api-resources<\/code> \u7684\u65b9\u5f0f\u8fdb\u884c\u5217\u4e3e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code># k8s control-plane:\n\n# \u53ef\u4ee5\u5148\u901a\u8fc7 api-resources \u6765\u5217\u4e3e\u6240\u6709\u5f53\u524d Kubernetes \u7684\u8d44\u6e90\nkubectl api-resources \\\n  --verbs=list \\\n  --namespaced \\\n  -o name<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite>1. <code>--verbs=list<\/code>\uff1a \u786e\u4fdd\u6240\u6709\u8fd4\u56de\u7684\u8d44\u6e90\u90fd\u652f\u6301 list \u64cd\u4f5c\u3002<br>2. <code>--namespaced<\/code> \uff1a\u4ec5\u8fd4\u56de\u547d\u540d\u7a7a\u95f4\u7684 API \u8d44\u6e90<br>3. <code>-o name<\/code>\uff1a\u53ea\u8f93\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u8d44\u6e90\u540d\u79f0<\/cite><\/blockquote>\n\n\n\n<p>2\u3001\u7136\u540e\u53ef\u4ee5\u901a\u8fc7 <code>xargs<\/code> \u7b49\u8fdb\u884c\u5faa\u73af\u8f93\u51fa<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code># k8s control-plane:\n\nkubectl api-resources \\\n  --verbs=list \\\n  --namespaced \\\n  -o name \\\n  | xargs -n 1 \\\n    kubectl get \\\n    --ignore-not-found \\\n    --show-kind \\\n    -n &lt;\u547d\u540d\u7a7a\u95f4\u540d\u79f0>\n  <\/code><\/pre>\n\n\n\n<p>3\u3001\u53ef\u4ee5\u7ed3\u5408 <code>-l xxx=xxx<\/code> \u6765\u8fdb\u884c\u8fc7\u6ee4\u6307\u6807 labels \u7684\u8d44\u6e90<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code># k8s control-plane:\n\nkubectl api-resources \\\n  --verbs=list \\\n  --namespaced \\\n  -o name \\\n  | xargs -n 1 \\\n    kubectl get \\\n    --ignore-not-found \\\n    --show-kind \\\n    -l apo.kubernetes.io\/name=my-apps\n    -n &lt;\u547d\u540d\u7a7a\u95f4\u540d\u79f0> <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00 \u6982\u8ff0 \u5728\u5b66\u4e60\u8fd0\u7ef4 K8S \u65f6\uff0c\u73b0\u5728\u6bd4\u8f83\u4e3b\u6d41\u7684\u90e8\u7f72\u662f\u901a\u8fc7 helm \u4ed3\u5e93\u7684\u65b9\u5f0f\u8fdb\u884c\u53d1\u5e03\u5e94\u7528\uff0c\u5f53\u4e00\u4e2a helm [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-k8s"],"_links":{"self":[{"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=102"}],"version-history":[{"count":4,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":113,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions\/113"}],"wp:attachment":[{"href":"https:\/\/www.sretalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}