I’m using an Kubernetes server with API version (1.25.2) . When I try to do a kubectl command getting the below error
TRONBQQ2:~$ kubectl get nodes
error: unknown flag: --environment
error: unknown flag: --environment
error: unknown flag: --environment
error: unknown flag: --environment
error: unknown flag: --environment
Unable to connect to the server: getting credentials: exec: executable kubelogin failed with exit code 1
From the same terminal I’m able to access the Kubernetes server with version 1.23.12.
Is this due to an old kubectl clieint version?.
TRONBQQ2:~$ kubectl version --client
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.4", GitCommit:"d360454c9bcd1634cf4cc52d1867af5491dc9c5f", GitTreeState:"clean",
BuildDate:"2020-11-11T13:17:17Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}
TRONBQQ2:~$ sudo apt-get install -y kubectl
Reading package lists... Done
Building dependency tree
Reading state information... Done
kubectl is already the newest version (1.19.4-00).
0 upgraded, 0 newly installed, 0 to remove and 313 not upgraded.
I even tried to upgrade the kubectl . Even after upgrade, version remains in v1.19.4. Not sure this is the reason for the above mentioned error
2
Answers
Try to check whether the the following command is printing the below options.
It seems I was having a different kubelogin and missed the above specified Command Options. So I installed the new version of kubelogin using
If that doesn't work, then you can refer "" to get the kubelogin brew package
Also export the below path
Once the kubelogin is available , run the below command to convert your KUBECONFIG
I tried to reproduce the same issue in my environment and got the below results
I did the following issue to resolve the issue
This issue will occur due to the version, we have to upgrade the latest version
I have set the subscription id to AKS cluster using below command
My current AKS version is 1.23.12
My Kubectl version is
This error will occur based on the kube/config file and the config file should be exist
I have the config file configured we won’t get any error
Below is my config file
I have followed the below commands to access the kubectl commands