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

Exec plugin returning bad version #6749

Closed
rwong2888 opened this issue Jul 16, 2021 · 7 comments
Closed

Exec plugin returning bad version #6749

rwong2888 opened this issue Jul 16, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@rwong2888
Copy link
Contributor

I'm trying to use exec plugin and I'm getting this error. I tried v1, v1beta1, v1alpha1 to no avail. Any suggestions?

Get "https://x.x.x.x/version?timeout=32s": getting credentials: exec plugin is configured to use API version client.authentication.k8s.io/v1beta1, plugin returned version client.authentication.k8s.io/__internal
apiVersion: v1
kind: Secret
metadata:
  name: playground-west
  labels:
    argocd.argoproj.io/secret-type: cluster
type: Opaque
stringData:
  name: playground-west
  server: https://x.x.x.x
  config: |
    {
      "execProviderConfig": {
        "command": "gcloud",
        "args": [
          "config",
          "config-helper",
          "--format=json"
        ],
        "apiVersion": "client.authentication.k8s.io/v1beta1"
      }
    }
gcloud version
Google Cloud SDK 347.0.0
alpha 2021.06.25
beta 2021.06.25
bq 2.0.69
core 2021.06.25
gsutil 4.64
@rwong2888 rwong2888 added the bug Something isn't working label Jul 16, 2021
@jessesuen
Copy link
Member

This issue seems to indicate the client is the problem:
vmware-archive/kubeless#1037

@pjamenaja
Copy link

See my comment here - #5958 (comment).

@rwong2888
Copy link
Contributor Author

Hi @alexmt following up on this from the argocd meeting. Did you have an example to declaratively gke auth in a secret?

@alexmt
Copy link
Collaborator

alexmt commented May 3, 2022

Sorry @rwong2888 , Unfortunately I had no time last month and could not help. The native GKE support was merged #9190 and will be available in v2.4

The simplest possible was to get it in v2.3 is to build golang using this snippet below, make sure binary is available in application controller pod and use instructions from the PR to configure cluster secret.

package commands

import (
	"context"
	"fmt"
	"os"

	"github.com/spf13/cobra"
	"golang.org/x/oauth2/google"
)

var (
	// defaultGCPScopes:
	// - cloud-platform is the base scope to authenticate to GCP.
	// - userinfo.email is used to authenticate to GKE APIs with gserviceaccount
	//   email instead of numeric uniqueID.
	// https://github.com/kubernetes/client-go/blob/be758edd136e61a1bffadf1c0235fceb8aee8e9e/plugin/pkg/client/auth/gcp/gcp.go#L59
	defaultGCPScopes = []string{
		"https://www.googleapis.com/auth/cloud-platform",
		"https://www.googleapis.com/auth/userinfo.email",
	}
)

func newGCPCommand() *cobra.Command {
	var command = &cobra.Command{
		Use: "gcp",
		Run: func(c *cobra.Command, args []string) {
			// Preferred way to retrieve GCP credentials
			// https://github.com/golang/oauth2/blob/9780585627b5122c8cc9c6a378ac9861507e7551/google/doc.go#L54-L68
			cred, err := google.FindDefaultCredentials(context.Background(), defaultGCPScopes...)
			if err != nil {
				panic(err)
			}
			token, err := cred.TokenSource.Token()
			if err != nil {
				panic(err)
			}
			_, _ = fmt.Fprint(os.Stdout, formatJSON(token.AccessToken, token.Expiry))
		},
	}
	return command
}

@rwong2888
Copy link
Contributor Author

Thank you @alexmt, I hope you are feeling better now and have more free time.

Your follow-up is much appreciated.

I look forward to 2.4 and will test it out post-release.

I will keep this issue open until then.

@rekiemfaxaf
Copy link

Hey guys, I'm having the same problem with argocd v2.4.0-rc2
So there is some workaround to avoid the error?
Any help will be very welcome! Thanks!

@rwong2888
Copy link
Contributor Author

@rekiemfaxaf following the doc works. I am on v2.4.0-rc4
https://argo-cd.readthedocs.io/en/latest/operator-manual/declarative-setup/#clusters

Thank you @alexmt , closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants