{"id":407,"date":"2018-04-10T19:15:00","date_gmt":"2018-04-10T17:15:00","guid":{"rendered":"https:\/\/cymbeline.ch\/?p=407"},"modified":"2018-04-11T13:44:02","modified_gmt":"2018-04-11T11:44:02","slug":"fix-slow-kubectl-on-windows","status":"publish","type":"post","link":"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/","title":{"rendered":"Fix slow kubectl on Windows"},"content":{"rendered":"

Over the last few days I noticed that when I use kubectl to manage a k8s test cluster in Azure, it takes forever to actually carry out the operations remotely. Today I took some time to debug this. Here’s how to fix a slow kubectl on Windows.<\/p>\n

Get Verbose Output<\/h2>\n

I started with changing the log level, and capturing the details, like this:<\/p>\n

\r\nkubectl get pods -v=20\r\n<\/pre>\n

The good news is, given that the commands worked so slowly, I had enough time to just read what was going on, and even understand where the problem was. If it’s not so slow, it helps to redirect stderr to a file, like this:<\/p>\n

\r\nkubectl get pods -v=20 2> err.txt\r\n<\/pre>\n

In my case, it turned out that the command was going through a cache which was on the H: drive. That may not mean much to you, but my employer’s IT maps the H: drive to the (remote) home directory. They also set the HOMEDRIVE, HOMEPATH and HOMESHARE environment variables on login. HOMEDRIVE in particular is set to H:. Given that Windows (unlike Linux) by default doesn’t come with a HOME environment variable, kubectl for Windows tries to make up by constructing the HOME path using HOMEDRIVE and HOMEPATH. So kubectl ended up caching everything on a remote share, some 8500 km away. Needless to say, the lag between my workstation and the remote share is noticable.<\/p>\n

How to fix Slow kubectl on Windows<\/h2>\n

So, how do you fix this? Well, it’s actually very easy: set the HOME environment variable to a local directory, run kubectl again, and now it’s a lot faster. In PowerShell, for that session, I just did<\/p>\n

\r\n$env:HOME = $env:USERPROFILE\r\n<\/pre>\n

Now what’s left for me is to try and convince the IT department to stop using the HOMEDRIVE and HOMESHARE for remote users. That’s the tough part \ud83d\ude09<\/p>\n

<\/p>","protected":false},"excerpt":{"rendered":"

Over the last few days I noticed that when I use kubectl to manage a k8s test cluster in Azure, it takes forever to actually carry out the operations remotely. Today I took some time to debug this. Here’s how to fix a slow kubectl on Windows. Get Verbose Output I started with changing the … Continue reading “Fix slow kubectl on Windows”<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[61],"tags":[81,88,89,87,90],"yoast_head":"\nFix slow kubectl on Windows - Tales of a Code Monkey<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fix slow kubectl on Windows - Tales of a Code Monkey\" \/>\n<meta property=\"og:description\" content=\"Over the last few days I noticed that when I use kubectl to manage a k8s test cluster in Azure, it takes forever to actually carry out the operations remotely. Today I took some time to debug this. Here’s how to fix a slow kubectl on Windows. Get Verbose Output I started with changing the … Continue reading "Fix slow kubectl on Windows"\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/\" \/>\n<meta property=\"og:site_name\" content=\"Tales of a Code Monkey\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-10T17:15:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-04-11T11:44:02+00:00\" \/>\n<meta name=\"author\" content=\"roger\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"roger\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/\",\"url\":\"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/\",\"name\":\"Fix slow kubectl on Windows - Tales of a Code Monkey\",\"isPartOf\":{\"@id\":\"https:\/\/cymbeline.ch\/#website\"},\"datePublished\":\"2018-04-10T17:15:00+00:00\",\"dateModified\":\"2018-04-11T11:44:02+00:00\",\"author\":{\"@id\":\"https:\/\/cymbeline.ch\/#\/schema\/person\/cf1f3b3205f4266bf8b68a80fa6b0916\"},\"breadcrumb\":{\"@id\":\"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cymbeline.ch\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fix slow kubectl on Windows\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cymbeline.ch\/#website\",\"url\":\"https:\/\/cymbeline.ch\/\",\"name\":\"Tales of a Code Monkey\",\"description\":\"... the adventures of a guy making software.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cymbeline.ch\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cymbeline.ch\/#\/schema\/person\/cf1f3b3205f4266bf8b68a80fa6b0916\",\"name\":\"roger\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cymbeline.ch\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/33cc08db99ae52beb26ab6fda46e0eb7?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/33cc08db99ae52beb26ab6fda46e0eb7?s=96&r=g\",\"caption\":\"roger\"},\"sameAs\":[\"https:\/\/www.cymbeline.ch\"],\"url\":\"https:\/\/cymbeline.ch\/author\/roger\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fix slow kubectl on Windows - Tales of a Code Monkey","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/","og_locale":"en_US","og_type":"article","og_title":"Fix slow kubectl on Windows - Tales of a Code Monkey","og_description":"Over the last few days I noticed that when I use kubectl to manage a k8s test cluster in Azure, it takes forever to actually carry out the operations remotely. Today I took some time to debug this. Here’s how to fix a slow kubectl on Windows. Get Verbose Output I started with changing the … Continue reading \"Fix slow kubectl on Windows\"","og_url":"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/","og_site_name":"Tales of a Code Monkey","article_published_time":"2018-04-10T17:15:00+00:00","article_modified_time":"2018-04-11T11:44:02+00:00","author":"roger","twitter_misc":{"Written by":"roger","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/","url":"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/","name":"Fix slow kubectl on Windows - Tales of a Code Monkey","isPartOf":{"@id":"https:\/\/cymbeline.ch\/#website"},"datePublished":"2018-04-10T17:15:00+00:00","dateModified":"2018-04-11T11:44:02+00:00","author":{"@id":"https:\/\/cymbeline.ch\/#\/schema\/person\/cf1f3b3205f4266bf8b68a80fa6b0916"},"breadcrumb":{"@id":"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cymbeline.ch\/2018\/04\/10\/fix-slow-kubectl-on-windows\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cymbeline.ch\/"},{"@type":"ListItem","position":2,"name":"Fix slow kubectl on Windows"}]},{"@type":"WebSite","@id":"https:\/\/cymbeline.ch\/#website","url":"https:\/\/cymbeline.ch\/","name":"Tales of a Code Monkey","description":"... the adventures of a guy making software.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cymbeline.ch\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cymbeline.ch\/#\/schema\/person\/cf1f3b3205f4266bf8b68a80fa6b0916","name":"roger","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cymbeline.ch\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/33cc08db99ae52beb26ab6fda46e0eb7?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/33cc08db99ae52beb26ab6fda46e0eb7?s=96&r=g","caption":"roger"},"sameAs":["https:\/\/www.cymbeline.ch"],"url":"https:\/\/cymbeline.ch\/author\/roger\/"}]}},"_links":{"self":[{"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/posts\/407"}],"collection":[{"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/comments?post=407"}],"version-history":[{"count":5,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/posts\/407\/revisions"}],"predecessor-version":[{"id":412,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/posts\/407\/revisions\/412"}],"wp:attachment":[{"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/media?parent=407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/categories?post=407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cymbeline.ch\/wp-json\/wp\/v2\/tags?post=407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}