You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: extensions/use-pod-identity-mid/README.md
+12-22Lines changed: 12 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
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.
4
4
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.
6
6
7
7
*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.
8
8
@@ -18,7 +18,7 @@ In this sub-project, you will work on completing the following tasks.
18
18
Refer to the architecture diagram [here](https://docs.microsoft.com/en-us/azure/aks/operator-best-practices-identity#use-pod-identities).
19
19
20
20
**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.
22
22
23
23
Readers are advised to refer to the following on-line resources as needed.
24
24
-[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.
27
27
-[Use Managed Identities in AKS](https://docs.microsoft.com/en-us/azure/aks/use-managed-identity)
28
28
29
29
## 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**
31
31
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.
33
33
-**Managed Identity Controller (MIC)**
34
34
35
35
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
65
65
#
66
66
```
67
67
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.
69
69
70
70
Save the values of `clientId` and `id` from the command output.
71
71
@@ -74,7 +74,7 @@ Follow the steps below to deploy AAD Pod Identity components and custom resource
74
74
# prefix..
75
75
# Make sure you are logged in to your Azure account and have configured the correct subscription.
76
76
# 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
78
78
# - name => Managed Identity name eg., claims-api-mid
79
79
#
80
80
$ 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
85
85
86
86
4. Assign Roles to AKS cluster Service Principal.
87
87
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.
89
89
90
90
```bash
91
91
# Retrieve the AKS cluster service principal id.
92
92
# 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
94
94
# - name => AKS cluster name
95
95
#
96
96
$ 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
108
108
```
109
109
110
110
## B. Configure Azure SQL Database
111
-
**Approx. time to complete this section: 25 minutes**
111
+
**Approx. time to complete this section: 15 minutes**
112
112
113
113
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.
114
114
@@ -245,7 +245,7 @@ Execute the steps below to deploy the Claims Web API application on AKS.
245
245
246
246
3. Define and execute an Build Pipeline in Azure DevOps.
247
247
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.
249
249
250
250
- Docker **Build** Task: This task builds the Claims Web API application and application container image.
251
251
- 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.
264
264
265
265
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).
266
266
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.
278
268
279
269
```bash
280
270
# 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.
286
276
#
287
277
```
288
278
289
-
3. Access the Claims Web API application.
279
+
6. Access the Claims Web API application.
290
280
291
281
```bash
292
282
# Get the ALB IP address for the Claims Web API endpoint
Copy file name to clipboardExpand all lines: extensions/use-pod-identity/README.md
+22-15Lines changed: 22 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,23 @@
1
1
# Use AAD Pod Identity and Key Vault FlexVolume driver to inject Secrets into applications on AKS
2
2
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.
4
4
5
5
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.
6
6
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.
8
8
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.
10
12
11
13
**Functional Diagram:**
12
14
13
15
Refer to the architecture diagram [here](https://docs.microsoft.com/en-us/azure/aks/operator-best-practices-identity#use-pod-identities).
14
16
15
17
**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.
17
19
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.
19
21
-[Azure AAD Pod Identity](https://github.com/Azure/aad-pod-identity)
@@ -24,7 +26,7 @@ Readers are advised to go thru the following on-line resources before proceeding
24
26
25
27
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.
26
28
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.
28
30
29
31
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).
30
32
@@ -68,11 +70,11 @@ Follow the steps below to provision the Nginx Ingress Controller on the AKS clus
68
70
## B. Deploy Azure Key Vault FlexVolume Driver on AKS cluster
69
71
**Approx. time to complete this section: 10 minutes**
70
72
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.
72
74
73
75
Follow the steps below to provision the FlexVolume driver on the AKS cluster.
74
76
75
-
1. Deploy Key Vault FlexVolume Driver on the AKS Cluster
77
+
1. Deploy Azure Key Vault FlexVolume Driver on the AKS Cluster
76
78
77
79
```bash
78
80
# 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.
87
89
## C. Install AAD Pod Identity components on AKS Cluster
88
90
**Approx. time to complete this section: 30 minutes**
89
91
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
+
91
94
-**Managed Identity Controller (MIC)**
92
95
93
96
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
# Verify MIC (Deployments) and NMI (Daemon sets) pods have been deployed on the cluster.
116
122
# The pods will be deployed in the 'default' namespace. There should be as many instances of
117
123
# 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
132
138
# - name => Managed Identity name eg., claims-api-mid
133
139
#
134
140
$ 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.
137
144
#
138
145
```
139
146
4. Assign AKS cluster SPN Role.
@@ -176,7 +183,7 @@ The Azure SQL Database *Connection String* will be stored in an Azure Key Vault.
176
183
177
184
| Secret Name | Value | Description |
178
185
| ----------- | ----- | ----------- |
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. |
180
187
181
188
3. Assign Azure Identity Roles.
182
189
@@ -221,8 +228,8 @@ The Azure SQL Database *Connection String* will be stored in an Azure Key Vault.
221
228
#
222
229
# Edit the Pod Identity Kubernetes manifest file `./k8s-resources/aadpodidentity.yaml`, update
223
230
# 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
@@ -296,4 +303,4 @@ Execute the steps below to deploy the Claims Web API application on AKS.
296
303
297
304
Access the Claims Web API service using a browser eg., http://[ALB Public IP]/api/v1/claims.
298
305
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.
0 commit comments