Authenticate kubernetes
provider to AKS using Terraform Cloud Dynamic Credentials for Azure
#2603
Labels
kubernetes
provider to AKS using Terraform Cloud Dynamic Credentials for Azure
#2603
Description
One-liner:
kubernetes
Terraform provider to work with Entra-enabled AKS without managing any secrets (just OIDC federations).Scenario:
azurerm
andkubernetes
providers, for onboarding new apps/apis into AKS cluster. (azurerm_user_assigned_identity
,kubernetes_namespace_v1
,kubernetes_service_account_v1
, etc.)azurerm
provider perfectlyOwner
role of the resource group where theazurerm
resources goAzure Kubernetes Service RBAC Cluster Admin
role, sufficient to make any changes through the Kubernetes API of the AKS clusterManual version illustrating a similar idea:
Goal:
kubernetes
Terraform provider is able to take on the same identity being pulled in by theazurerm
provider, using that identity to call the AKS cluster's Kubernetes API when provisioningkubernetes_*
resourcesazurerm
provider federating via OIDC)Potential Terraform Configuration
I can imagine two ways to do this:
Option 1:
kubernetes
provider can be told to use the same Azure Dyamic Credentials as theazurerm
providerOption 2:
kubernetes
provider exchanges the TFC-provided OIDC token on its own:Notes:
kubelogin
to be available within the context of the Terraform run. We need a self-hosted TFC agent anyways, due to use of a private cluster, so the TFC-provided agents wouldn't have line-of-sight to the Kubernetes API, and have installedkubelogin
ourselves./home/tfc-agent/.tfc-agent/component/terraform/runs/{run-id-here}/tfc-azure-token
, with issuer ofhttps://app.terraform.io
and audience ofapi://AzureADTokenExchange
, but using that JWT withkubelogin
isn't workingkubelogin get-token
command as specified in mykubeconfig
afterkubelogin convert-kubeconfig -l azurecli
, I get a JWT with an issuer ofhttps://sts.windows.net/{my-tenant-id-here}/
and audience of6dae42f8-4368-4678-94ff-3960e28e3630
, which is that static Entra ID for the AKS OIDC application that is the same for every customer. I believe this JWT is what is being submitted with calls to the Kubernetes API.References
Community Note
The text was updated successfully, but these errors were encountered: