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

Azure: Remove a need to provide secret while deploying CAA #974

Closed
surajssd opened this issue May 17, 2023 · 7 comments
Closed

Azure: Remove a need to provide secret while deploying CAA #974

surajssd opened this issue May 17, 2023 · 7 comments
Labels
provider/azure Issues related to Azure CAA provider

Comments

@surajssd
Copy link
Member

In this new approach of not needing to have secrets, we will still create an identity like we do here but instead of passing the secret AZURE_CAA_CLIENT_SECRET to the daemonset, we will assign an identity to the worker nodes or to the CAA daemonset (workload) itself.

Current Approach

In current approach we create a service principal and use the client_id, client_secret produced out of it and give it to the CAA daemonset.

Advantages

  • Simpler works on any type of kubernetes be it a bring-your-own kubernetes or on AKS (of course it has to be on Azure).

Disdvantages

  • Have to manage a secret.
  • Does not work in CI set up we are trying to build.

Assign identity to the VM

Here we will create an identity and assign it to the worker nodes. So any request originating from the worker node will have permissions to create peer pod VM.

Advantages

  • No need to manage a client_secret.
  • It will work with CI.
  • Regardless of the k8s cluster type this will work. It will work for AKS and any DIY k8s setup on Azure.

Disadvantages

  • Obviously this allows "any" workload to create peer pod vm in the same RG.

Assign identity to the workload

Here you can see how one can assign identity to the k8s workloads to be able to communicate with the Azure APIs.

Advantages

  • No need to manage a client_secret.
  • It will work with CI.
  • Only the CAA pods will have that permission to create peer pod VMs.

Disadvantages

  • Won't work outside AKS, unless we figure out a way to provision an OIDC issuer on any k8s cluster running on Azure.
@surajssd surajssd added the provider/azure Issues related to Azure CAA provider label May 17, 2023
@surajssd
Copy link
Member Author

surajssd commented May 17, 2023

We can support multiple approaches but we have to choose one (or more) to ensure things work on CI and for users.

@bpradipt
Copy link
Member

This is a great idea. We can support both the options - viz assigning identity to CAA (and peerpod-ctrl - since this does cleanups for VMs if required) and passing client_secret.

@surajssd
Copy link
Member Author

So there is a way to assign identity to self-managed clusters on Azure: https://azure.github.io/azure-workload-identity/docs/topics/self-managed-clusters.html

I haven't tried it so not sure how this will be translated into our CAA deployments.

@tumberino
Copy link
Contributor

Could you use https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#service-account-token-volume-projection with your azure clusters? This would be a more cross-provider friendly mechanism?

@surajssd
Copy link
Member Author

Could you use https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#service-account-token-volume-projection with your azure clusters? This would be a more cross-provider friendly mechanism?

@jtumber-ibm I don't I understand what you mean here. Service account tokens allow you to talk to the k8s api server, so using the k8s RBAC one can define what's allowed.

But here I am talking about how do we allow an application to talk to the Azure API without needing any secret? AKS has a mechanism called workload identity, which is similar to k8s service account token. On the Azure side you define what a particular "workload" on AKS can do with azure APIs and bam, you don't need secret.

My concern was how do we get this working for other DIY k8s clusters on Azure?!

@tumberino
Copy link
Contributor

Could you use https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#service-account-token-volume-projection with your azure clusters? This would be a more cross-provider friendly mechanism?

@jtumber-ibm I don't I understand what you mean here. Service account tokens allow you to talk to the k8s api server, so using the k8s RBAC one can define what's allowed.

But here I am talking about how do we allow an application to talk to the Azure API without needing any secret? AKS has a mechanism called workload identity, which is similar to k8s service account token. On the Azure side you define what a particular "workload" on AKS can do with azure APIs and bam, you don't need secret.

My concern was how do we get this working for other DIY k8s clusters on Azure?!

Sorry if I wasn't clear. Does Azure not provide a Service Account token to IAM role token endpoint?

@surajssd
Copy link
Member Author

Sorry if I wasn't clear. Does Azure not provide a Service Account token to IAM role token endpoint?

Yes it does but I know this works with the AKS, but not sure how it will work with DIY clusters on Azure. There seems to be a way to do that with DIY clusters, but I haven't tried it myself.

surajssd added a commit to surajssd/cloud-api-adaptor that referenced this issue Jul 18, 2023
If a certain property is not defined then don't expose it as empty
inside the CAA pod.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
kartikjoshi21 pushed a commit that referenced this issue Jul 19, 2023
- Allow provisioner-user to provide the "managed identity name" to be
  used when creating the federated identity credential. Now one can
  expose a variable `MANAGED_IDENTITY_NAME` in the properties file to
  expose this value to the provisioner.

- Create federated identity credential, which ties the existing managed
  identity to namespace and service account of the CAA pod. This way we
  don't have to pass the service principal credentials to the CAA pod in
  CI.

- To be able to use this federated identity credential the cluster has
  to be created with OIDC issuer profile enabled and workload identity
  enabled.

Fixes #974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
kartikjoshi21 pushed a commit that referenced this issue Jul 19, 2023
- Make it optional to provide client secret.
- Use a new API to do authentication.

Fixes #974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
kartikjoshi21 pushed a commit that referenced this issue Jul 19, 2023
- This commit adds a method that allows updating the list of the
`patchesStrategicMerge` list with additional patch files.

- Add a patch file that will add the workload identity to the
  cloud-api-adaptor-daemonset and the service account cloud-api-adaptor.

- Add code to provisioner that will update the patch file with the
  client id of the managed identity.

Fixes #974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
kartikjoshi21 pushed a commit that referenced this issue Jul 19, 2023
Fixes #974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
kartikjoshi21 pushed a commit that referenced this issue Jul 19, 2023
Regardless of what authentication provisioner uses (be it service
principal based or az cli based), the CAA still needs client id, so make
it mandatory to provide client id.

Fixes #974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
kartikjoshi21 pushed a commit that referenced this issue Jul 19, 2023
If a certain property is not defined then don't expose it as empty
inside the CAA pod.

Fixes #974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
bpradipt pushed a commit to bpradipt/cloud-api-adaptor that referenced this issue Aug 12, 2023
Upgrade from v2 to v4, this is required to use the workload identity
feature.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
bpradipt pushed a commit to bpradipt/cloud-api-adaptor that referenced this issue Aug 12, 2023
- Allow provisioner-user to provide the "managed identity name" to be
  used when creating the federated identity credential. Now one can
  expose a variable `MANAGED_IDENTITY_NAME` in the properties file to
  expose this value to the provisioner.

- Create federated identity credential, which ties the existing managed
  identity to namespace and service account of the CAA pod. This way we
  don't have to pass the service principal credentials to the CAA pod in
  CI.

- To be able to use this federated identity credential the cluster has
  to be created with OIDC issuer profile enabled and workload identity
  enabled.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
bpradipt pushed a commit to bpradipt/cloud-api-adaptor that referenced this issue Aug 12, 2023
- Make it optional to provide client secret.
- Use a new API to do authentication.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
bpradipt pushed a commit to bpradipt/cloud-api-adaptor that referenced this issue Aug 12, 2023
- This commit adds a method that allows updating the list of the
`patchesStrategicMerge` list with additional patch files.

- Add a patch file that will add the workload identity to the
  cloud-api-adaptor-daemonset and the service account cloud-api-adaptor.

- Add code to provisioner that will update the patch file with the
  client id of the managed identity.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
bpradipt pushed a commit to bpradipt/cloud-api-adaptor that referenced this issue Aug 12, 2023
Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
bpradipt pushed a commit to bpradipt/cloud-api-adaptor that referenced this issue Aug 12, 2023
Regardless of what authentication provisioner uses (be it service
principal based or az cli based), the CAA still needs client id, so make
it mandatory to provide client id.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
bpradipt pushed a commit to bpradipt/cloud-api-adaptor that referenced this issue Aug 12, 2023
If a certain property is not defined then don't expose it as empty
inside the CAA pod.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
wainersm pushed a commit to wainersm/cc-cloud-api-adaptor that referenced this issue Sep 5, 2023
Upgrade from v2 to v4, this is required to use the workload identity
feature.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
wainersm pushed a commit to wainersm/cc-cloud-api-adaptor that referenced this issue Sep 5, 2023
- Allow provisioner-user to provide the "managed identity name" to be
  used when creating the federated identity credential. Now one can
  expose a variable `MANAGED_IDENTITY_NAME` in the properties file to
  expose this value to the provisioner.

- Create federated identity credential, which ties the existing managed
  identity to namespace and service account of the CAA pod. This way we
  don't have to pass the service principal credentials to the CAA pod in
  CI.

- To be able to use this federated identity credential the cluster has
  to be created with OIDC issuer profile enabled and workload identity
  enabled.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
wainersm pushed a commit to wainersm/cc-cloud-api-adaptor that referenced this issue Sep 5, 2023
- Make it optional to provide client secret.
- Use a new API to do authentication.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
wainersm pushed a commit to wainersm/cc-cloud-api-adaptor that referenced this issue Sep 5, 2023
- This commit adds a method that allows updating the list of the
`patchesStrategicMerge` list with additional patch files.

- Add a patch file that will add the workload identity to the
  cloud-api-adaptor-daemonset and the service account cloud-api-adaptor.

- Add code to provisioner that will update the patch file with the
  client id of the managed identity.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
wainersm pushed a commit to wainersm/cc-cloud-api-adaptor that referenced this issue Sep 5, 2023
Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
wainersm pushed a commit to wainersm/cc-cloud-api-adaptor that referenced this issue Sep 5, 2023
Regardless of what authentication provisioner uses (be it service
principal based or az cli based), the CAA still needs client id, so make
it mandatory to provide client id.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
wainersm pushed a commit to wainersm/cc-cloud-api-adaptor that referenced this issue Sep 5, 2023
If a certain property is not defined then don't expose it as empty
inside the CAA pod.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
lysliu pushed a commit to lysliu/cloud-api-adaptor that referenced this issue Nov 9, 2023
Upgrade from v2 to v4, this is required to use the workload identity
feature.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
lysliu pushed a commit to lysliu/cloud-api-adaptor that referenced this issue Nov 9, 2023
- Allow provisioner-user to provide the "managed identity name" to be
  used when creating the federated identity credential. Now one can
  expose a variable `MANAGED_IDENTITY_NAME` in the properties file to
  expose this value to the provisioner.

- Create federated identity credential, which ties the existing managed
  identity to namespace and service account of the CAA pod. This way we
  don't have to pass the service principal credentials to the CAA pod in
  CI.

- To be able to use this federated identity credential the cluster has
  to be created with OIDC issuer profile enabled and workload identity
  enabled.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
lysliu pushed a commit to lysliu/cloud-api-adaptor that referenced this issue Nov 9, 2023
- Make it optional to provide client secret.
- Use a new API to do authentication.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
lysliu pushed a commit to lysliu/cloud-api-adaptor that referenced this issue Nov 9, 2023
- This commit adds a method that allows updating the list of the
`patchesStrategicMerge` list with additional patch files.

- Add a patch file that will add the workload identity to the
  cloud-api-adaptor-daemonset and the service account cloud-api-adaptor.

- Add code to provisioner that will update the patch file with the
  client id of the managed identity.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
lysliu pushed a commit to lysliu/cloud-api-adaptor that referenced this issue Nov 9, 2023
Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
lysliu pushed a commit to lysliu/cloud-api-adaptor that referenced this issue Nov 9, 2023
Regardless of what authentication provisioner uses (be it service
principal based or az cli based), the CAA still needs client id, so make
it mandatory to provide client id.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
lysliu pushed a commit to lysliu/cloud-api-adaptor that referenced this issue Nov 9, 2023
If a certain property is not defined then don't expose it as empty
inside the CAA pod.

Fixes confidential-containers#974

Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/azure Issues related to Azure CAA provider
Projects
None yet
Development

No branches or pull requests

3 participants