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

no Auth Provider found for name "azure" When using Azure ODIC to login to kubernetes cluster and running a test #976

Open
whume opened this issue Aug 19, 2021 · 1 comment

Comments

@whume
Copy link

whume commented Aug 19, 2021

I was testing terratest today and noticed it was unable to authenticate into my K8s clusters using my OIDC for AzureAD that works when I use kubectl / terraform / helm etc. I was unsure if this was a issue with the code or how to troubleshoot it and my googling is failing. The test runs fine on my EKS cluster that uses IAM auth so I was thinking it was something with OIDC via AzureAD.

The test itself is pretty simple just verify a service is there.

package test

import (

	"testing"

	"github.com/stretchr/testify/require"

	"github.com/gruntwork-io/terratest/modules/k8s"
	
)

func TestVaultSvc(t *testing.T) {
	t.Parallel()
	namespaceName := "vault"

	options := k8s.NewKubectlOptions("", "", namespaceName)

	service := k8s.GetService(t, options, "vault-agent-injector-svc")
	require.Equal(t, service.Name, "vault-agent-injector-svc")
}

The config file looks like this with all my stuff redacted

---
kind: Config
apiVersion: v1
preferences: {}
current-context: ''
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://<ip address>:6443
  name: cluster-1
contexts:
- context:
    cluster: cluster-1
    user: user@foo.com
  name: cluster-1
current-context: cluster-1
users:
- name: user@foo.com
  user:
    auth-provider:
      config:
        apiserver-id: "<api server id>"
        client-id: "<client id>"
        environment: "<environment>"
        tenant-id: "<tenant id>"
      name: azure

When running I get the following error

TestVaultSvc 2021-08-18T21:04:46-04:00 client.go:42: Configuring Kubernetes client using config file /Users/user/.kube/config with context cluster-1
--- FAIL: TestVaultSvc (0.00s)
    service.go:46:
        	Error Trace:	service.go:46
        	            				vault_injector_k8s_service_test.go:49
        	Error:      	Received unexpected error:
        	            	no Auth Provider found for name "azure"
        	Test:       	TestVaultSvc
FAIL
FAIL	command-line-arguments	0.283s
FAIL

Any help would be appreciated. Without this it would be hard to have all our engineers writing tests locally.

Thanks!

@tkent
Copy link

tkent commented May 26, 2022

👋 I know this is an old question, but I just recently bumped into this myself and thought I'd drop the answer off. The solution is to make sure that all the auth providers are loaded. That should be as simple as including an import like this in your test:

import _ "k8s.io/client-go/plugin/pkg/client/auth"

scott-cotton added a commit to signadot/cli that referenced this issue Oct 11, 2023
from gruntwork-io/terratest#976 (comment)

the imported package has no documentation, though.
scott-cotton added a commit to signadot/cli that referenced this issue Oct 11, 2023
* add import for auth providers

from gruntwork-io/terratest#976 (comment)

the imported package has no documentation, though.

* Move client-go auth load to the same package where we import client-go/kubernetes

* downgrade client-go version

* use libconnect for cli-v0.5.3 (downgraded client-go)

---------

Co-authored-by: Daniel De Vera <daniel@signadot.com>
Co-authored-by: Anirudh Ramanathan <anirudh@signadot.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants