未加星标

AzureAD Pod Identity in AKS: A journey to integrate Azure Key Vault

字体大小 | |
[系统(windows) 所属分类 系统(windows) | 发布者 店小二04 | 时间 2018 | 作者 红领巾 ] 0人收藏点击收藏
AzureAD Pod Identity in AKS: A journey to integrate Azure Key Vault andAKS

Thorsten Hans


AzureAD Pod Identity in AKS: A journey to integrate Azure Key Vault
Photo by MILKOV on Unsplash

Back in May, I wrote an article on how to integrate Azure Key Vault with ACS. Since that, a lot happened in the Azure and Kubernetes space and I thought an updated version would be worth sharing because dealing correctly with sensitive data is essential .

This is the first of two separate articles, that will guide you through the complete setup and configuration process to integrate Azure Kubernetes Services and Azure Key Vault securely without leaking essential data about your Service Principal.

If you don’t know Azure Key Vault yet, check out the post I’ve linked below. There is also a quick Key Vault introduction and some scripts that ensure you’re up andrunning.

Integrating Azure KeyVault with Azure Container Services

Learn how to integrate Azure KeyVault with Azure Container Services or competitive Kubernetes environments. thorsten-hans.com

At this point, you should have basic knowledge about Azure Key Vault and it’s time to look into some new stuff, created by the Azure Team and the community.

Azure AD PodIdentity

With AAD Pod Identity, the team made a huge step towards seamless k8s and Azure integration. AAD Pod Identity allows you to execute Pods in the security context of an Azure Identity . That identity will be dynamically assigned to any pod that is matching certain requirements.

Azure/aad-pod-identity

Assign Azure Active Directory Identities to kubernetes applications. - Azure/aad-pod-identity github.com

Integrations with Azure services ― such as Azure Key Vault ― will become way easier and way more flexible with Azure AD Pod Identity .

Cluster Administrators can easily switch underlying Azure Identities to swap Pods from one Identity to another. This can happen at runtime without having a developer doing any changes to application code.

Enabling AAD Pod Identity onAKS

Okay, time to get some work done. Let’s enable Azure AD Pod Identity on an AKS cluster.

First, you’ve to install the AAD Pod Identity infrastructure on your cluster. There are two different deployments available, the default one:

kubectl create -f <a href="https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/deployment.yaml" data-href="https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/deployment.yaml" rel="noopener" target="_blank">https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/deployment.yaml</a>

And a slightly different deployment, that should you use if your cluster has RBAC (Role Based Access Control) enabled

kubectl create -f <a href="https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/deployment-rbac.yaml" data-href="https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/deployment-rbac.yaml" rel="noopener" target="_blank">https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/deployment-rbac.yaml</a>

Once deployment is finished, you’ll end up in having two new resources deployed on your cluster

Managed Identity Controller (MIC) Node Managed Identity (NMI)

MIC is responsible for binding Azure Identities to pods. The NMI will act like an interceptor which observes incoming requests for your pods and will call back into Azure (by using ADAL) to acquire an access token from Azure AD to communicate with Azure APIs ― such as Azure Key Vault ― in behalf of that Azure Identity .

Creating a new AzureIdentity

Now it’s time to create the Azure Identity using Azure CLI

az identity create -g demo-resource-group -n demo_pod_identity -o json

This command will produce a response similar to this

{ "clientId": "00000000-0000-0000-0000-000000000000", "clientSecretUrl": "...", "id": "/subscriptions/00000000-0000-0000...", "name": "demo_pod_identity", "principalId": "00000000-0000-0000-0000-000000000000", "resourceGroup": "demo-resource-group", "tenantId": "00000000-0000-0000-0000-000000000000", "type": "Microsoft.ManagedIdentity/userAssignedIdentities" }

Grab the principalId and assign the Reader role for the targeting Resource Group (the resource group where you’ve placed your Azure Key Vault instance) to that identity

az role assignment create --role Reader --assignee <your_principal_id_goes_here> --scope /subscriptions/<subscriptionid>/resourcegroups/demo-resource-group

Next, the underlying Service Principal of your AKS instance needs permissions to act as Managed Identity Operator . That’s required because MIC will try to acquire the access token for that Azure Identity. This “authentication” call will be issued in the security context of the AKS cluster, so you’ve to create another role assignment to get that working. In this case, the scope is the unique identifier from the Azure Identity you’ve created a minute ago.

az role assignment create
--role "Managed Identity Operator"
--assignee <aks_service_principal_id_here>
--scope <azure_identitys_id> Deploying an Azure Identity toAKS

Everything is in place now, so it’s time to deploy some k8s resources and bring the AAD Pod Identity to AKS .

apiVersion: "aadpodidentity.k8s.io/v1" kind: AzureIdentity metadata: name: demo_aks_pod_id spec: type: 0 ResourceID: /subscriptions/<subid>/reso.../demo_pod_identity ClientID: 00000000-0000-0000-0000-000000000000

There are a couple of interesting things in this small yaml file, that I want to explain quickly

Obviously, name is used later on to identify the instance of AzureIdentity spec.type is set to 0 which represents a Managed Service Identity (MSI). spec.type could also be set to 1 , which tells the AAD Pod Identity infrastructure that you want to use a Service Principal instead of an Azure Identity ResourceId is the id value, taken from your Azure Identity ClientId is the clientId value, taken from your Azure Identity

本文系统(windows)相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术

代码区博客精选文章
分页:12
转载请注明
本文标题:AzureAD Pod Identity in AKS: A journey to integrate Azure Key Vault
本站链接:https://www.codesec.net/view/621315.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(windows) | 评论(0) | 阅读(84)