Skip to content

Load client-go auth-provider plugins so oidc kubeconfigs connect - #9

Merged
pierreneter merged 1 commit into
p10node:mainfrom
junior:oidc-auth-provider
Oct 16, 2026
Merged

pierreneter merged 1 commit into
p10node:mainfrom
junior:oidc-auth-provider

Conversation

@junior

@junior junior commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

A kubeconfig whose user logs in through auth-provider: oidc shows its context in the header, and then the connection fails with:

clientset: no Auth Provider found for name "oidc"

client-go only knows the auth-provider plugins a program imports, and k10s imports none. This adds the import kubectl and k9s use, k8s.io/client-go/plugin/pkg/client/auth: the oidc plugin, plus stubs for the removed gcp and azure providers, so a kubeconfig that still names one of those gets client-go's pointer to the replacement credential plugin instead of the same "not found".

Tests in internal/k8s/auth_test.go, against an https test API server:

  • TestOIDCAuthProviderKubeconfigConnects: a valid id-token connects, and the API server receives it as the bearer token.
  • TestOIDCAuthProviderRefreshesExpiredToken: an expired id-token is refreshed against a fake identity provider (discovery, then one refresh-token grant), the API server only ever sees the new token, and the new tokens are written back to the file that holds the user, here the second file of a two-file KUBECONFIG. It runs with and without --readonly: the refresh is a POST, but it goes to the identity provider through the plugin's own client, which the read-only guard does not wrap.
  • TestRemovedAuthProviderIsStillRecognised: a gcp auth-provider gets client-go's removal notice.

All three fail on main with the "no Auth Provider found" error. Checked with gofmt, go vet ./... and go test ./... on Go 1.26.9, and a build for each release platform. I also ran a build of this branch against a real cluster whose kubeconfig logs in this way, and it connects.

A kubeconfig user that logs in through `auth-provider: oidc`, which
kubectl still reads, failed before any request with

  clientset: no Auth Provider found for name "oidc"

client-go only knows the auth-provider plugins a program imports, and
k10s imported none: the context showed in the header, then the
connection failed and the No cluster panel showed that line.

Import k8s.io/client-go/plugin/pkg/client/auth, as kubectl and k9s
do: the oidc plugin, plus stubs for the removed gcp and azure
providers that say what replaced them. The oidc plugin refreshes an
expired id-token against the identity provider with its own HTTP
client and writes the new one back to the kubeconfig file that holds
the user, so read-only mode, which guards only requests to the API
server, does not stand in its way.

Signed-off-by: Adao Oliveira Jr <[email protected]>
@junior
junior force-pushed the oidc-auth-provider branch from a49f736 to 62e3ddd Compare October 9, 2026 16:44
@pierreneter
pierreneter self-requested a review October 16, 2026 06:28
@pierreneter

Copy link
Copy Markdown
Member

First of all, sorry for the slow review. I was sick for the past week and today is the first day I've been back at a computer, so this is the first chance I've had to look at it properly.

Reviewed and verified locally on top of main (227fed8):

  • gofmt, go vet ./..., go build ./... and go mod tidy are all clean, no go.mod/go.sum changes needed.
  • go test ./... passes on this branch.
  • Copied auth_test.go onto main without the import: all three new tests fail with no Auth Provider found for name "oidc" / "gcp", exactly as described. So the tests really pin the behavior.
  • The read-only reasoning holds up: readOnlyTransport only wraps the API server config, and --readonly is documented as "nothing that changes the cluster". The oidc refresh goes to the identity provider through the plugin's own client, and the token write-back is a local file. Matches what kubectl does.

The test setup is really thorough: a TLS fake API server, a fake IdP with discovery + token endpoint, multi-file $KUBECONFIG with the write-back landing in the right file, and the removed-provider stub. Nice work.

Approving.

One more thing: this is your third PR here (#6, #7 and now this one), and every one of them has been well-reasoned, well-tested and carefully written. Would you be interested in becoming a maintainer of k10s? That would mean triage, reviewing and merging PRs, and a say in where the project goes. No pressure at all, but if you're up for it, just say so and I'll send the invite.

@pierreneter
pierreneter merged commit 5952d17 into p10node:main Oct 16, 2026
1 check passed
@junior
junior deleted the oidc-auth-provider branch November 6, 2026 20:30
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

Successfully merging this pull request may close these issues.

2 participants