terraform-provider-flux: kubernetes client initialization failed: no Auth Provider found for name "oidc"
Describe the bug
We use kubernetes on tkgi and authenticate against the cluster with sso to create our KUBECONFIG with
tkgi login -a <tkgihostfqdn> -k -ssoexport KUBECONFIG=~/.kube/<clustername>.yamltkgi get-kubeconfig <clustername> -a <tkgihostfqdn> -k -sso
The resultant KUBECONFIG looks like:
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: xx....
server: https://<myclusterfqdn>:8443
name: <clustername>
contexts:
- context:
cluster: <clustername>
user: <myoidcusername>
name: <clustername>
current-context: <clustername>
kind: Config
references: {}
users:
- name: <myoidcusername>
user:
auth-provider:
config:
client-id: pks_cluster_client
client-secret: ""
id-token: xx....
idp-certificate-authority-data: xx....
idp-issuer-url: https://<tkgihostfqdn>:8443/oauth/token
refresh-token: xx....
name: oidc
Running terraform apply gives the error:
│ Error: Kubernetes Client
│
│ with flux_bootstrap_git.this,
│ on bootstrap.tf line 1, in resource "flux_bootstrap_git" "this":
│ 1: resource "flux_bootstrap_git" "this" {
│
│ kubernetes client initialization failed: no Auth Provider found for name "oidc"
Steps to reproduce
Our terraform code is as follows:
terraform {
required_providers {
flux = {
source = "fluxcd/flux"
version = "1.2.3"
}
}
}
provider "flux" {
kubernetes = { }
git = {
url = var.git_url
branch = var.git_branch
# configure credentials
}
}
resource "flux_bootstrap_git" "this" {
path = var.cluster_path
registry = var.registry
version = "v2.2.3"
}
Expected behavior
With one of our TKGI clusters, this works as expected however the KUBECONFIG is token based only, not OIDC
Screenshots and recordings
No response
Terraform and provider versions
Terraform v1.7.3 fluxcd/flux Provider v1.2.3
Terraform provider configurations
terraform {
required_providers {
flux = {
source = "fluxcd/flux"
version = "1.2.3"
}
}
}
provider "flux" {
kubernetes = { }
git = {
url = var.git_url
branch = var.git_branch
# configure credentials
}
}
flux_bootstrap_git resource
resource "flux_bootstrap_git" "this" {
path = var.cluster_path
registry = var.registry
version = "v2.2.3"
}
Flux version
v2.2.3
Additional context
No response
Code of Conduct
- I agree to follow this project’s Code of Conduct
Would you like to implement a fix?
None
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (9 by maintainers)
@kcighon @Wildeone1 sorry I totally dropped the ball on this one, let me discuss this at the weekly flux project meeting this afternoon and get back to you as I think it may impact how the flux binary itself interacts with the cluster but I’ll report back.
@kcighon this will be released with the next flux release which should be in a few weeks. You can track the release via https://github.com/fluxcd/flux2/issues/4947
@swade1987 test creating a secret succeeded showing the kubernetes provider with KUBE_CONFIG_PATH set works if the KUBECONFIG file contains auth-provider name oidc.
flux_bootstrap_git with the same setup (ie using KUBE_CONFIG_PATH) fails with the error in the OP.