'Server could not find the requested resource

How to fix this? I am trying to get the version of kubectl but says server not found. I have already installed kubernetes in my PC.

enter image description here



Solution 1:[1]

If you are using minikube - just start minikube that will sort this problem

'minikube start --memory=4096'

Solution 2:[2]

You need to configure the KUBECONFIG which indicates the list of address and certs of k8s api servers, contexts and users.

Once you configure it correctly, kubectl can reach to the server.

The default path of kubeconfig is ~/.kube/config. Also you can specify it using environment variable KUBECONFIG and --kubeconfig flag with kubectl cli. ex:

export KUBECONFIG=your_kubeconfig_file_path
kubectl config get-contexts

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 maxkart
Solution 2 James Wang