dotnet / tye

Tye is a tool that makes developing, testing, and deploying microservices and distributed applications easier. Project Tye includes a local orchestrator to make developing microservices easier and the ability to deploy microservices to Kubernetes with minimal configuration.
MIT License
5.29k stars 520 forks source link

Tye fails to resolve kubectl installation on Windows #917

Open pratiksanglikar opened 3 years ago

pratiksanglikar commented 3 years ago

Describe the bug

Tye fails to resolve the kubectl installation when kubectl is installed through the PowerShell script on Windows 10.

To Reproduce

  1. Install kubectl through the PowerShell script -

    > Install-Script -Name 'install-kubectl' -Scope CurrentUser -Force
    > install-kubectl.ps1 
  2. Verify kubectl installation

    > kubectl version
    Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.3", GitCommit:"1e11e4a2108024935ecfcb2912226cedeafd99df", GitTreeState:"clean", BuildDate:"2020-10-14T12:50:19Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"windows/amd64"}
  3. install Tye dotnet tool install -g Microsoft.Tye --version "0.6.0-alpha.21070.5"

  4. create a new project and add it to the solution -

    > mkdir microservice
    > cd microservice
    > dotnet new razor -n frontend
    > dotnet new sln
    > dotnet sln add frontend
  5. Try deploying the tye application tye deploy --interactive

  6. Notice the error -

    > tye deploy --interactive
    Loading Application Details...
    Verifying kubectl installation...
    Drats! 'deploy' failed:
        Cannot apply manifests because kubectl is not installed.

Further technical details

Phiph commented 3 years ago

Hey @pratiksanglikar,

When you have the module installed via PowerShell can you run kubectl in cmd.exe? And also what version of Powershell are you using

I just wanna see what can be done to solve this.

Cheers P

pratiksanglikar commented 3 years ago

Hi @Phiph , Yes, I can run kubectl through cmd.exe when installed via PowerShell.

PowerShell version -

>  Get-Host | Select-Object Version

Version
-------
5.1.19041.610
Phiph commented 3 years ago

Thanks @pratiksanglikar

Looks like the kube detector uses a new Process() object - I don't know much about how it interacts with Powershell.

https://github.com/dotnet/tye/blob/ae44f395420e4fffdcaa93dc06c1dccd696db52f/src/shared/KubectlDetector.cs#L40

I'll experiment with the set up soon and let you know what I find. in the meantime I don't suppose you've got another project that plays well with kubectl installed via powershell that runs .net core?

pratiksanglikar commented 3 years ago

Thank you for looking into it, @Phiph! I just checked that I can create a .NET Core project with DevSpaces support, which can play with the same kubectl installed via PowerShell.

angellaa commented 3 years ago

I had the same issue by installing kubectl on Windows using the official instructions and making it available on the path: https://kubernetes.io/docs/tasks/tools/install-kubectl/

angellaa commented 3 years ago

Installing Docker Desktop and Enabling Kubernetes in the UI made the "tye deploy" to successfully detect kubectl

andreatosato commented 2 years ago

@angellaa Can you explain you case? I have installed minik8s and Docker Desktop with Kubernetes.

Where is "UI"?