Skip to content

Commit bfb6137

Browse files
committed
Updated Readme docs. Updated commands to use latest specs.
1 parent 6fd8cb1 commit bfb6137

File tree

4 files changed

+38
-41
lines changed

4 files changed

+38
-41
lines changed

extensions/use-pod-identity-mid/README.md

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This project extension describes the steps for configuring the Claims Web API application to use user-assigned **Managed Identity** to access Azure SQL Database. **AAD Pod Identity** is used to retrieve managed identity service principal token and authenticate with Azure SQL Server.
44

5-
*Managed Identity* makes applications more secure by eliminating secrets such as credentials in connection strings.
5+
*Managed Identities for Azure Resources* makes applications more secure by eliminating secrets such as credentials in connection strings.
66

77
*AAD Pod Identity* enables Kubernetes applications to access cloud resources securely using managed identities and service principals. Without any code modifications, containerized applications can access any resource on Azure cloud that use AAD as an Identity provider.
88

@@ -18,7 +18,7 @@ In this sub-project, you will work on completing the following tasks.
1818
Refer to the architecture diagram [here](https://docs.microsoft.com/en-us/azure/aks/operator-best-practices-identity#use-pod-identities).
1919

2020
**Prerequisites:**
21-
1. Readers are required to complete Sections A thru G in the [parent project](https://github.com/ganrad/aks-aspnet-sqldb-rest) before proceeding with the hands-on labs in this project.
21+
1. Readers are required to complete Sections A thru G in the [parent project](https://github.com/ganrad/aks-aspnet-sqldb-rest) before proceeding with the hands-on labs in this sub-project.
2222

2323
Readers are advised to refer to the following on-line resources as needed.
2424
- [Azure Active Directory](https://docs.microsoft.com/en-us/azure/active-directory/)
@@ -27,9 +27,9 @@ Readers are advised to refer to the following on-line resources as needed.
2727
- [Use Managed Identities in AKS](https://docs.microsoft.com/en-us/azure/aks/use-managed-identity)
2828

2929
## A. Install AAD Pod Identity components on AKS Cluster
30-
**Approx. time to complete this section: 30 minutes**
30+
**Approx. time to complete this section: 25 minutes**
3131

32-
AAD Pod Identity consists of two key components and custom resources. The two core components are described below.
32+
AAD Pod Identity consists of two key components and custom resources. The two core components are briefly described below.
3333
- **Managed Identity Controller (MIC)**
3434

3535
The MIC is a custom Kubernetes resource that watches for changes to Pods, Identities and Bindings through the Kubernetes API Server. When it detects a change, the MIC adds or deletes assigned identities as required.
@@ -65,7 +65,7 @@ Follow the steps below to deploy AAD Pod Identity components and custom resource
6565
#
6666
```
6767

68-
3. Create an Azure Managed Identity in the **Node** Resource Group.
68+
3. Create an Azure Managed Identity in the AKS **Cluster/Node** Resource Group.
6969

7070
Save the values of `clientId` and `id` from the command output.
7171

@@ -74,7 +74,7 @@ Follow the steps below to deploy AAD Pod Identity components and custom resource
7474
# prefix..
7575
# Make sure you are logged in to your Azure account and have configured the correct subscription.
7676
# Substitute correct values for the following parameters:
77-
# - node-resource-group => Azure Kubernetes Service Node resource group
77+
# - node-resource-group => Azure Kubernetes Service Cluster/Node resource group
7878
# - name => Managed Identity name eg., claims-api-mid
7979
#
8080
$ az identity create -g <node-resource-group> -n <name> -o json
@@ -85,12 +85,12 @@ Follow the steps below to deploy AAD Pod Identity components and custom resource
8585

8686
4. Assign Roles to AKS cluster Service Principal.
8787

88-
Assign the AKS Service Principal, **Managed Identity Operator** and **Virtual Machine Contributor** roles for (scope of) the **Node** or **Cluster** Resource Group.
88+
Assign the AKS Service Principal, **Managed Identity Operator** and **Virtual Machine Contributor** roles for (scope of) the **Cluster** Resource Group.
8989

9090
```bash
9191
# Retrieve the AKS cluster service principal id.
9292
# Substitute correct values for the following parameters:
93-
# - resource-group => Azure Kubernetes Service resource group
93+
# - resource-group => Resource group in which Azure Kubernetes Service is deployed
9494
# - name => AKS cluster name
9595
#
9696
$ az aks show -g <resource-group> -n <name> --query servicePrincipalProfile.clientId -o tsv
@@ -108,7 +108,7 @@ Follow the steps below to deploy AAD Pod Identity components and custom resource
108108
```
109109

110110
## B. Configure Azure SQL Database
111-
**Approx. time to complete this section: 25 minutes**
111+
**Approx. time to complete this section: 15 minutes**
112112

113113
To allow **Managed Identity** access to Azure SQL Database resources (eg., Tables), a managed identity user has to be created in the database and granted specific roles. This would allow the managed identity user to manipulate data in the database tables.
114114

@@ -245,7 +245,7 @@ Execute the steps below to deploy the Claims Web API application on AKS.
245245

246246
3. Define and execute an Build Pipeline in Azure DevOps.
247247

248-
Login to [Azure DevOps Services](https://dev.azure.com/) and define a simple *Pipeline*. The pipeline should contain 2 tasks as detailed below.
248+
Login to [Azure DevOps Services](https://dev.azure.com/) portal and define a simple *Pipeline*. The pipeline should contain 2 tasks as detailed below.
249249

250250
- Docker **Build** Task: This task builds the Claims Web API application and application container image.
251251
- Docker **Push** Task: This task pushes the built application container image to ACR.
@@ -264,17 +264,7 @@ Execute the steps below to deploy the Claims Web API application on AKS.
264264

265265
In case you have deployed an Ingress Controller (Nginx / Traefik) on the AKS cluster, you can also expose the API endpoint on the ingress controller by deploying an *Ingress* resource (left as an exercise).
266266

267-
5. Create a new Kubernetes namespace for deploying Claims Web API with Managed Identity.
268-
269-
```bash
270-
# Create a new Kubernetes namespace 'dev-claims-mid' for deploying the Claims Web API application
271-
# with Managed Identity.
272-
#
273-
$ kubectl create namespace dev-claims-mid
274-
#
275-
```
276-
277-
6. Deploy the Claims Web API application.
267+
5. Deploy the Claims Web API application.
278268

279269
```bash
280270
# Install the Claims Web API application in namespace 'dev-claims-mid'
@@ -286,7 +276,7 @@ Execute the steps below to deploy the Claims Web API application on AKS.
286276
#
287277
```
288278

289-
3. Access the Claims Web API application.
279+
6. Access the Claims Web API application.
290280

291281
```bash
292282
# Get the ALB IP address for the Claims Web API endpoint

extensions/use-pod-identity/README.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
# Use AAD Pod Identity and Key Vault FlexVolume driver to inject Secrets into applications on AKS
22

3-
This extension project describes the steps for configuring AAD Pod Identity and Azure FlexVolume driver for retreiving secrets from Azure Key Vault and mounting them onto the file system within the Claims Web API application container.
3+
This project extension describes the steps for configuring AAD Pod Identity and Azure FlexVolume driver for retreiving secrets from Azure Key Vault and mounting them onto the file system within the Claims Web API application container.
44

55
In production environments, confidential data such as database user names and passwords are stored in a secure location such as Azure Key Vault and then injected into the application container at runtime.
66

7-
In this project, the Azure SQL Database **Connection String** will be stored in Azure Key Vault. The FlexVolume driver will be used to retrieve the connection string from Key Vault and mount it as a file on the container's file system.
7+
In this project, the Azure SQL Database **Connection String** will be stored in Azure Key Vault.
88

9-
Azure Active Directory (AAD) Pod Identity enables Kubernetes applications to access cloud resources securely using managed identities and service principals. Without any code modifications, containerized applications can access any resource on Azure cloud that uses AAD as an Identity provider.
9+
The **Azure Key Vault FlexVolume Driver** will be used to retrieve the connection string from Key Vault and mount it as a file on the container's file system.
10+
11+
**Azure Active Directory (AAD) Pod Identity** enables Kubernetes applications to access cloud resources securely using managed identities and service principals. Without any code modifications, containerized applications can access any resource on Azure cloud that uses AAD as an Identity provider.
1012

1113
**Functional Diagram:**
1214

1315
Refer to the architecture diagram [here](https://docs.microsoft.com/en-us/azure/aks/operator-best-practices-identity#use-pod-identities).
1416

1517
**Prerequisites:**
16-
1. Readers are required to complete Sections A thru G in the [parent project](https://github.com/ganrad/aks-aspnet-sqldb-rest) before proceeding with the hands-on labs in this project.
18+
1. Readers are required to complete Sections A thru G in the [parent project](https://github.com/ganrad/aks-aspnet-sqldb-rest) before proceeding with the hands-on labs in this sub-project.
1719

18-
Readers are advised to go thru the following on-line resources before proceeding with the hands-on sections.
20+
Readers are advised to go thru the following on-line resources as needed.
1921
- [Azure AAD Pod Identity](https://github.com/Azure/aad-pod-identity)
2022
- [Azure/Kubernetes Key Vault FlexVolume Driver](https://github.com/Azure/kubernetes-keyvault-flexvol)
2123

@@ -24,7 +26,7 @@ Readers are advised to go thru the following on-line resources before proceeding
2426

2527
An ingress controller provides reverse proxy, configurable traffic routing and TLS termination for applications (Web Services) deployed on the AKS cluster. The ingress controller acts as a single entry point for all external HTTP traffic inbound into the cluster and intelligently routes the calls to the respective application service end-points.
2628

27-
In this project, we will deploy an [Nginx Ingress Controller](https://github.com/kubernetes/ingress-nginx) and configure it to intercept and route HTTP calls to the Claims API microservice.
29+
In this sub-project, we will deploy an [Nginx Ingress Controller](https://github.com/kubernetes/ingress-nginx) and configure it to intercept and route HTTP calls to the Claims API microservice.
2830

2931
Follow the steps below to provision the Nginx Ingress Controller on the AKS cluster. You can also refer to the steps in the AKS documentation [here](https://docs.microsoft.com/en-us/azure/aks/ingress-basic).
3032

@@ -68,11 +70,11 @@ Follow the steps below to provision the Nginx Ingress Controller on the AKS clus
6870
## B. Deploy Azure Key Vault FlexVolume Driver on AKS cluster
6971
**Approx. time to complete this section: 10 minutes**
7072

71-
The FlexVolume driver is responsible for retrieving secrets from Azure Key Vault and mounting them into separate files on the application container's file system.
73+
The Azure Key Vault FlexVolume driver retrieves secrets from Azure Key Vault and mounts them into separate files on the application container's file system.
7274

7375
Follow the steps below to provision the FlexVolume driver on the AKS cluster.
7476

75-
1. Deploy Key Vault FlexVolume Driver on the AKS Cluster
77+
1. Deploy Azure Key Vault FlexVolume Driver on the AKS Cluster
7678

7779
```bash
7880
# Deploy the KV FlexVolume Driver on the AKS cluster.
@@ -87,7 +89,8 @@ Follow the steps below to provision the FlexVolume driver on the AKS cluster.
8789
## C. Install AAD Pod Identity components on AKS Cluster
8890
**Approx. time to complete this section: 30 minutes**
8991

90-
AAD Pod Identity consists of two key components and custom resources. The two core components are described below.
92+
AAD Pod Identity consists of two key components and custom resources. The two core components are briefly described below.
93+
9194
- **Managed Identity Controller (MIC)**
9295

9396
The MIC is a custom Kubernetes resource that watches for changes to Pods, Identities and Bindings through the Kubernetes API Server. When it detects a change, the MIC adds or deletes assigned identities as required.
@@ -112,6 +115,9 @@ Follow the steps below to deploy AAD Pod Identity components and custom resource
112115
#
113116
$ kubectl apply -f https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/deployment.yaml
114117
#
118+
# For AKS clusters, deploy the MIC and AKS add-on exception
119+
$ kubectl apply -f https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/mic-exception.yaml
120+
#
115121
# Verify MIC (Deployments) and NMI (Daemon sets) pods have been deployed on the cluster.
116122
# The pods will be deployed in the 'default' namespace. There should be as many instances of
117123
# NMI and MIC pods running as there are nodes in the cluster (1 pod on each node).
@@ -132,8 +138,9 @@ Follow the steps below to deploy AAD Pod Identity components and custom resource
132138
# - name => Managed Identity name eg., claims-api-mid
133139
#
134140
$ az identity create -g <resource-group> -n <name> -o json
135-
# Important: Save the json output of the above command in a file !! We will need to use 'clientId', 'principalId'
136-
# 'id' and other values from the json output in the subsequent commands below.
141+
# Important: Save the json output of the above command in a file !!
142+
# We will need to use 'clientId', 'principalId', 'id' and other values from the json output in
143+
# the subsequent steps below.
137144
#
138145
```
139146
4. Assign AKS cluster SPN Role.
@@ -176,7 +183,7 @@ The Azure SQL Database *Connection String* will be stored in an Azure Key Vault.
176183

177184
| Secret Name | Value | Description |
178185
| ----------- | ----- | ----------- |
179-
sqldbconn | Server=tcp:{SQL_SRV_PREFIX}.database.windows.net;Initial Catalog=ClaimsDB;Persist Security Info=False;User ID={SQL_USER_ID};Password={SQL_USER_PWD};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30; | The Azure SQL Database connection string. Value of 'ConnectionStrings.SqlServerDb' parameter in `appsettings.json` file. Make sure to substitute correct values for SQL_SRV_PREFIX, SQL_USER_ID & SQL_USER_PWD in the connection string. |
186+
sqldbconn | Server=tcp:{SQL_SRV_PREFIX}.database.windows.net;Initial Catalog=ClaimsDB;Persist Security Info=False;User ID={SQL_USER_ID};Password={SQL_USER_PWD};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30; | The Azure SQL Database connection string. Value of 'ConnectionStrings.SqlServerDb' parameter in `appsettings.json` file. **IMPORTANT:** Make sure to substitute correct values for SQL_SRV_PREFIX, SQL_USER_ID & SQL_USER_PWD in the connection string. |
180187

181188
3. Assign Azure Identity Roles.
182189

@@ -221,8 +228,8 @@ The Azure SQL Database *Connection String* will be stored in an Azure Key Vault.
221228
#
222229
# Edit the Pod Identity Kubernetes manifest file `./k8s-resources/aadpodidentity.yaml`, update
223230
# values for the following two attributes and then save the file.
224-
# - ResourceID => 'id' attribute value of the managed identity created in Section B step 3
225-
# - ClientID => 'clientId' value of the managed identity created in Section B step 3
231+
# - resourceID => 'id' attribute value of the managed identity created in Section B step 3
232+
# - clientID => 'clientId' value of the managed identity created in Section B step 3
226233
#
227234
# Deploy the pod identity custom resource on AKS
228235
$ kubectl apply -f ./k8s-resources/aadpodidentity.yaml -n dev-claims-podid
@@ -296,4 +303,4 @@ Execute the steps below to deploy the Claims Web API application on AKS.
296303

297304
Access the Claims Web API service using a browser eg., http://[ALB Public IP]/api/v1/claims.
298305

299-
Congrats! In this extension, you installed Azure **FlexVolume** driver and **AAD Pod Identity** components. Finally, you configured the Claims Web API application to use FlexVolume driver and the managed Pod Identity to retrieve SQL Connection String from an Azure Key Vault.
306+
Congrats! In this project extension, you installed **Azure Key Vault FlexVolume** driver and **AAD Pod Identity** components on the AKS cluster. Next, you secured the SQL Connection String by storing it in an Azure Key Vault. Finally, you configured the Claims Web API application to use FlexVolume driver and managed Pod Identity to retrieve the SQL Connection String from Key Vault and connect to the SQL Database.

extensions/use-pod-identity/k8s-resources/aadpodidentity.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ metadata:
44
name: claims-api-podid
55
spec:
66
type: 0
7-
ResourceID: /subscriptions/0000-0000/resourcegroups/resourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/claims-api-mid
8-
ClientID: 00000-7d73-470b-9c28-0000
7+
resourceID: /subscriptions/0000-0000/resourcegroups/resourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/claims-api-mid
8+
clientID: 00000-7d73-470b-9c28-0000

extensions/use-pod-identity/k8s-resources/aadpodidentitybinding.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ kind: AzureIdentityBinding
33
metadata:
44
name: claims-api-podid-binding
55
spec:
6-
AzureIdentity: claims-api-podid
7-
Selector: claims-api-kv-mid
6+
azureIdentity: claims-api-podid
7+
selector: claims-api-kv-mid

0 commit comments

Comments
 (0)