Skip to content

Support Azure CLI Access on AKS with workload identity#40142

Merged
greedy52 merged 6 commits intomasterfrom
STeve/39532/aks_workload_id
Apr 17, 2024
Merged

Support Azure CLI Access on AKS with workload identity#40142
greedy52 merged 6 commits intomasterfrom
STeve/39532/aks_workload_id

Conversation

@greedy52
Copy link
Copy Markdown
Contributor

@greedy52 greedy52 commented Apr 2, 2024

Implements #39532:

changelog: added Azure CLI access support on AKS with Entra Workload ID

Why:
Azure CLI app access is implemented with azidentity.NewManagedIdentityCredential. This works fine for regular VMs, and Azure AKS with Entra pod identity. However, the Entra pod identity is a Preview feature that will be deprecated soon. The Official way to do pod-level identity on AKS is Azure Workload Identity. We also advertise Azure Workload Identity in our own Azure AKS guide.

How it works:

  • Workload Identity requires azidentity.NewWorkloadIdentityCredential, plus the client ID of the Azure user-assigned identity in order to be assumed. Multiple workload identities can be assigned to the single service account assigned to the AKS pod.
  • On the Pod though, there is only one "default" client ID available to the App service. we assume the "default" client ID/assigned identity is the app-agent identity with Microsoft.ManagedIdentity/userAssignedIdentities/read permission.
  • When user sends in requests from tsh, the app agent makes API calls to fetch client IDs for the user-requested identities, then use the fetched client ID for azidentity.NewWorkloadIdentityCredential.

Setup:
(TODO make a proper doc change)

  1. AKS
    1. Follow Official Workload ID guide to setup AKS, user identity, service account, OIDC mapping, etc.
    2. IMPORTANT! When following this guide, we create a new app-agent identity say teleport-azure-app-aks-agent for "USER_ASSIGNED_IDENTITY_NAME". Create a role for this identity with Microsoft.ManagedIdentity/userAssignedIdentities/read action permission, and assign it to the role. Note that the client ID for this app-agent will be used for service account's azure.workload.identity/client-id
  2. Deploy Teleport App Service with an azure app (cloud: "Azure") and use the service account created in the previous step for this pod in this AKS cluster.
  3. For each end-user access user assigned identities
    1. Create a user assigned identity for end-user access, say teleport-user-reader, and grant it relevant permissions.
    2. Repeat the "Establish federated identity credential" from the above guide, but use the end-user identity and assign it to the same service account (e.g: az identity federated-credential create --name federated-teleport-user-reader --identity-name teleport-user-reader --resource-group "${RESOURCE_GROUP}" --issuer "${AKS_OIDC_ISSUER}" --subject system:serviceaccount:"${SERVICE_ACCOUNT_NAMESPACE}":"${SERVICE_ACCOUNT_NAME}" --audience api://AzureADTokenExchange)
    3. Grant this identity to the Teleport role or user traits.
  4. Use tsh apps login <azure-on-aks> and tsh az as usual

Testing

  • AKS
  • Azure VM (for existing "direct" managed identity credential)

@greedy52 greedy52 self-assigned this Apr 2, 2024
@greedy52 greedy52 requested review from Tener and smallinsky April 4, 2024 19:16
@greedy52 greedy52 marked this pull request as ready for review April 4, 2024 19:16
Comment thread lib/srv/app/azure/credential.go Outdated
@greedy52 greedy52 force-pushed the STeve/39532/aks_workload_id branch from 016bac9 to f2b5dc2 Compare April 16, 2024 19:42
@greedy52 greedy52 added this pull request to the merge queue Apr 17, 2024
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 17, 2024
@greedy52 greedy52 added this pull request to the merge queue Apr 17, 2024
Merged via the queue into master with commit 8978ab3 Apr 17, 2024
@greedy52 greedy52 deleted the STeve/39532/aks_workload_id branch April 17, 2024 15:19
@public-teleport-github-review-bot
Copy link
Copy Markdown

@greedy52 See the table below for backport results.

Branch Result
branch/v15 Failed

greedy52 added a commit that referenced this pull request Apr 18, 2024
* Support Azure CLI Access on AKS with workload identity

* fix lint and properly pass along a logger

* fix typos

* reverse error check and fix typo

* fix terraform go.mod

* fix event handler go.mod
github-merge-queue Bot pushed a commit that referenced this pull request Apr 23, 2024
* Support Azure CLI Access on AKS with workload identity

* fix lint and properly pass along a logger

* fix typos

* reverse error check and fix typo

* fix terraform go.mod

* fix event handler go.mod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants