{"id":598,"date":"2022-12-20T03:50:35","date_gmt":"2022-12-19T18:50:35","guid":{"rendered":"https:\/\/blog.homi.run\/?p=598"},"modified":"2022-12-20T03:50:35","modified_gmt":"2022-12-19T18:50:35","slug":"2%e3%81%a4%e3%81%aecontext%e3%82%92%e5%90%8c%e6%99%82%e3%81%ab%e6%93%8d%e4%bd%9c%e3%81%99%e3%82%8bkubectl%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%9f-%e5%bb%b6","status":"publish","type":"post","link":"https:\/\/blog.homi.run\/?p=598","title":{"rendered":"2\u3064\u306eContext\u3092\u540c\u6642\u306b\u64cd\u4f5c\u3059\u308bkubectl\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f5c\u3063\u305f &#8211; \u5ef6\u9577\u6226"},"content":{"rendered":"\n<p>\u6628\u65e5\u66f8\u3044\u305f\u8a18\u4e8b\u306e\u306a\u304b\u3067<a href=\"https:\/\/github.com\/homirun\/kuo\">kuo\u3068\u3044\u3046kubectl plugin\u3092\u7a81\u8cab\u5de5\u4e8b\u3067\u30ac\u30c3\u3068\u4f5c\u3063\u305f<\/a>\u3068\u3044\u3046\u8a71\u3092\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-homirun-039-s-blog wp-block-embed-homirun-039-s-blog\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"IF54DIA3v4\"><a href=\"https:\/\/blog.homi.run\/?p=579\">2\u3064\u306eContext\u3092\u540c\u6642\u306b\u64cd\u4f5c\u3059\u308bkubectl\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f5c\u3063\u305f<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;2\u3064\u306eContext\u3092\u540c\u6642\u306b\u64cd\u4f5c\u3059\u308bkubectl\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f5c\u3063\u305f&#8221; &#8212; homirun&#039;s Blog\" src=\"https:\/\/blog.homi.run\/?p=579&#038;embed=true#?secret=eeZbMGZ9EY#?secret=IF54DIA3v4\" data-secret=\"IF54DIA3v4\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\u6628\u65e5\u306e\u6642\u70b9\u3067\u306f\u30c6\u30b9\u30c8\u304c\u306a\u304b\u3063\u305f\u308a\u3057\u3066\u8272\u3005\u3042\u308c\u3060\u3063\u305f\u306e\u3067\u3001\u4eca\u65e5\u6700\u4f4e\u9650\u306e\u30e9\u30a4\u30f3\u307e\u3067\u6301\u3063\u3066\u3044\u3063\u3066\u30ea\u30ea\u30fc\u30b9\u3092\u6253\u3064\u3068\u3053\u308d\u307e\u3067\u3084\u3063\u305f\u3002\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u52e2\u3044\u306e\u3042\u308b\u3046\u3061\u306e\u305d\u306e\u5dee\u5206\u3060\u3051\u3067\u3082\u7d39\u4ecb\u3067\u304d\u305f\u3089\u3068\u601d\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6a5f\u80fd\u9762<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">kubectl\u30b5\u30d6\u30b3\u30de\u30f3\u30c9\u306e\u30d5\u30e9\u30b0\u5bfe\u5fdc<\/h3>\n\n\n\n<p>\u6a5f\u80fd\u306e\u6642\u70b9\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306akub<code>ectl<\/code>\u306e\u30b5\u30d6\u30b3\u30de\u30f3\u30c9\u306f\u554f\u984c\u306a\u304f\u52d5\u3044\u3066\u3044\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ kubectl kuo get node\n\n======== cluster1 ========\nNAME    STATUS   ROLES           AGE   VERSION\nchino   Ready    control-plane   25d   v1.25.4+k0s\nmaya    Ready    &lt;none>          25d   v1.25.4+k0s\nmegu    Ready    &lt;none>          25d   v1.25.4+k0s\n======== cluster2 ========\nNAME       STATUS   ROLES           AGE    VERSION\nminikube   Ready    control-plane   122m   v1.25.3<\/code><\/pre>\n\n\n\n<p>\u3057\u304b\u3057\u306a\u304c\u3089\u3001<code>-o<\/code>\u30d5\u30e9\u30b0\u306a\u3069\u3092\u3064\u3051\u308b\u3068cobla(\u3068\u3044\u3046\u304bpflag\u3063\u307d\u3044)\u304ckuo\u306e\u30d5\u30e9\u30b0\u3060\u3068\u89e3\u91c8\u3057\u3066\u3057\u307e\u3044\u3001\u5b9a\u7fa9\u3055\u308c\u3066\u306a\u3044\u3053\u3068\u304b\u3089\u6012\u3089\u308c\u304c\u767a\u751f\u3057\u3066\u3057\u307e\u3063\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ kubectl kuo get node -o wide\n\nError: unknown shorthand flag: 'o' in -o<\/code><\/pre>\n\n\n\n<p>\u305d\u3053\u3067\u3001kuo\u5074\u3067\u306f\u30d5\u30e9\u30b0\u3092\u4f7f\u3046\u4e88\u5b9a\u304c\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u5168\u90e8\u305d\u306e\u307e\u307e\u5f15\u6570\u3068\u3057\u3066\u6271\u3063\u3066\u3082\u3089\u3046\u3088\u3046\u306b\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u305d\u3046\u3059\u308b\u3053\u3068\u3067\u3001\u81ea\u7136\u306a\u5f62\u3067kubectl\u30b5\u30d6\u30b3\u30de\u30f3\u30c9\u306e\u30d5\u30e9\u30b0\u3092\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ kubectl kuo get node -o wide\n\n======== cluster1 ========\nNAME    STATUS   ROLES           AGE   VERSION       INTERNAL-IP      EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME\nchino   Ready    control-plane   26d   v1.25.4+k0s   10.x.y.124       &lt;none>        Ubuntu 22.04.1 LTS   xxxxxxxxxxxxxxxxx   containerd:\/\/x.y.z\nmaya    Ready    &lt;none>          26d   v1.25.4+k0s   10.x.y.88        &lt;none>        Ubuntu 22.04.1 LTS   xxxxxxxxxxxxxxxxx   containerd:\/\/x.y.z\nmegu    Ready    &lt;none>          26d   v1.25.4+k0s   10.x.y.112       &lt;none>        Ubuntu 22.04.1 LTS   xxxxxxxxxxxxxxxxx   containerd:\/\/x.y.z\n======== cluster2 ========\nNAME       STATUS   ROLES           AGE   VERSION   INTERNAL-IP    EXTERNAL-IP   OS-IMAGE               KERNEL-VERSION   CONTAINER-RUNTIME\nminikube   Ready    control-plane   22h   v1.25.3   192.x.y.2      &lt;none>        Buildroot 2021.02.12   x.y.z            docker:\/\/x.y.z\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5468\u308a<\/h3>\n\n\n\n<p>\u3068\u308a\u3042\u3048\u305a\u666e\u901a\u306bMakefile\u3092\u7528\u610f\u3057\u3066\u3001\u305d\u3053\u3067\u30d3\u30eb\u30c9\u3068\u914d\u7f6e\u3092\u3059\u308b\u3088\u3046\u306b\u3057\u305f\u3002\u7d20\u6734\u306a\u611f\u3058\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>install: .\/cmd\/kuo\/main.go\n        go build -o kubectl-kuo .\/cmd\/kuo\n        mv .\/kubectl-kuo \/usr\/local\/bin\/<\/code><\/pre>\n\n\n\n<p>krew\u304b\u3089\u843d\u3068\u3057\u3066\u3053\u308c\u305f\u308a\u3059\u308b\u306e\u304c\u30d9\u30b9\u30c8\u3060\u3068\u306f\u601d\u3046\u304c\u3001\u767b\u9332\u3059\u308b\u306b\u3082\u30ec\u30d3\u30e5\u30fc\u304c\u8d70\u308b\u3089\u3057\u3044\u306e\u3067\u305d\u3061\u3089\u306f\u4fdd\u7559\u306b\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30c6\u30b9\u30c8<\/h2>\n\n\n\n<p>\u30c6\u30b9\u30c8\u306f\u3068\u308a\u3042\u3048\u305a\u30b3\u30de\u30f3\u30c9\u304c\u6b63\u3057\u304f\u52d5\u304f\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3059\u308b\u3060\u3051\u306e\u6700\u4f4e\u9650\u306e\u3068\u3053\u308d\u307e\u3067\u3067\u3001\u30b3\u30de\u30f3\u30c9\u306b\u5024\u3092\u6e21\u3057\u3066\u671f\u5f85\u3055\u308c\u308b\u5fdc\u7b54\u304c\u5e30\u3063\u3066\u304f\u308b\u304b\u3092\u898b\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>func TestCommandKuo(t *testing.T) {\n\tvar out &#91;]byte\n\tvar err error\n\n\t\/\/ .kuoconfig\u304c\u306a\u3044\u3068\u304d\u306f\u30a8\u30e9\u30fc\u306b\u306a\u308b\n\texec.Command(\"rm\", \"~\/.kuoconfig\").Run()\n\tout, err = exec.Command(\"kubectl\", \"kuo\").Output()\n\tassert.Error(t, err)\n\n\t\/\/ .kuoconfig\u304c\u3042\u308b\u3068\u304d\u306f\u8a2d\u5b9a\u3055\u308c\u305fcontext\u306e\u4e00\u89a7\u304c\u5e30\u3063\u3066\u304f\u308b\n\tInitializeSetContext()\n\tout, err = exec.Command(\"kubectl\", \"kuo\").Output()\n\tassert.NoError(t, err)\n\tassert.Contains(t, string(out), \"&#91;\"+CONTEXT1+\" \"+CONTEXT2+\"]\")\n}<\/code><\/pre>\n\n\n\n<p>\u307e\u3060Go\u306e\u30c6\u30b9\u30c8\u306e\u6d41\u5100\u307f\u305f\u3044\u306a\u306e\u304c\u308f\u304b\u3063\u3066\u304a\u3089\u305a\u3001\u591a\u5206\u66f8\u304d\u65b9\u9055\u3046\u3093\u3060\u308d\u3046\u306a\u3041\u3068\u601d\u3044\u306a\u304c\u3089\u3068\u308a\u3042\u3048\u305a\u66f8\u3044\u3066\u3044\u305f\u3002(\u30c6\u30b9\u30c8\u30b1\u30fc\u30b9\u3054\u3068\u3067\u7d30\u304b\u304f\u30e1\u30bd\u30c3\u30c9\u5206\u3051\u305f\u307b\u3046\u304c\u3044\u3044\u306e\u304b\u306a\u3068\u601d\u3063\u305f)<\/p>\n\n\n\n<p>\u30e6\u30cb\u30c3\u30c8\u30c6\u30b9\u30c8\u3068\u304b\u3082\u3053\u308c\u304b\u3089\u66f8\u304f\u3002(\u591a\u5206)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">CI<\/h2>\n\n\n\n<p>\u3053\u308c\u304c\u3001\u610f\u5916\u3068\u9762\u5012\u3060\u3063\u305f\u3002<\/p>\n\n\n\n<p>\u30af\u30e9\u30b9\u30bf\u304c2\u3064\u3042\u308b\u74b0\u5883\u3092\u7528\u610f\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u305f\u3081\u3001CI\u306e\u74b0\u5883\u69cb\u7bc9\u306b\u60a9\u307e\u3055\u308c\u305f\u3002<\/p>\n\n\n\n<p>\u6700\u7d42\u7684\u306b\u305f\u3069\u308a\u7740\u3044\u305f\u306e\u306f\u3001GithubActions\u306e<a href=\"https:\/\/github.com\/helm\/kind-action\">helm\/kind-action<\/a>\u3068<a href=\"https:\/\/github.com\/medyagh\/setup-minikube\">medyagh\/setup-minikube<\/a>\u3092\u540c\u3058workflow\u4e0a\u3067\u52d5\u304b\u3057\u3066\u305d\u3053\u3067\u30c6\u30b9\u30c8\u3092\u3059\u308b\u3068\u3044\u3046\u3082\u306e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>      - name: Set up Kind\n        uses: helm\/kind-action@v1.4.0\n      - name: Set up minikube\n        uses: medyagh\/setup-minikube@master\n      - name: test\n        run: |\n          make install\n          go test .\/test\/kuo_test.go<\/code><\/pre>\n\n\n\n<p>\u672c\u5f53\u306f\u5168\u90e8\u5165\u3063\u305f\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u308b\u306e\u304c\u826f\u3044\u3093\u3060\u308d\u3046\u306a\u3041\u3068\u601d\u3044\u3064\u3064\u3082dind\u3067kind\u3068minikube\u3092\u52d5\u304b\u3059\u306e\u3082\u306a\u3041\u3068\u601d\u3044\u3053\u306e\u5f62\u306b\u843d\u3061\u7740\u3044\u305f\u3002<\/p>\n\n\n\n<div style=\"height:47px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u5ef6\u9577\u6226\u3068\u3044\u3046\u5f62\u3067\u66f8\u3044\u3066\u307f\u305f\u3002<\/p>\n\n\n\n<p>Go\u3067\u3061\u3083\u3093\u3068\u3057\u305f\u4f55\u304b\u3092\u66f8\u304f\u306e\u306f\u521d\u3081\u3066\u306a\u306e\u3067\u7d50\u69cb\u697d\u3057\u3093\u3067\u3084\u308c\u3066\u3044\u308b\u3002Python\u3082\u3044\u3044\u304cGo\u3082\u305d\u308c\u306a\u308a\u306b\u66f8\u3051\u307e\u3059\u3050\u3089\u3044\u306b\u306a\u308c\u308b\u3068\u3088\u3044\u306e\u304b\u306a\u3041\u3068\u8003\u3048\u3064\u3064\u3001\u52c9\u5f37\u304c\u3066\u3089\u306b\u3061\u3087\u3044\u3061\u3087\u3044kuo\u306e\u66f4\u65b0\u3092\u3057\u3066\u3044\u3053\u3046\u3068\u601d\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6628\u65e5\u66f8\u3044\u305f\u8a18\u4e8b\u306e\u306a\u304b\u3067kuo\u3068\u3044\u3046kubectl plugin\u3092\u7a81\u8cab\u5de5\u4e8b\u3067\u30ac\u30c3\u3068\u4f5c\u3063\u305f\u3068\u3044\u3046\u8a71\u3092\u3057\u305f\u3002 \u6628\u65e5\u306e\u6642\u70b9\u3067\u306f\u30c6\u30b9\u30c8\u304c\u306a\u304b\u3063\u305f\u308a\u3057\u3066\u8272\u3005\u3042\u308c\u3060\u3063\u305f\u306e\u3067\u3001\u4eca\u65e5\u6700\u4f4e\u9650\u306e\u30e9\u30a4\u30f3\u307e\u3067\u6301\u3063\u3066\u3044\u3063\u3066\u30ea\u30ea\u30fc\u30b9\u3092\u6253\u3064\u3068\u3053\u308d\u307e\u3067\u3084 &hellip; <a href=\"https:\/\/blog.homi.run\/?p=598\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;2\u3064\u306eContext\u3092\u540c\u6642\u306b\u64cd\u4f5c\u3059\u308bkubectl\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f5c\u3063\u305f &#8211; \u5ef6\u9577\u6226&#8221;\u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,7],"tags":[],"class_list":["post-598","post","type-post","status-publish","format-standard","hentry","category-6","category-7"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.homi.run\/index.php?rest_route=\/wp\/v2\/posts\/598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.homi.run\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.homi.run\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.homi.run\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.homi.run\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=598"}],"version-history":[{"count":12,"href":"https:\/\/blog.homi.run\/index.php?rest_route=\/wp\/v2\/posts\/598\/revisions"}],"predecessor-version":[{"id":610,"href":"https:\/\/blog.homi.run\/index.php?rest_route=\/wp\/v2\/posts\/598\/revisions\/610"}],"wp:attachment":[{"href":"https:\/\/blog.homi.run\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.homi.run\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.homi.run\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}