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

Allow Azure Workload identity authentication #210

Merged
merged 9 commits into from
May 23, 2024

Conversation

patst
Copy link
Contributor

@patst patst commented Feb 28, 2024

Description of your changes

We want to use Azure Workload Identity to provision resources with the Kubernetes provider.,
At the moment only Azure Service Principal authentication is possible (see

IdentityTypeAzureServicePrincipalCredentials = "AzureServicePrincipalCredentials"
)

Details about Azure workload Identity: https://azure.github.io/kubelogin/concepts/login-modes/workloadidentity.html#workload-identity

this is an addition to #170 done by @haarchri

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.
    ( there is one finding: internal/clients/azure/azure.go:30:1: cyclomatic complexity 11 of func WrapRESTConfigis high (> 10), any suggestion how to fix it? For me it only reduces readability to split up the function)

How has this code been tested

Deployed it in a AKS Cluster and checked if I can access the cluster and provision resources.

Example configuration:

apiVersion: kubernetes.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
  name: kubernetes-provider
spec:
  credentials:
    source: Secret
    secretRef:
      namespace: crossplane-system
      name: cluster-config
      key: kubeconfig
  identity:
    type: AzureWorkloadIdentityCredentials
    source: Secret
    secretRef:
      name: azure-wli-credentials
      namespace: crossplane-system
      key: credentials.json
---
apiVersion: v1
kind: Secret
metadata:
  name: azure-wli-credentials
  namespace: crossplane-system
stringData:
  # serverId hardcoded to AKS ID, see https://azure.github.io/kubelogin/concepts/aks.html#azure-kubernetes-service-aad-server
  credentials.json: |
    {
      "tenantId": "<aad-tenant-id>",
      "serverId": "6dae42f8-4368-4678-94ff-3960e28e3630",
      "clientId": "<client-id>",
      "federatedTokenFile": "/var/run/secrets/azure/tokens/azure-identity-token",
      "authorityHost": "https://login.microsoftonline.com/"
     }

@cychiang
Copy link

This is great, and wondering when would be possible to merge it?

@turkenh
Copy link
Collaborator

turkenh commented May 22, 2024

@patst, thanks for the PR, and sorry for being late here.

Would you mind rebasing your PR, so that we can move it forward?

@patst
Copy link
Contributor Author

patst commented May 22, 2024

@patst, thanks for the PR, and sorry for being late here.

Would you mind rebasing your PR, so that we can move it forward?

@turkenh great you found the time. We are using the self-build version in production since a few months and are very happy.

I rebased the changes and hopefully was able to resolve the merge conflicts correct

Copy link
Collaborator

@turkenh turkenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks for your contribution @patst 🙌

@turkenh turkenh merged commit ba27bba into crossplane-contrib:main May 23, 2024
8 checks passed
@turkenh
Copy link
Collaborator

turkenh commented May 23, 2024

@patst, I just merged #225, which is also touching similar codepaths as your PR. Here is an image build from the latest main, including both PRs: xpkg.upbound.io/crossplane-contrib/provider-kubernetes:v0.14.0-rc0.38.gb6e342f

It would be great if you could test/validate this image on your environment to make sure nothing is broken before cutting a release 🙏

@patst patst deleted the feat/workload-identity branch May 23, 2024 07:09
@patst
Copy link
Contributor Author

patst commented May 23, 2024

@patst, I just merged #225, which is also touching similar codepaths as your PR. Here is an image build from the latest main, including both PRs: xpkg.upbound.io/crossplane-contrib/provider-kubernetes:v0.14.0-rc0.38.gb6e342f

It would be great if you could test/validate this image on your environment to make sure nothing is broken before cutting a release 🙏

thanks for merging it.
I just tested xpkg.upbound.io/crossplane-contrib/provider-kubernetes:v0.14.0-rc0.38.gb6e342f in our sandbox environment and it worked fine.

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.

4 participants