windowspowershellinstallationkubectlchocolatey

Error while installing kubectl in Windows 10


Installing the kubectl on windows 10 not working. I follow this URL.

I tried different install options, in the powershell and using chocolote. None of them worked for me. The error is clear that this execuable is not supported for windows os. I did checked the SHA but it is different.

PS D:\chocoloate_tmpdir> curl -o kubectl.exe.sha256 https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/windows/amd64/kubectl.exe.sha256
PS D:\chocoloate_tmpdir> Get-FileHash kubectl.exe                                                                                                                                               
Algorithm       Hash                                                                   Path
---------       ----                                                                   ----
SHA256          02F984988E490046CBC831A582D34505C28C7DD9AB61C357E264C7178596B701       D:\chocoloate_tmpdir\kubectl.exe

PS D:\chocoloate_tmpdir> Get-FileHash .\kubectl.exe.sha256                                                                                                                                      
Algorithm       Hash                                                                   Path
---------       ----                                                                   ----
SHA256          98BCEB6AF839704828C28709B60628E25CF5F624A6D6E7D06F1FC255AA4254CB       D:\chocoloate_tmpdir\kubectl.exe.sha256

question is, what could be the issue and what other methods are available for installing kubectl in windows.

Here are the commands tried and error output:

one:

PS D:\chocoloate_tmpdir> choco install kubernetes-cli                                                                                                                                           Chocolatey v0.10.15
Installing the following packages:
kubernetes-cli
By installing you accept licenses for the packages.
Progress: Downloading kubernetes-cli 1.17.1... 100%

kubernetes-cli v1.17.1 [Approved]
kubernetes-cli package files install completed. Performing other installation steps.
The package kubernetes-cli wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): Y

Extracting 64-bit C:\ProgramData\chocolatey\lib\kubernetes-cli\tools\kubernetes-client-windows-amd64.tar.gz to C:\ProgramData\chocolatey\lib\kubernetes-cli\tools...
C:\ProgramData\chocolatey\lib\kubernetes-cli\tools
Extracting 64-bit C:\ProgramData\chocolatey\lib\kubernetes-cli\tools\kubernetes-client-windows-amd64.tar to C:\ProgramData\chocolatey\lib\kubernetes-cli\tools...
C:\ProgramData\chocolatey\lib\kubernetes-cli\tools
 ShimGen has successfully created a shim for kubectl.exe
 The install of kubernetes-cli was successful.
  Software installed to 'C:\ProgramData\chocolatey\lib\kubernetes-cli\tools'

Chocolatey installed 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
PS D:\chocoloate_tmpdir> kubectl version --client                                                                                                                                               Program 'kubectl.exe' failed to run: The specified executable is not a valid application for this OS platform.At line:1 char:1
+ kubectl version --client
+ ~~~~~~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ kubectl version --client
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

two:

PS D:\chocoloate_tmpdir> curl -o kubectl.exe https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/windows/amd64/kubectl.exe 
PS D:\chocoloate_tmpdir> cp .\kubectl.exe C:\bin\ 
PS D:\chocoloate_tmpdir> kubectl version                                                                                                                                                        Program 'kubectl.exe' failed to run: The specified executable is not a valid application for this OS platform.At line:1 char:1
+ kubectl version
+ ~~~~~~~~~~~~~~~.
At line:1 char:1
+ kubectl version
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

Solution

  • You've probably missed some of these steps:

    Copy the binary to a folder in your PATH. If you have an existing directory in your PATH that you use for command line utilities, copy the binary to that directory. Otherwise, complete the following steps.

    1. Create a new directory for your command line binaries, such as C:\bin.

    2. Copy the kubectl.exe binary to your new directory.

    3. Edit your user or system PATH environment variable to add the new directory to your PATH.

    4. Close your PowerShell terminal and open a new one to pick up the new PATH variable.

    Please verify what is the current content of your PATH. You can move your kubectl binary directly to one of those folders which are already added to your PATH. Alternatively you may edit it and add your desired directory containing kubectl. Have you relaunched your PowerShell terminal after saving the changes ? It's quite straightforward to configure and there is no need to use full paths to the executable.

    Take a look at this article in the official kubernetes docs.

    Please let me know if it helps.