{"id":473836,"date":"2022-07-14T09:02:58","date_gmt":"2022-07-14T06:02:58","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/"},"modified":"2022-07-14T09:02:58","modified_gmt":"2022-07-14T06:02:58","slug":"how-to-get-started-with-krew-the-kubectl-plugin-manager","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/","title":{"rendered":"#How to Get Started With Krew, the Kubectl Plugin Manager"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a3e219fe23ef\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a3e219fe23ef\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/#%E2%80%9CHow_to_Get_Started_With_Krew_the_Kubectl_Plugin_Manager%E2%80%9D\" >&#8220;How to Get Started With Krew, the Kubectl Plugin Manager&#8221;<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/#Installing_Krew\" >Installing Krew<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/#Updating_the_Plugin_Index\" >Updating the Plugin Index<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/#Installing_Plugins\" >Installing Plugins<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/#Updating_to_New_Plugin_Releases\" >Updating to New Plugin Releases<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/#Searching_for_Plugins\" >Searching for Plugins<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/#Using_Custom_Indexes\" >Using Custom Indexes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/#Publishing_Your_Own_Plugins\" >Publishing Your Own Plugins<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E2%80%9CHow_to_Get_Started_With_Krew_the_Kubectl_Plugin_Manager%E2%80%9D\"><\/span>&#8220;How to Get Started With Krew, the Kubectl Plugin Manager&#8221;<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<div>\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage aligncenter size-full wp-image-9632\" data-pagespeed-no-defer=\"\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/csit\/2021\/02\/748108a6.jpg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Graphic showing the Kubernetes logo\" width=\"1602\" height=\"902\"\/><\/p>\n<p>Krew is a package manager for Kubectl, the official Kubernetes CLI. Using Krew you can find, install, and update Kubectl plugins that extend the CLI with additional functionality.<\/p>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/kubernetes.io\/docs\/tasks\/extend-kubectl\/kubectl-plugins\/#distributing-kubectl-plugins\">Kubectl\u2019s plugins mechanism<\/a> supports several plugin installation methods. The simplest way is to pop plugins straight into a directory that\u2019s in your <code>PATH<\/code>. This is a manual process which offers no way to update the plugin as new releases are published.<\/p>\n<p>Krew provides common package management functionalities for the Kubectl plugin ecosystem. It maintains a public index of known packages and supports third-party indexes too. The latter lets you publish plugins privately within an organization or team.<\/p>\n<h2 id=\"installing-krew\"><span class=\"ez-toc-section\" id=\"Installing_Krew\"><\/span>Installing Krew<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/kubernetes-sigs\/krew\">Krew is an open-source<\/a> tool that\u2019s part of the Kubernetes project. It doesn\u2019t come bundled with Kubectl though. To get started with Krew, you must manually <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">download<\/a> and install the latest release. Current Krew distributions work with Kubectl v1.12 and later.<\/p>\n<p>Downloads are available from the project\u2019s <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/kubernetes-sigs\/krew\/releases\">GitHub releases<\/a> page. The distribution tar archives contain the Krew binary. Run its installation script to finish adding Krew to your system:<\/p>\n<pre>$ .\/krew-linux_amd64 install krew<\/pre>\n<p>A complete script that automatically downloads and installs the correct Krew distribution for your system is available <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/krew.sigs.k8s.io\/docs\/user-guide\/setup\/install\">within the documentation<\/a>.<\/p>\n<p>Next you should update your <code>PATH<\/code> to include Krew\u2019s <code>bin<\/code> directory. This is located within <code>$KREW_ROOT<\/code> which is usually <code>$HOME\/.krew<\/code>. Executables from Kubectl plugins you install will be stored inside the <code>bin<\/code> subdirectory.<\/p>\n<pre>$ export PATH=\"${KREW_ROOT:-$HOME\/.krew}\/bin:$PATH\"<\/pre>\n<p>Now you should be able to use Krew via the <code>kubectl krew<\/code> command:<\/p>\n<pre>~$ kubectl krew&#13;\nkrew is the kubectl plugin manager.&#13;\nYou can invoke krew through kubectl: \"kubectl krew [command]...\"&#13;\n&#13;\nUsage:&#13;\n  kubectl krew [command]&#13;\n...<\/pre>\n<h2 id=\"updating-the-plugin-index\"><span class=\"ez-toc-section\" id=\"Updating_the_Plugin_Index\"><\/span>Updating the Plugin Index<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Krew\u2019s plugin index catalogs all the currently available plugins you can install. It works similarly to the package lists used by OS-level package managers such as <code>apt<\/code>.<\/p>\n<p>Update the index periodically so your Krew installation has access to the latest versions of all available plugins:<\/p>\n<pre>$ kubectl krew update&#13;\nUpdated the local copy of plugin index.<\/pre>\n<h2 id=\"installing-plugins\"><span class=\"ez-toc-section\" id=\"Installing_Plugins\"><\/span>Installing Plugins<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>install<\/code> command adds new plugins to Kubectl. It can install any of the plugins listed in Krew\u2019s index. Krew takes care of downloading the plugin and registering it with Kubectl.<\/p>\n<pre>$ kubectl krew install ctx&#13;\nUpdated the local copy of plugin index.&#13;\nInstalling plugin: ctx&#13;\nInstalled plugin: ctx&#13;\n...<\/pre>\n<p>Krew automatically updates its plugin index before installation, ensuring you get the new plugin\u2019s latest release. Once the install completes, you\u2019ll see some basic information from the plugin\u2019s author at the bottom of the command\u2019s output.<\/p>\n<p>Now you can use the plugin\u2019s commands via the <code>kubectl<\/code> CLI:<\/p>\n<pre>$ kubectl ctx my-context<\/pre>\n<h2 id=\"updating-to-new-plugin-releases\"><span class=\"ez-toc-section\" id=\"Updating_to_New_Plugin_Releases\"><\/span>Updating to New Plugin Releases<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>One of Krew\u2019s biggest advantages is its integrated plugin update system. Running the <code>upgrade<\/code> command will refresh the package index and update all your installed plugins to their newest release. This process is fully automatic.<\/p>\n<pre>$ kubectl krew upgrade&#13;\nUpdated the local copy of plugin index.&#13;\n...<\/pre>\n<p>You can upgrade plugins individually by passing their names to the <code>upgrade<\/code> command:<\/p>\n<pre>$ kubectl krew upgrade ctx<\/pre>\n<p>If you ever want to remove a plugin, supply its name to the <code>uninstall<\/code> command:<\/p>\n<pre>$ kubectl krew uninstall ctx<\/pre>\n<p>Krew will ensure the plugin\u2019s completely removed from your system.<\/p>\n<p>The <code>list<\/code> command shows all your plugins and their installed versions:<\/p>\n<pre>~$ kubectl krew list&#13;\nPLUGIN  VERSION&#13;\nctx     v0.9.4&#13;\nkrew    v0.4.3&#13;\nns      v0.9.4<\/pre>\n<p>Krew itself appears in the plugin list and is supported by the update system. Running <code>upgrade<\/code> or <code>upgrade krew<\/code> will fetch and install the latest Krew release before your plugins are updated.<\/p>\n<h2 id=\"searching-for-plugins\"><span class=\"ez-toc-section\" id=\"Searching_for_Plugins\"><\/span>Searching for Plugins<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>search<\/code> command lets you browse the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/krew.sigs.k8s.io\/plugins\">Krew package index<\/a> from your terminal.<\/p>\n<pre>~$ kubectl krew search cert-manager&#13;\nNAME          DESCRIPTION                                        INSTALLED&#13;\ncert-manager  Manage cert-manager resources inside your cluster  no<\/pre>\n<p>Once you\u2019ve found a plugin you\u2019re interested in, run the <code>info<\/code> command to find out more about it. This reveals the plugin\u2019s current version number, a link to its website, and a short description supplied by the author.<\/p>\n<pre>~$ kubectl krew info cert-manager&#13;\nNAME: cert-manager&#13;\nINDEX: default&#13;\nURI: https:\/\/github.com\/jetstack\/cert-manager\/releases\/download\/v1.7.0\/kubectl-cert_manager-linux-amd64.tar.gz&#13;\nSHA256: 73618617b9ec42994c3ea77bbc8be743e382501d42ad2ee7aeca0d32c15655c0&#13;\nVERSION: v1.7.0&#13;\nHOMEPAGE: https:\/\/github.com\/jetstack\/cert-manager&#13;\nDESCRIPTION: &#13;\nThe official plugin accompanying cert-manger, a Kubernetes add-on to&#13;\nautomate the management and issuance of TLS certificates. Allows for&#13;\ndirect interaction with cert-manager resources e.g. manual renewal of&#13;\nCertificate resources.<\/pre>\n<h2 id=\"using-custom-indexes\"><span class=\"ez-toc-section\" id=\"Using_Custom_Indexes\"><\/span>Using Custom Indexes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Krew supports custom indexes that facilitate plugin installation from your own sources. Indexes are simply Git repositories with a <code>plugins<\/code> folder containing YAML manifests. These files define the plugins that are available for installation. The structure of Krew\u2019s <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/krew.sigs.k8s.io\/docs\/user-guide\/custom-indexes\">default index<\/a> is a useful model when you\u2019re setting up your own.<\/p>\n<p>To add an index, pass its repository URL to the <code>index add<\/code> command:<\/p>\n<pre>$ kubectl krew index add custom-index https:\/\/example.com\/krew\/index.git<\/pre>\n<p>To reference plugins in your index, prefix their names with your chosen index name:<\/p>\n<pre>$ kubectl krew install custom-index\/example-plugin<\/pre>\n<p>When no prefix is given, Krew uses the <code>default\/<\/code> prefix instead. This always refers to Krew\u2019s built-in plugin index. If you\u2019d prefer to direct unprefixed plugin names to your own index, set the <code>KREW_DEFAULT_INDEX_URI<\/code> environment variable to your repository\u2019s URL:<\/p>\n<pre>$ export KREW_DEFAULT_INDEX_URI=\"https:\/\/example.com\/krew\/index.git\"&#13;\n&#13;\n# Automatically resolved to the custom index&#13;\n$ kubectl krew install example-plugin<\/pre>\n<h2 id=\"publishing-your-own-plugins\"><span class=\"ez-toc-section\" id=\"Publishing_Your_Own_Plugins\"><\/span>Publishing Your Own Plugins<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>It\u2019s fairly straightforward to <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/krew.sigs.k8s.io\/docs\/developer-guide\/distributing-with-krew\">distribute your own plugins<\/a> to users via Krew. First you need to create an archive of your Kubectl plugin\u2019s content, either as a <code>.tar.gz<\/code> or <code>.zip<\/code> file. Upload this to a publicly accessible location \u2013 your project\u2019s website or GitHub releases page are both good choices.<\/p>\n<p>Write a <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/krew.sigs.k8s.io\/docs\/developer-guide\/plugin-manifest\">Krew plugin manifest next<\/a>. This is a simple YAML file which provides basic information about your plugin such as its name, description, and current version. The manifest also includes your plugin archive\u2019s public URL. When a user installs your plugin, Krew will fetch its archive from the URL specified in the manifest.<\/p>\n<p>Once you\u2019ve written your manifest, you can commit it to a Git repository. Add that repository as a custom Krew index to add your plugin to your Kubectl installation. Submissions to Krew\u2019s public index <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/krew.sigs.k8s.io\/docs\/developer-guide\/release\/new-plugin\">are accepted by<\/a> creating a pull request to its repository that adds your manifest in the <code>plugins<\/code> directory.<\/p>\n<h2 id=\"conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Krew simplifies Kubernetes plugin discovery, installation, and management. It\u2019s a handy convenience tool for anyone using Kubectl plugins. Krew offers a full package management experience that includes custom private indexes for your internal tools.<\/p>\n<p>The public index contains <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/krew.sigs.k8s.io\/plugins\/\">over 180 plugins<\/a> covering all aspects of Kubernetes management. Some popular options include <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/jetstack\/cert-manager\">cert-manager<\/a>, for working with Cert-Manager objects in your cluster, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/boz\/kail\">tail<\/a>, offering simplified log streaming, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/zegl\/kube-score\">score<\/a> for static analysis of your objects, and <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.cloudsavvyit.com\/?p=15937\">ctx and ns<\/a> to streamline switching between contexts and namespaces.<\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/devops\/how-to-get-started-with-krew-the-kubectl-plugin-manager\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;How to Get Started With Krew, the Kubectl Plugin Manager&#8221; Krew is a package manager for Kubectl, the official Kubernetes CLI. Using Krew you can find, install, and update Kubectl plugins that extend the CLI with additional functionality. Kubectl\u2019s plugins mechanism supports several plugin installation methods. The simplest way is to pop plugins straight into&#8230;<\/p>\n","protected":false},"author":1,"featured_media":473837,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/wp-content\/uploads\/csit\/2021\/02\/748108a6.jpg?height=200p&trim=2,2,2,2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-473836","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/473836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=473836"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/473836\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/473837"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=473836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=473836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=473836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}