Kubectl config file windows

Содержание
  1. Install Tools
  2. kubectl
  3. minikube
  4. kubeadm
  5. Feedback
  6. Install and Set Up kubectl on Windows
  7. Before you begin
  8. Install kubectl on Windows
  9. Install kubectl binary with curl on Windows
  10. Install with PowerShell from PSGallery
  11. Install on Windows using Chocolatey or Scoop
  12. Install on Windows as part of the Google Cloud SDK
  13. Verify kubectl configuration
  14. Optional kubectl configurations
  15. Enable shell autocompletion
  16. What’s next
  17. Feedback
  18. kubectl windows should use %USERPROFILE%/.kube as expected location for config file #2
  19. Comments
  20. giffinj commented Sep 8, 2016
  21. eirslett commented Sep 9, 2016 •
  22. samuelms1 commented Dec 13, 2016
  23. Krylon360 commented Dec 22, 2016
  24. mattdelco commented Jan 2, 2018
  25. Tasks
  26. Kubernetes v1.17 documentation is no longer actively maintained. The version you are currently viewing is a static snapshot. For up-to-date documentation, see the latest version.
  27. Install and Set Up kubectl
  28. Before you begin
  29. Install kubectl on Linux
  30. Install kubectl binary with curl on Linux
  31. Install using native package management
  32. Install using other package management
  33. Install kubectl on macOS
  34. Install kubectl binary with curl on macOS
  35. Install with Homebrew on macOS
  36. Install with Macports on macOS
  37. Install kubectl on Windows
  38. Install kubectl binary with curl on Windows
  39. Install with Powershell from PSGallery
  40. Install on Windows using Chocolatey or Scoop
  41. Download as part of the Google Cloud SDK
  42. Verifying kubectl configuration
  43. Optional kubectl configurations
  44. Enabling shell autocompletion
  45. Introduction
  46. Install bash-completion
  47. Enable kubectl autocompletion
  48. Introduction
  49. Upgrade Bash
  50. Install bash-completion
  51. Enable kubectl autocompletion
  52. What’s next
  53. Feedback

Install Tools

kubectl

The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs. For more information including a complete list of kubectl operations, see the kubectl reference documentation.

kubectl is installable on a variety of Linux platforms, macOS and Windows. Find your preferred operating system below.

kind lets you run Kubernetes on your local computer. This tool requires that you have Docker installed and configured.

The kind Quick Start page shows you what you need to do to get up and running with kind.

minikube

Like kind , minikube is a tool that lets you run Kubernetes locally. minikube runs a single-node Kubernetes cluster on your personal computer (including Windows, macOS and Linux PCs) so that you can try out Kubernetes, or for daily development work.

You can follow the official Get Started! guide if your focus is on getting the tool installed.

Once you have minikube working, you can use it to run a sample application.

kubeadm

You can use the kubeadm tool to create and manage Kubernetes clusters. It performs the actions necessary to get a minimum viable, secure cluster up and running in a user friendly way.

Installing kubeadm shows you how to install kubeadm. Once installed, you can use it to create a cluster.

Feedback

Was this page helpful?

Thanks for the feedback. If you have a specific, answerable question about how to use Kubernetes, ask it on Stack Overflow. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.

Install and Set Up kubectl on Windows

Before you begin

You must use a kubectl version that is within one minor version difference of your cluster. For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master. Using the latest version of kubectl helps avoid unforeseen issues.

Install kubectl on Windows

The following methods exist for installing kubectl on Windows:

Install kubectl binary with curl on Windows

Or if you have curl installed, use this command:

Validate the binary (optional)

Download the kubectl checksum file:

Validate the kubectl binary against the checksum file:

Using Command Prompt to manually compare CertUtil ‘s output to the checksum file downloaded:

Using PowerShell to automate the verification using the -eq operator to get a True or False result:

Add the binary in to your PATH .

Test to ensure the version of kubectl is the same as downloaded:

Install with PowerShell from PSGallery

If you are on Windows and using the PowerShell Gallery package manager, you can install and update kubectl with PowerShell.

Run the installation commands (making sure to specify a DownloadLocation ):

The installer creates $HOME/.kube and instructs it to create a config file.

Читайте также:  Предупреждение кодовая страница консоли 866 отличается от основной страницы windows 1251

Test to ensure the version you installed is up-to-date:

Install on Windows using Chocolatey or Scoop

To install kubectl on Windows you can use either Chocolatey package manager or Scoop command-line installer.

Test to ensure the version you installed is up-to-date:

Navigate to your home directory:

Create the .kube directory:

Change to the .kube directory you just created:

Configure kubectl to use a remote Kubernetes cluster:

Install on Windows as part of the Google Cloud SDK

You can install kubectl as part of the Google Cloud SDK.

Run the kubectl installation command:

Test to ensure the version you installed is up-to-date:

Verify kubectl configuration

In order for kubectl to find and access a Kubernetes cluster, it needs a kubeconfig file, which is created automatically when you create a cluster using kube-up.sh or successfully deploy a Minikube cluster. By default, kubectl configuration is located at

Check that kubectl is properly configured by getting the cluster state:

If you see a URL response, kubectl is correctly configured to access your cluster.

If you see a message similar to the following, kubectl is not configured correctly or is not able to connect to a Kubernetes cluster.

For example, if you are intending to run a Kubernetes cluster on your laptop (locally), you will need a tool like Minikube to be installed first and then re-run the commands stated above.

If kubectl cluster-info returns the url response but you can’t access your cluster, to check whether it is configured properly, use:

Optional kubectl configurations

Enable shell autocompletion

kubectl provides autocompletion support for Bash and Zsh, which can save you a lot of typing.

Below are the procedures to set up autocompletion for Zsh, if you are running that on Windows.

The kubectl completion script for Zsh can be generated with the command kubectl completion zsh . Sourcing the completion script in your shell enables kubectl autocompletion.

To do so in all your shell sessions, add the following to your

If you have an alias for kubectl, you can extend shell completion to work with that alias:

After reloading your shell, kubectl autocompletion should be working.

If you get an error like complete:13: command not found: compdef , then add the following to the beginning of your

What’s next

  • Install Minikube
  • See the getting started guides for more about creating clusters.
  • Learn how to launch and expose your application.
  • If you need access to a cluster you didn’t create, see the Sharing Cluster Access document.
  • Read the kubectl reference docs

Feedback

Was this page helpful?

Thanks for the feedback. If you have a specific, answerable question about how to use Kubernetes, ask it on Stack Overflow. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.

kubectl windows should use %USERPROFILE%/.kube as expected location for config file #2

Comments

giffinj commented Sep 8, 2016

Windows does not have an environment variable «HOME» by default, but does have «USERPROFILE». Would it make more sense to default the config location to %USERPROFILE%/.kube/config on Windows so users don’t need to know to create a variable HOME? Thanks!

The text was updated successfully, but these errors were encountered:

eirslett commented Sep 9, 2016 •

Maybe. You could send a PR if you want to! It would need to include a recompilation of the binary as well. EDIT: Actually I’m not sure if we would need a new binary. Maybe an update to the documentation would be enough.

samuelms1 commented Dec 13, 2016

@eirslett I have the 1.5.0 binary. If you give me permissions to this repo I’d like to add the binary to the repo releases.

Krylon360 commented Dec 22, 2016

Windows 10 Enterprise seems to be missing the %USERPROFILE% variable. I’ve seen this on several installs with different users

mattdelco commented Jan 2, 2018

On Windows program configuration settings typically go under %LOCALAPPDATA% or %APPDATA% , both of which are usually under %USERPROFILE%\AppData. The former stays only on the current system, while the latter migrates around from one system to another (this is in the context of multiple machines joined to the same domain and a domain user moving from one machine to another).

Читайте также:  1909 windows 10 тормозит

Tasks

Kubernetes v1.17 documentation is no longer actively maintained. The version you are currently viewing is a static snapshot. For up-to-date documentation, see the latest version.

Install and Set Up kubectl

The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs. For a complete list of kubectl operations, see Overview of kubectl.

Before you begin

You must use a kubectl version that is within one minor version difference of your cluster. For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master. Using the latest version of kubectl helps avoid unforeseen issues.

Install kubectl on Linux

Install kubectl binary with curl on Linux

Download the latest release with the command:

To download a specific version, replace the $(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) portion of the command with the specific version.

For example, to download version v1.17.17 on Linux, type:

Make the kubectl binary executable.

Move the binary in to your PATH.

Test to ensure the version you installed is up-to-date:

Install using native package management

Install using other package management

If you are on Ubuntu or another Linux distribution that support snap package manager, kubectl is available as a snap application.

If you are on Linux and using Homebrew package manager, kubectl is available for installation.

Install kubectl on macOS

Install kubectl binary with curl on macOS

Download the latest release:

To download a specific version, replace the $(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) portion of the command with the specific version.

For example, to download version v1.17.17 on macOS, type:

Make the kubectl binary executable.

Move the binary in to your PATH.

Test to ensure the version you installed is up-to-date:

Install with Homebrew on macOS

If you are on macOS and using Homebrew package manager, you can install kubectl with Homebrew.

Run the installation command:

Test to ensure the version you installed is up-to-date:

Install with Macports on macOS

If you are on macOS and using Macports package manager, you can install kubectl with Macports.

Run the installation command:

Test to ensure the version you installed is up-to-date:

Install kubectl on Windows

Install kubectl binary with curl on Windows

Download the latest release v1.17.17 from this link.

Or if you have curl installed, use this command:

To find out the latest stable version (for example, for scripting), take a look at https://storage.googleapis.com/kubernetes-release/release/stable.txt.

Add the binary in to your PATH.

Test to ensure the version of kubectl is the same as downloaded:

Install with Powershell from PSGallery

If you are on Windows and using Powershell Gallery package manager, you can install and update kubectl with Powershell.

Run the installation commands (making sure to specify a DownloadLocation ):

The installer creates $HOME/.kube and instructs it to create a config file

Test to ensure the version you installed is up-to-date:

Install on Windows using Chocolatey or Scoop

To install kubectl on Windows you can use either Chocolatey package manager or Scoop command-line installer.

Test to ensure the version you installed is up-to-date:

Navigate to your home directory:

Create the .kube directory:

Change to the .kube directory you just created:

Configure kubectl to use a remote Kubernetes cluster:

Download as part of the Google Cloud SDK

You can install kubectl as part of the Google Cloud SDK.

Run the kubectl installation command:

Test to ensure the version you installed is up-to-date:

Verifying kubectl configuration

In order for kubectl to find and access a Kubernetes cluster, it needs a kubeconfig file, which is created automatically when you create a cluster using kube-up.sh or successfully deploy a Minikube cluster. By default, kubectl configuration is located at

Check that kubectl is properly configured by getting the cluster state:

If you see a URL response, kubectl is correctly configured to access your cluster.

If you see a message similar to the following, kubectl is not configured correctly or is not able to connect to a Kubernetes cluster.

For example, if you are intending to run a Kubernetes cluster on your laptop (locally), you will need a tool like Minikube to be installed first and then re-run the commands stated above.

If kubectl cluster-info returns the url response but you can’t access your cluster, to check whether it is configured properly, use:

Читайте также:  Изменить дополнительные параметры общего доступа windows 10 не работает

Optional kubectl configurations

Enabling shell autocompletion

kubectl provides autocompletion support for Bash and Zsh, which can save you a lot of typing.

Below are the procedures to set up autocompletion for Bash (including the difference between Linux and macOS) and Zsh.

Introduction

The kubectl completion script for Bash can be generated with the command kubectl completion bash . Sourcing the completion script in your shell enables kubectl autocompletion.

However, the completion script depends on bash-completion, which means that you have to install this software first (you can test if you have bash-completion already installed by running type _init_completion ).

Install bash-completion

bash-completion is provided by many package managers (see here). You can install it with apt-get install bash-completion or yum install bash-completion , etc.

The above commands create /usr/share/bash-completion/bash_completion , which is the main script of bash-completion. Depending on your package manager, you have to manually source this file in your

To find out, reload your shell and run type _init_completion . If the command succeeds, you’re already set, otherwise add the following to your

Reload your shell and verify that bash-completion is correctly installed by typing type _init_completion .

Enable kubectl autocompletion

You now need to ensure that the kubectl completion script gets sourced in all your shell sessions. There are two ways in which you can do this:

Source the completion script in your

Add the completion script to the /etc/bash_completion.d directory:

If you have an alias for kubectl, you can extend shell completion to work with that alias:

Both approaches are equivalent. After reloading your shell, kubectl autocompletion should be working.

Introduction

The kubectl completion script for Bash can be generated with kubectl completion bash . Sourcing this script in your shell enables kubectl completion.

However, the kubectl completion script depends on bash-completion which you thus have to previously install.

Upgrade Bash

The instructions here assume you use Bash 4.1+. You can check your Bash’s version by running:

If it is too old, you can install/upgrade it using Homebrew:

Reload your shell and verify that the desired version is being used:

Homebrew usually installs it at /usr/local/bin/bash .

Install bash-completion

You can test if you have bash-completion v2 already installed with type _init_completion . If not, you can install it with Homebrew:

As stated in the output of this command, add the following to your

Reload your shell and verify that bash-completion v2 is correctly installed with type _init_completion .

Enable kubectl autocompletion

You now have to ensure that the kubectl completion script gets sourced in all your shell sessions. There are multiple ways to achieve this:

Source the completion script in your

Add the completion script to the /usr/local/etc/bash_completion.d directory:

If you have an alias for kubectl, you can extend shell completion to work with that alias:

If you installed kubectl with Homebrew (as explained above), then the kubectl completion script should already be in /usr/local/etc/bash_completion.d/kubectl . In that case, you don’t need to do anything.

In any case, after reloading your shell, kubectl completion should be working.

The kubectl completion script for Zsh can be generated with the command kubectl completion zsh . Sourcing the completion script in your shell enables kubectl autocompletion.

To do so in all your shell sessions, add the following to your

If you have an alias for kubectl, you can extend shell completion to work with that alias:

After reloading your shell, kubectl autocompletion should be working.

If you get an error like complete:13: command not found: compdef , then add the following to the beginning of your

What’s next

  • Install Minikube
  • See the getting started guides for more about creating clusters.
  • Learn how to launch and expose your application.
  • If you need access to a cluster you didn’t create, see the Sharing Cluster Access document.
  • Read the kubectl reference docs

Feedback

Was this page helpful?

Thanks for the feedback. If you have a specific, answerable question about how to use Kubernetes, ask it on Stack Overflow. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.

Оцените статью