<p>I'm using an Kubernetes server with API version (1.25.2) . When I try to do a kubectl command getting the below error</p>
<pre><code>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
</code></pre>
<p>From the same terminal I'm able to access the Kubernetes server with version 1.23.12.</p>
<p>Is this due to an old kubectl clieint version?.</p>
<pre><code>TRONBQQ2:~$ kubectl version --client
Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;19&quot;, GitVersion:&quot;v1.19.4&quot;, GitCommit:&quot;d360454c9bcd1634cf4cc52d1867af5491dc9c5f&quot;, GitTreeState:&quot;clean&quot;, 
BuildDate:&quot;2020-11-11T13:17:17Z&quot;, GoVersion:&quot;go1.15.2&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}
TRONBQQ2:~$ sudo apt-get install -y kubectl
Reading package lists... Done
Building dependency tree
Reading state information... Done
</code></pre>
<p>kubectl is already the newest version (1.19.4-00).
0 upgraded, 0 newly installed, 0 to remove and 313 not upgraded.</p>
<p>I even tried to upgrade the <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-kubectl-binary-with-curl-on-linux" rel="nofollow noreferrer">kubectl</a> . Even after upgrade, version remains in v1.19.4. Not sure this is the reason for the above mentioned error</p>

<p>Try to check whether the the following command is printing the  below options.</p>
<pre><code>&gt;&gt;&gt;kubelogin -h

Login to azure active directory and populate kubeconfig with AAD tokens

Usage:
  kubelogin [flags]
  kubelogin [command]

Available Commands:
    completion         Generate the autocompletion script for the specified shell
   convert-kubeconfig convert kubeconfig to use exec auth module
   get-token          get AAD token
  help               Help about any command
  remove-tokens      Remove all cached tokens from filesystem

 Flags:
     -h, --help          help for kubelogin
     --logtostderr   log to standard error instead of files (default true)
 -v, --v Level       number for the log level verbosity
  --version       version for kubelogin
</code></pre>
<p>It seems I was having a different kubelogin and missed the above specified Command Options. So I installed the new version of kubelogin using</p>
<pre><code> az aks install-cli
</code></pre>
<p>If that doesn't work, then you can refer &quot;<a href="https://i.stack.imgur.com/bB2N7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bB2N7.png" alt="enter image description here" /></a>&quot; to get the kubelogin brew package</p>
<p>Also export the below path</p>
<pre><code>export PATH=&quot;/usr/local/bin:$PATH&quot;
</code></pre>
<p>Once the kubelogin is available , run the below command to convert your  KUBECONFIG</p>
<pre><code>kubelogin convert-kubeconfig ./kube/config
</code></pre>
