Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubectl Unable to connect to the server Azure Kubernetes Service #1000

Closed
realnikhilkumar opened this issue Jan 6, 2021 · 5 comments
Closed
Labels
kind/support Categorizes issue or PR as a support question. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@realnikhilkumar
Copy link

Hi,

I am getting below error when using kubectl with MS AKS. I had followed all Microsoft documentation and Kubernetes documentation.

kubectl get nodes
Unable to connect to the server: x509: certificate signed by unknown authority

Azure CLI 2.17.1

Please see below output for aks cli install

PS C:\Users\nikhil.kumar1.kube> az aks install-cli
Downloading client to "C:\Users\nikhil.kumar1.azure-kubectl\kubectl.exe" from "https://storage.googleapis.com/kubernetes-release/release/v1.20.1/bin/windows/amd64/kubectl.exe"
Please add "C:\Users\nikhil.kumar1.azure-kubectl" to your search PATH so the kubectl.exe can be found. 2 options:
1. Run "set PATH=%PATH%;C:\Users\nikhil.kumar1.azure-kubectl" or "$env:path += 'C:\Users\nikhil.kumar1.azure-kubectl'" for PowerShell. This is good for the current command session.
2. Update system PATH environment variable by following "Control Panel->System->Advanced->Environment Variables", and re-open the command window. You only need to do it once
Downloading client to "C:\Users\NIKHIL~1.KUM\AppData\Local\Temp\tmp8fburcp1\kubelogin.zip" from "https://github.com/Azure/kubelogin/releases/download/v0.0.7/kubelogin.zip"
Please add "C:\Users\nikhil.kumar1.azure-kubelogin" to your search PATH so the kubelogin.exe can be found. 2 options:
1. Run "set PATH=%PATH%;C:\Users\nikhil.kumar1.azure-kubelogin" or "$env:path += 'C:\Users\nikhil.kumar1.azure-kubelogin'" for PowerShell. This is good for the current command session.
2. Update system PATH environment variable by following "Control Panel->System->Advanced->Environment Variables", and re-open the command window. You only need to do it once
PS C:\Users\nikhil.kumar1.kube>

Environment variables were updated.

Regards,
Nikhil

@realnikhilkumar realnikhilkumar added the kind/support Categorizes issue or PR as a support question. label Jan 6, 2021
@k8s-ci-robot
Copy link
Contributor

@realnikhilkumar: This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jan 6, 2021
@Clivern
Copy link

Clivern commented Jan 6, 2021

@realnikhilkumar i think this might help --> #823

@realnikhilkumar
Copy link
Author

Hi,

In my case this error was very misleading. It has nothing to do with actual certificate. Microsoft should have done better job in documentation at their end. The error given is incorrect. Error should actually inform user about not have proper runtime setup. AKS is expecting that the user is using a UNIX/Linux terminal not default Azure-CLI. AKS is expecting user to use AKS CLI from a UNIX/Linux terminal/emulator.

I worked with Microsoft Support on this.

Following is the resolution: (Windows 10 system preferred version 2004 or later)

  1. From Control Panel -> Programs -> Turn Windows Features On or Off
  2. Enable Virtual Machine Platform
  3. Enable Windows Subsystem for Linux
  4. Reboot
  5. From Windows Store Install Ubuntu 18.04 LTS
  6. Launch Ubuntu follow prompt to create user id and password
  7. On Ubuntu prompt run command given in option 1 (curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash)
  8. Install kubectl by running sudo az aks install-cli
  9. login to portal.azure.com and copy the connection instructions for AKS cluster
  10. On Ubuntu prompt run az login
  11. On Ubuntu prompt paste the AKS cluster connection commands (az account set --subscription and az aks get-credentials)
  12. This will create config file with certificates readable through bash shell

Reference links
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli
https://docs.microsoft.com/en-us/windows/wsl/about
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt

Follow above four links one by one, do not click Next Steps at bottom of the page.

@PurnachandRaja
Copy link

PurnachandRaja commented Feb 28, 2023

If you want to avoid the hassle of installing WSL just simply add env variables to path in system variables
Control Panel->System->Advanced system settings->Environment Variables->System variables->Path->Edit->New

Add below paths one after other
C:\Users\nikhil.kumar1.azure-kubectl
C:\Users\nikhil.kumar1.azure-kubelogin

@PurnachandRaja
Copy link

there should be a \ after system name not sure why it is not showing up in earlier comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

4 participants