client-go icon indicating copy to clipboard operation
client-go copied to clipboard

Invalid apiVersion

Open SebastienMelki opened this issue 2 years ago • 10 comments

Hello,

I'm trying to run the out of cluster example found here https://github.com/kubernetes/client-go/tree/master/examples/out-of-cluster-client-configuration . I made sure that 'kubectl get nodes' is working correctly when I run it from my terminal, and also made sure that my kube config if being picked up correctly from ~/.kube/config. But the example code is not running as expected and generating the following error 'exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1"' when running kubernetes.NewForConfig(config).

Any help would be appreciated, I tried searching past issues but didn't find similar errors.

Thanks! image image

SebastienMelki avatar May 19 '22 20:05 SebastienMelki

I've the identical issue.

I tried, as a test, to set 'apiVersion: client.authentication.k8s.io/v1beta1' in my .kube/config file, and while that got me past the error described above (exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1") with (kubernetes.NewForConfig(config) it lead me to this further error below in the next part of the code (clientset.CoreV1().Pods) listing pods.

Get "https://**********************.us-east-1.eks.amazonaws.com/api/v1/namespaces/kube-system/pods": getting credentials: decoding stdout: no kind "ExecCredential" is registered for version "client.authentication.k8s.io/v1alpha1" in scheme "pkg/runtime/scheme.go:100"

ocallaghane avatar May 20 '22 14:05 ocallaghane

I've the identical issue. use aws eks

zhengyansheng avatar May 24 '22 02:05 zhengyansheng

I was facing the same problem with kubernetes server version is 1.20.x and client-go version 0.24.0 . I downgraded my client-go version to 0.20.4 and it worked. Please make sure that the client-go version is compatible with the version of your K8s server.

krriteshgupta avatar May 24 '22 05:05 krriteshgupta

I was facing the same problem with kubernetes server version is 1.20.x and client-go version 0.24.0 . I downgraded my client-go version to 0.20.4 and it worked. Please make sure that the client-go version is compatible with the version of your K8s server.

Thanks alot @krriteshgupta - this fixed the issue downgrading the client-go to 0.20.4 (AWS EKS 1.21.x)

ocallaghane avatar May 24 '22 13:05 ocallaghane

I can talk to EKS okay from v0.24.1. The most recent version of the AWS cli will generate a kubeconfig with client.authentication.k8s.io/v1beta1 . The newer AWS cli also include the correct version in the response from aws eks get-token --cluster-name:

{
  "kind": "ExecCredential",
  "apiVersion": "client.authentication.k8s.io/v1beta1",
  "spec": {},
  "status": {
    "expirationTimestamp": "2022-06-15T06:22:26Z",
    "token": "k8s-aws-..snip.."
  }
}

More details here: https://github.com/aws/aws-cli/issues/6920

russau avatar Jun 15 '22 06:06 russau

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Sep 13 '22 07:09 k8s-triage-robot

I've the identical issue.

I tried, as a test, to set 'apiVersion: client.authentication.k8s.io/v1beta1' in my .kube/config file, and while that got me past the error described above (exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1") with (kubernetes.NewForConfig(config) it lead me to this further error below in the next part of the code (clientset.CoreV1().Pods) listing pods.

Get "https://**********************.us-east-1.eks.amazonaws.com/api/v1/namespaces/kube-system/pods": getting credentials: decoding stdout: no kind "ExecCredential" is registered for version "client.authentication.k8s.io/v1alpha1" in scheme "pkg/runtime/scheme.go:100"

I have a similar issue. Any help would be appreciated.

ngangadhar-pki avatar Sep 23 '22 14:09 ngangadhar-pki

I'm facing the same problem

clayrisser avatar Sep 23 '22 17:09 clayrisser

I'm facing the same problem

@clayrisser Updating AWS CLI V1 to V2 helped me solve this.

ngangadhar-pki avatar Sep 23 '22 19:09 ngangadhar-pki

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Oct 23 '22 20:10 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Nov 22 '22 20:11 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

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 avatar Nov 22 '22 20:11 k8s-ci-robot

In my case, I was running the go command via Linux Cron. And the PATH variable contains only the "/usr/bin" path. AWS CLI v2 was in "/usr/local/bin". AWS CLI v1 was in "/usr/bin". Go program used AWS CLI v1 and hence this error.

After adding PATH=/usr/local/bin:$PATH to the Cron command, issue resolved.

karthikeayan avatar Jul 26 '23 09:07 karthikeayan

PATH=/usr/local/bin:$PATH

This worked for me! Thank you!

kaye-alvarado avatar Sep 13 '23 13:09 kaye-alvarado

doc for aws: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions

Vinaum8 avatar Sep 27 '23 17:09 Vinaum8