Skip to content

Commit a61bac9

Browse files
Merge pull request #251254 from RichardChen820/appconfig/junbchen/workloadIdentity
[App Configuration] Add workload identity and file-style support in reference doc
2 parents 95ea4b7 + e569554 commit a61bac9

File tree

1 file changed

+189
-10
lines changed

1 file changed

+189
-10
lines changed

articles/azure-app-configuration/reference-kubernetes-provider.md

Lines changed: 189 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,31 @@ The `spec.target` property has the following child property.
3131
|Name|Description|Required|Type|
3232
|---|---|---|---|
3333
|configMapName|The name of the ConfigMap to be created|true|string|
34+
|configMapData|The setting that specifies how the retrieved data should be populated in the generated ConfigMap|false|object|
3435

35-
If the `spec.auth` property isn't set, the system-assigned managed identity is used. It has the following child properties. Only one authentication method should be set.
36+
If the `spec.target.configMapData` property is not set, the generated ConfigMap will be populated with the list of key-values retrieved from Azure App Configuration, which allows the ConfigMap to be consumed as environment variables. Update this property if you wish to consume the ConfigMap as a mounted file. This property has the following child properties.
37+
38+
|Name|Description|Required|Type|
39+
|---|---|---|---|
40+
|type|The setting that indicates how the retrieved data is constructed in the generated ConfigMap. The allowed values include `default`, `json`, `yaml` and `properties`|optional|string|
41+
|key|The key name of the retrieved data when the `type` is set to `json`, `yaml` or `properties`. Set it to the file name if the ConfigMap is set up to be consumed as a mounted file|conditional|string|
42+
43+
The `spec.auth` property isn't required if the connection string of your App Configuration store is provided by setting the `spec.connectionStringReference` property. Otherwise, one of the identities, service principal, workload identity, or managed identity, will be used for authentication. The `spec.auth` has the following child properties. Only one of them should be specified. If none of them are set, the system-assigned managed identity of the virtual machine scale set will be used.
3644

3745
|Name|Description|Required|Type|
3846
|---|---|---|---|
39-
|managedIdentityClientId|The Client ID of user-assigned managed identity|false|string|
4047
|servicePrincipalReference|The name of the Kubernetes Secret that contains the credentials of a service principal|false|string|
48+
|workloadIdentity|The settings for using workload identity|false|object|
49+
|managedIdentityClientId|The Client ID of user-assigned managed identity of virtual machine scale set|false|string|
4150

42-
The `spec.keyValues` has the following child properties. The `spec.keyValues.keyVaults` property is required if any Key Vault references are expected to be downloaded.
51+
The `spec.auth.workloadIdentity` property has the following child property.
4352

53+
|Name|Description|Required|Type|
54+
|---|---|---|---|
55+
|managedIdentityClientId|The Client ID of the user-assigned managed identity associated with the workload identity|true|string|
56+
57+
The `spec.keyValues` has the following child properties. The `spec.keyValues.keyVaults` property is required if any Key Vault references are expected to be downloaded.
58+
4459
|Name|Description|Required|Type|
4560
|---|---|---|---|
4661
|selectors|The list of selectors for key-value filtering|false|object array|
@@ -72,17 +87,19 @@ If the `spec.keyValues.keyVaults.auth` property isn't set, the system-assigned m
7287

7388
|Name|Description|Required|Type|
7489
|---|---|---|---|
75-
|managedIdentityClientId|The client ID of a user-assigned managed identity used for authentication with vaults that don't have individual authentication methods specified|false|string|
7690
|servicePrincipalReference|The name of the Kubernetes Secret that contains the credentials of a service principal used for authentication with vaults that don't have individual authentication methods specified|false|string|
91+
|workloadIdentity|The settings of the workload identity used for authentication with vaults that don't have individual authentication methods specified. It has the same child properties as `spec.auth.workloadIdentity`|false|object|
92+
|managedIdentityClientId|The client ID of a user-assigned managed identity of virtual machine scale set used for authentication with vaults that don't have individual authentication methods specified|false|string|
7793
|vaults|The authentication methods for individual vaults|false|object array|
7894

79-
The authentication method of each *vault* can be specified with the following properties. One of `managedIdentityClientId` and `servicePrincipalReference` must be provided.
95+
The authentication method of each *vault* can be specified with the following properties. One of `managedIdentityClientId`, `servicePrincipalReference` or `workloadIdentity` must be provided.
8096

8197
|Name|Description|Required|Type|
8298
|---|---|---|---|
8399
|uri|The URI of a vault|true|string|
84-
|managedIdentityClientId|The client ID of a user-assigned managed identity used for authentication with a vault|false|string|
85100
|servicePrincipalReference|The name of the Kubernetes Secret that contains the credentials of a service principal used for authentication with a vault|false|string|
101+
|workloadIdentity|The settings of the workload identity used for authentication with a vault. It has the same child properties as `spec.auth.workloadIdentity`|false|object|
102+
|managedIdentityClientId|The client ID of a user-assigned managed identity of virtual machine scale set used for authentication with a vault|false|string|
86103

87104
The `spec.keyValues.refresh` property has the following child properties.
88105

@@ -102,10 +119,12 @@ The `spec.keyValues.refresh.monitoring.keyValues` is an array of objects, which
102119

103120
### Authentication
104121

105-
#### Use System-Assigned Managed Identity
122+
#### Use system-assigned managed identity of virtual machine scale set
106123

107124
1. [Enable the system-assigned managed identity in the virtual machine scale set](/azure/active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vmss#enable-system-assigned-managed-identity-on-an-existing-virtual-machine-scale-set) used by the Azure Kubernetes Service (AKS) cluster.
125+
108126
1. [Grant the system-assigned managed identity **App Configuration Data Reader** role](/azure/azure-app-configuration/howto-integrate-azure-managed-service-identity#grant-access-to-app-configuration) in Azure App Configuration.
127+
109128
1. Deploy the following sample `AzureAppConfigurationProvider` resource to the AKS cluster.
110129

111130
``` yaml
@@ -119,11 +138,14 @@ The `spec.keyValues.refresh.monitoring.keyValues` is an array of objects, which
119138
configMapName: configmap-created-by-appconfig-provider
120139
```
121140
122-
#### Use User-Assigned Managed Identity
141+
#### Use user-assigned managed identity of virtual machine scale set
123142
124143
1. [Create a user-assigned managed identity](/azure/active-directory/managed-identities-azure-resources/how-manage-user-assigned-managed-identities#create-a-user-assigned-managed-identity) and note down its client ID after creation.
144+
125145
1. [Assign the user-assigned managed identity to the virtual machine scale set](/azure/active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vmss#user-assigned-managed-identity) used by the Azure Kubernetes Service (AKS) cluster.
146+
126147
1. [Grant the user-assigned managed identity **App Configuration Data Reader** role](/azure/active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vmss#user-assigned-managed-identity) in Azure App Configuration.
148+
127149
1. Set the `spec.auth.managedIdentityClientId` property to the client ID of the user-assigned managed identity in the following sample `AzureAppConfigurationProvider` resource and deploy it to the AKS cluster.
128150

129151
``` yaml
@@ -139,11 +161,14 @@ The `spec.keyValues.refresh.monitoring.keyValues` is an array of objects, which
139161
managedIdentityClientId: <your-managed-identity-client-id>
140162
```
141163

142-
#### Use Service Principal
164+
#### Use service principal
143165

144166
1. [Create a Service Principal](/azure/active-directory/develop/howto-create-service-principal-portal)
167+
145168
1. [Grant the service principal **App Configuration Data Reader** role](/azure/azure-app-configuration/howto-integrate-azure-managed-service-identity#grant-access-to-app-configuration) in Azure App Configuration.
169+
146170
1. Create a Kubernetes Secret in the same namespace as the `AzureAppConfigurationProvider` resource and add *azure_client_id*, *azure_client_secret*, and *azure_tenant_id* of the service principal to the Secret.
171+
147172
1. Set the `spec.auth.servicePrincipalReference` property to the name of the Secret in the following sample `AzureAppConfigurationProvider` resource and deploy it to the Kubernetes cluster.
148173

149174
``` yaml
@@ -159,9 +184,42 @@ The `spec.keyValues.refresh.monitoring.keyValues` is an array of objects, which
159184
servicePrincipalReference: <your-service-principal-secret-name>
160185
```
161186

162-
#### Use Connection String
187+
#### Use workload identity
188+
189+
1. [Enable Workload Identity](/azure/aks/workload-identity-deploy-cluster#update-an-existing-aks-cluster) on the Azure Kubernetes Service (AKS) cluster.
190+
191+
1. [Get the OIDC issuer URL](/azure/aks/workload-identity-deploy-cluster#retrieve-the-oidc-issuer-url) of the AKS cluster.
192+
193+
1. [Create a user-assigned managed identity](/azure/active-directory/managed-identities-azure-resources/how-manage-user-assigned-managed-identities#create-a-user-assigned-managed-identity) and note down its client ID after creation.
194+
195+
1. Create the federated identity credential between the managed identity, OIDC issuer, and subject using the Azure CLI.
196+
197+
``` azurecli
198+
az identity federated-credential create --name "${FEDERATED_IDENTITY_CREDENTIAL_NAME}" --identity-name "${USER_ASSIGNED_IDENTITY_NAME}" --resource-group "${RESOURCE_GROUP}" --issuer "${AKS_OIDC_ISSUER}" --subject system:serviceaccount:azappconfig-system:az-appconfig-k8s-provider --audience api://AzureADTokenExchange
199+
```
200+
201+
1. [Grant the user-assigned managed identity **App Configuration Data Reader** role](/azure/active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vmss#user-assigned-managed-identity) in Azure App Configuration.
202+
203+
1. Set the `spec.auth.workloadIdentity.managedIdentityClientId` property to the client ID of the user-assigned managed identity in the following sample `AzureAppConfigurationProvider` resource and deploy it to the AKS cluster.
204+
205+
``` yaml
206+
apiVersion: azconfig.io/v1beta1
207+
kind: AzureAppConfigurationProvider
208+
metadata:
209+
name: appconfigurationprovider-sample
210+
spec:
211+
endpoint: <your-app-configuration-store-endpoint>
212+
target:
213+
configMapName: configmap-created-by-appconfig-provider
214+
auth:
215+
workloadIdentity:
216+
managedIdentityClientId: <your-managed-identity-client-id>
217+
```
218+
219+
#### Use connection string
163220

164221
1. Create a Kubernetes Secret in the same namespace as the `AzureAppConfigurationProvider` resource and add Azure App Configuration connection string with key *azure_app_configuration_connection_string* in the Secret.
222+
165223
1. Set the `spec.connectionStringReference` property to the name of the Secret in the following sample `AzureAppConfigurationProvider` resource and deploy it to the Kubernetes cluster.
166224

167225
``` yaml
@@ -174,6 +232,7 @@ The `spec.keyValues.refresh.monitoring.keyValues` is an array of objects, which
174232
target:
175233
configMapName: configmap-created-by-appconfig-provider
176234
```
235+
177236
### Key-value selection
178237

179238
Use the `selectors` property to filter the key-values to be downloaded from Azure App Configuration.
@@ -282,4 +341,124 @@ spec:
282341
label: common
283342
- key: sentinelKey
284343
label: development
344+
```
345+
346+
### Consume ConfigMap
347+
348+
Applications running in Kubernetes typically consume the ConfigMap either as environment variables or as configuration files. If the `configMapData.type` property is absent or is set to default, the ConfigMap is populated with the itemized list of data retrieved from Azure App Configuration, which can be easily consumed as environment variables. If the `configMapData.type` property is set to json, yaml or properties, data retrieved from Azure App Configuration is grouped into one item with key name specified by the `configMapData.key` property in the generated ConfigMap, which can be consumed as a mounted file.
349+
350+
The following examples show how the data is populated in the generated ConfigMap with different settings of the `configMapData.type` property.
351+
352+
Assuming an App Configuration store has these key-values:
353+
354+
|key|value|
355+
|---|---|
356+
|key1|value1|
357+
|key2|value2|
358+
|key3|value3|
359+
360+
#### [default](#tab/default)
361+
362+
and the `configMapData.type` property is absent or set to `default`,
363+
364+
``` yaml
365+
apiVersion: azconfig.io/v1beta1
366+
kind: AzureAppConfigurationProvider
367+
metadata:
368+
name: appconfigurationprovider-sample
369+
spec:
370+
endpoint: <your-app-configuration-store-endpoint>
371+
target:
372+
configMapName: configmap-created-by-appconfig-provider
373+
```
374+
375+
the generated ConfigMap will be populated with the following data:
376+
377+
``` yaml
378+
data:
379+
key1: value1
380+
key2: value2
381+
key3: value3
382+
```
383+
384+
#### [json](#tab/json)
385+
386+
and the `configMapData.type` property is set to `json`,
387+
388+
``` yaml
389+
apiVersion: azconfig.io/v1beta1
390+
kind: AzureAppConfigurationProvider
391+
metadata:
392+
name: appconfigurationprovider-sample
393+
spec:
394+
endpoint: <your-app-configuration-store-endpoint>
395+
target:
396+
configMapName: configmap-created-by-appconfig-provider
397+
configMapData:
398+
type: json
399+
key: appSettings.json
400+
```
401+
402+
the generated ConfigMap will be populated with the following data:
403+
404+
``` yaml
405+
data:
406+
appSettings.json: >-
407+
{"key1":"value1","key2":"value2","key3":"value3"}
408+
```
409+
410+
#### [yaml](#tab/yaml)
411+
412+
and the `configMapData.type` property is set to `yaml`,
413+
414+
``` yaml
415+
apiVersion: azconfig.io/v1beta1
416+
kind: AzureAppConfigurationProvider
417+
metadata:
418+
name: appconfigurationprovider-sample
419+
spec:
420+
endpoint: <your-app-configuration-store-endpoint>
421+
target:
422+
configMapName: configmap-created-by-appconfig-provider
423+
configMapData:
424+
type: yaml
425+
key: appSettings.yaml
426+
```
427+
428+
the generated ConfigMap will be populated with the following data:
429+
430+
``` yaml
431+
data:
432+
appSettings.yaml: >-
433+
key1: value1
434+
key2: value2
435+
key3: value3
436+
```
437+
438+
#### [properties](#tab/properties)
439+
440+
and the `configMapData.type` property is set to `properties`,
441+
442+
``` yaml
443+
apiVersion: azconfig.io/v1beta1
444+
kind: AzureAppConfigurationProvider
445+
metadata:
446+
name: appconfigurationprovider-sample
447+
spec:
448+
endpoint: <your-app-configuration-store-endpoint>
449+
target:
450+
configMapName: configmap-created-by-appconfig-provider
451+
configMapData:
452+
type: properties
453+
key: app.properties
454+
```
455+
456+
the generated ConfigMap will be populated with the following data:
457+
458+
``` yaml
459+
data:
460+
app.properties: >-
461+
key1=value1
462+
key2=value2
463+
key3=value3
285464
```

0 commit comments

Comments
 (0)