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

Unable to connect to context #1619

Closed
carlosleoliveira opened this issue Jun 28, 2022 · 23 comments
Closed

Unable to connect to context #1619

carlosleoliveira opened this issue Jun 28, 2022 · 23 comments
Labels
question Further information is requested

Comments

@carlosleoliveira
Copy link




Describe the bug
After I updated to version 0.25.19 when I open k9s can't get into any context. Get the 'unable to connect to context' after a while get the toast message.

To Reproduce
Steps to reproduce the behavior:

brew update k9s or brew install k9s
scoop install k9s

Expected behavior
View my pods, deployments, etc

Versions (please complete the following information):

  • OS: [Fedora 36, Windows 10]
  • K9s: [0.25.19]
  • K8s: [1.23.3]
@mouchar
Copy link

mouchar commented Jun 28, 2022

I have same issue, check /tmp/k9s-$USERNAME.log for details. In my case, it is caused by:

Unable to connect to api server error="exec plugin: invalid apiVersion \"client.authentication.k8s.io/v1alpha1\""

while connecting to EKS. Note that EKS does not (and will not) support alpha APIs so any k8s client app (like k9s) built with recent k8s.io/api package will not work with EKS :(

I'm reverting back to v0.25.18 that works fine.

@BitProcessor
Copy link

BitProcessor commented Jun 28, 2022

Same here 😢 (also EKS)

@carlosleoliveira
Copy link
Author

carlosleoliveira commented Jun 28, 2022

For me is EKS too. I'll leave my log file:

9:45AM INF 🐶 K9s starting up...
9:45AM WRN Unable to dial discovery API error="exec plugin: invalid apiVersion \"client.authentication.k8s.io/v1alpha1\""
9:45AM ERR Fail to locate metrics-server error="exec plugin: invalid apiVersion \"client.authentication.k8s.io/v1alpha1\""
9:45AM ERR failed to connect to cluster error="exec plugin: invalid apiVersion \"client.authentication.k8s.io/v1alpha1\""
9:45AM WRN No context specific skin file found -- /home/leo/.config/k9s/arn:aws:eks::cluster/cluster_skin.yml
9:45AM WRN No skin file found -- /home/leo/.config/k9s/skin.yml. Loading stock skins.
9:45AM ERR Load cluster resources - No API server connection
9:45AM WRN Custom view load failed /home/leo/.config/k9s/views.yml error="open /home/leo/.config/k9s/views.yml: no such file or directory"
9:45AM WRN CustomView watcher failed error="no such file or directory"
9:45AM ERR Unable to connect to api server error="exec plugin: invalid apiVersion \"client.authentication.k8s.io/v1alpha1\""
9:45AM ERR Load cluster resources - No API server connection
9:45AM WRN Unable to dial discovery API error="No connection to cached dial"
9:46AM ERR Unable to connect to api server error="exec plugin: invalid apiVersion \"client.authentication.k8s.io/v1alpha1\""
9:46AM ERR Context switch failed error="Unable to connect to context \"arn:aws:eks::cluster/-cluster\""
9:46AM ERR Unable to connect to context "arn:aws:eks::cluster/-cluster"
9:46AM ERR Unable to connect to api server error="exec plugin: invalid apiVersion \"client.authentication.k8s.io/v1alpha1\""
9:46AM ERR ClusterUpdater failed error="Conn check failed (1/5)"
9:46AM ERR Unable to connect to api server error="exec plugin: invalid apiVersion \"client.authentication.k8s.io/v1alpha1\""
9:46AM ERR ClusterUpdater failed error="Conn check failed (2/5)"
9:46AM ERR Unable to connect to api server error="exec plugin: invalid apiVersion \"client.authentication.k8s.io/v1alpha1\""
9:46AM ERR ClusterUpdater failed error="Conn check failed (3/5)"
9:46AM ERR Unable to connect to api server error="exec plugin: invalid apiVersion \"client.authentication.k8s.io/v1alpha1\""
9:46AM ERR ClusterUpdater failed error="Conn check failed (4/5)"
9:46AM ERR Unable to connect to api server error="exec plugin: invalid apiVersion \"client.authentication.k8s.io/v1alpha1\""
9:46AM ERR Conn check failed (5/5). Bailing out!

@slimus
Copy link
Collaborator

slimus commented Jun 28, 2022

Hi there! Have you tried to update k8s config like this https://stackoverflow.com/questions/72126048/circleci-message-error-exec-plugin-invalid-apiversion-client-authentication ?

@derailed derailed added the question Further information is requested label Jun 28, 2022
@derailed
Copy link
Owner

@carlosleoliveira Rats!! Thank you all for weighting in on this ding dang deal! In the latest k9s drop I've updated k8s deps to the latest 1.24.2. After further investigation, it looks like the latest k8s client indeed breaks eks ;( @mouchar Thank you for the pointer!!)
So it looks like you need: 1) update your aws cli 2) update your kubeconfig and change apiVersion: client.authentication.k8s.io/v1alpha1 => apiVersion: client.authentication.k8s.io/v1beta1 or run aws eks update-kubeconfig --region MY_REGION --name MY_CLUSTER_NAME

I don't have access to an eks cluster at the moment. Much appreciated if anyone can take this for a spin on eks and report back! If still a dud, I'll revert to an older k8s rev. Thank you!!

@carlosleoliveira
Copy link
Author

carlosleoliveira commented Jun 28, 2022

@slimus @derailed thanks for the reply. The fix was to change the config file to v1beta1. The aws eks update-kubeconfig --region MY_REGION --name MY_CLUSTER_NAME don't solve the problem even with the latest aws cli. I still have a question, I have a self-managed cluster in v1.21.12 and k9s don't show me cpu or mem, what can it be?

image

@derailed
Copy link
Owner

@carlosleoliveira Cool! Thank you for reporting back!! K9s gets its metrics from the metrics-server which must be present on your cluster.

@carlosleoliveira
Copy link
Author

@derailed nice! thanks for the help!

@BitProcessor
Copy link

@carlosleoliveira Rats!! Thank you all for weighting in on this ding dang deal! In the latest k9s drop I've updated k8s deps to the latest 1.24.2. After further investigation, it looks like the latest k8s client indeed breaks eks ;( @mouchar Thank you for the pointer!!) So it looks like you need: 1) update your aws cli 2) update your kubeconfig and change apiVersion: client.authentication.k8s.io/v1alpha1 => apiVersion: client.authentication.k8s.io/v1beta1 or run aws eks update-kubeconfig --region MY_REGION --name MY_CLUSTER_NAME

I don't have access to an eks cluster at the moment. Much appreciated if anyone can take this for a spin on eks and report back! If still a dud, I'll revert to an older k8s rev. Thank you!!

I modified my configs to use: apiVersion: client.authentication.k8s.io/v1beta1
Works like a charm, now happily connecting to EKS 1.21 with k9s 0.25.20

Thanks for the solution!

@damienleger
Copy link

@carlosleoliveira Rats!! Thank you all for weighting in on this ding dang deal! In the latest k9s drop I've updated k8s deps to the latest 1.24.2. After further investigation, it looks like the latest k8s client indeed breaks eks ;( @mouchar Thank you for the pointer!!) So it looks like you need: 1) update your aws cli 2) update your kubeconfig and change apiVersion: client.authentication.k8s.io/v1alpha1 => apiVersion: client.authentication.k8s.io/v1beta1 or run aws eks update-kubeconfig --region MY_REGION --name MY_CLUSTER_NAME

I don't have access to an eks cluster at the moment. Much appreciated if anyone can take this for a spin on eks and report back! If still a dud, I'll revert to an older k8s rev. Thank you!!

hello, just pointing that after the documentation https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/ the client/sever compatibility is guaranteed only with one minor difference.

You must use a kubectl version that is within one minor version difference of your cluster. For example, a v1.24 client can communicate with v1.23, v1.24, and v1.25 control planes. Using the latest compatible version of kubectl helps avoid unforeseen issues.

So imho attempts to make a 1.24 cli works on a 1.21 is a hack that can lead to unexpected behaviours, not a bugfix.

@roma-glushko
Copy link

hey @mouchar, how did you reverted the k9s version? I have tried to run something like brew install k9s@0.25.19 with no luck. Brew could not find that version for some reasons

@Ga13Ou
Copy link

Ga13Ou commented Jun 29, 2022

Same problem for me after updating to version 0.25.19

@Ga13Ou
Copy link

Ga13Ou commented Jun 29, 2022

hey @mouchar, how did you reverted the k9s version? I have tried to run something like brew install k9s@0.25.19 with no luck. Brew could not find that version for some reasons

@roma-glushko
You can use this command to directly rollback to v 0.25.18
curl -sS https://webinstall.dev/k9s@0.25.18 | bash

@yagiel
Copy link

yagiel commented Jul 8, 2022

same issue here with 0.25.19 and above, luckily rollback works:
brew extract --version=0.25.18 k9s homebrew/cask

@justinaslelys
Copy link

Leaving a note if someone else is banging the head against the wall after changing v1alpha1 to v1beta1.
The only thing that worked for me was aws eks update-kubeconfig --region MY_REGION --name MY_CLUSTER_NAME using latest aws cli (2.7.16). k9s is at v0.26.0

@codfather
Copy link

Leaving a note if someone else is banging the head against the wall after changing v1alpha1 to v1beta1. The only thing that worked for me was aws eks update-kubeconfig --region MY_REGION --name MY_CLUSTER_NAME using latest aws cli (2.7.16). k9s is at v0.26.0

Out of interest what version of k8s(kubectl) are you running?

@justinaslelys
Copy link

Leaving a note if someone else is banging the head against the wall after changing v1alpha1 to v1beta1. The only thing that worked for me was aws eks update-kubeconfig --region MY_REGION --name MY_CLUSTER_NAME using latest aws cli (2.7.16). k9s is at v0.26.0

Out of interest what version of k8s(kubectl) are you running?

client kubectl v1.21.5 and cluster v1.22.9-eks

Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.5", GitCommit:"aea7bbadd2fc0cd689de94a54e5b7b758869d691", GitTreeState:"clean", BuildDate:"2021-09-15T21:10:45Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"22+", GitVersion:"v1.22.9-eks-a64ea69", GitCommit:"540410f9a2e24b7a2a870ebfacb3212744b5f878", GitTreeState:"clean", BuildDate:"2022-05-12T19:15:31Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}

@akshaykalekar
Copy link

updating aws cli to 2.7.x and rerunning aws eks update-kubeconfig solved the issue

aws --version
aws-cli/2.7.27 Python/3.10.6 Darwin/21.6.0 source/x86_64 prompt/off

@munir131
Copy link

In my case it was due to GKE auth plugin issue. Just update plugin https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
I found that in log as @mouchar mentioned in first comment. Thanks

@materazzi9
Copy link

Hi there! Have you tried to update k8s config like this https://stackoverflow.com/questions/72126048/circleci-message-error-exec-plugin-invalid-apiversion-client-authentication ?

This solution worked for me.

I had this error ´´Unable to connect to api server error="exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1""´´

@ikersuen
Copy link

ikersuen commented May 16, 2023

Same issue happened to me for "Unable to connect context" with 'Unable to connect to api server error="exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1""' error.

Updating aws-cli binary version under /usr/local/bin to "aws-cli/2.11.20" and "export PATH=/usr/local/bin" solved the issue.

One may double confirm the kubeconfig under ~/.kube/config for the target cluster context's api version
for aws-cli 1.20.7, they are still using "apiVersion: client.authentication.k8s.io/v1alpha2" and later version of aws-cli used "apiVersion: client.authentication.k8s.io/v1beta1" would be alright.

@eddideku
Copy link

Hello,

I am on aws-cli/2.13.19 and I'm receiving similar error in k9s. Using aws eks-update-kubeconfig wasn't working for me and I found issue #1619 through google searching.

Glancing at the posts from this year, it seems the issue has resurfaced. Thank you @derailed and @ikersuen

I edited ~/.kube/config and changed the apiVersion from v1alpha1 to v1beta1 on the clusters I need to work with and now k9s is working.

@maxcotec
Copy link

reading from above comments, I understand that I need to change apiVersion: client.authentication.k8s.io/v1aplha1 to apiVersion: client.authentication.k8s.io/v1beta1. Manually changing this does not work. I had to re-install the awscli version, this time downgrading to version aws-cli/2.13.19. Updated cluster configs aws eks update-kubeconfig --name your-cluster-name and this now defaults to v1beta1. and k9s is happy.

aws-cli: aws-cli/2.13.19 Python/3.11.5 Darwin/23.4.0 exe/x86_64 prompt/off
k9s: 0.32.4
kubectl: Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.17", GitCommit:"a7736eaf34d823d7652415337ac0ad06db9167fc", GitTreeState:"clean", BuildDate:"2022-12-08T11:47:36Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"darwin/arm64"} Server Version: version.Info{Major:"1", Minor:"22+", GitVersion:"v1.22.17-eks-b9c9ed7", GitCommit:"d7e7b6aee985f2f629a939b809a166a3808e62db", GitTreeState:"clean", BuildDate:"2024-03-02T03:49:51Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests