Skip to content

Commit 7740df2

Browse files
Merge pull request #278264 from RichardChen820/user/junbchen/saWorkloadIdentity
Add custom service account support
2 parents 1ac9c42 + 2e1d2ea commit 7740df2

File tree

2 files changed

+49
-25
lines changed

2 files changed

+49
-25
lines changed

articles/azure-app-configuration/quickstart-azure-kubernetes-service.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ Add following key-values to the App Configuration store and leave **Label** and
241241
--namespace azappconfig-system \
242242
--create-namespace
243243
```
244-
244+
245245
> [!TIP]
246246
> The App Configuration Kubernetes Provider is also available as an AKS extension. This integration allows for seamless installation and management via the Azure CLI, ARM templates, or Bicep templates. Utilizing the AKS extension facilitates automatic minor/patch version updates, ensuring your system is always up-to-date. For detailed installation instructions, please refer to the [Azure App Configuration extension for Azure Kubernetes Service](/azure/aks/azure-app-configuration).
247247
@@ -261,10 +261,10 @@ Add following key-values to the App Configuration store and leave **Label** and
261261
key: mysettings.json
262262
auth:
263263
workloadIdentity:
264-
managedIdentityClientId: <your-managed-identity-client-id>
264+
serviceAccountName: <your-service-account-name>
265265
```
266266
267-
Replace the value of the `endpoint` field with the endpoint of your Azure App Configuration store. Follow the steps in [use workload identity](./reference-kubernetes-provider.md#use-workload-identity) and update the `auth` section with the client ID of the user-assigned managed identity you created.
267+
Replace the value of the `endpoint` field with the endpoint of your Azure App Configuration store. Proceed to the next step to update the `auth` section with your authentication information.
268268
269269
> [!NOTE]
270270
> `AzureAppConfigurationProvider` is a declarative API object. It defines the desired state of the ConfigMap created from the data in your App Configuration store with the following behavior:
@@ -273,6 +273,8 @@ Add following key-values to the App Configuration store and leave **Label** and
273273
> - The ConfigMap will be reset based on the present data in your App Configuration store if it's deleted or modified by any other means.
274274
> - The ConfigMap will be deleted if the App Configuration Kubernetes Provider is uninstalled.
275275
276+
1. Follow the [instructions to use the workload identity](./reference-kubernetes-provider.md#use-workload-identity) to authenticate with your App Configuration store. Update the *appConfigurationProvider.yaml* file by replacing the `serviceAccountName` field with the name of the service account you created. For more information on other authentication methods, refer to the examples in the [Authentication](./reference-kubernetes-provider.md#authentication) section.
277+
276278
1. Update the *deployment.yaml* file in the *Deployment* directory to use the ConfigMap `configmap-created-by-appconfig-provider` as a mounted data volume. It is important to ensure that the `volumeMounts.mountPath` matches the `WORKDIR` specified in your *Dockerfile* and the *config* directory created before.
277279
278280
```yaml
@@ -370,6 +372,10 @@ Ensure that you specify the correct key-value selectors to match the expected da
370372

371373
You can customize the installation by providing additional Helm values when installing the Azure App Configuration Kubernetes Provider. For example, you can set the log level, configure the provider to run on a specific node, or disable the workload identity. Refer to the [installation guide](./reference-kubernetes-provider.md#installation) for more information.
372374

375+
#### Why am I unable to authenticate with Azure App Configuration using workload identity after upgrading the provider to version 2.0.0?
376+
377+
Starting with version 2.0.0, a user-provided service account is required for authenticating with Azure App Configuration [using workload identity](./reference-kubernetes-provider.md#use-workload-identity). This change enhances security through namespace isolation. Previously, a Kubernetes provider’s service account was used for all namespaces. For updated instructions, see the documentation on using workload identity. If you need time to migrate when upgrading to version 2.0.0, you can temporarily set `workloadIdentity.globalServiceAccountEnabled=true` during provider installation. Please note that support for using the provider’s service account will be deprecated in a future release.
378+
373379
## Clean up resources
374380

375381
Uninstall the App Configuration Kubernetes Provider from your AKS cluster if you want to keep the AKS cluster.

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

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.author: junbchen
1212

1313
# Azure App Configuration Kubernetes Provider reference
1414

15-
The following reference outlines the properties supported by the Azure App Configuration Kubernetes Provider `v1.3.0`. See [release notes](https://github.com/Azure/AppConfiguration/blob/main/releaseNotes/KubernetesProvider.md) for more information on the change.
15+
The following reference outlines the properties supported by the Azure App Configuration Kubernetes Provider `v2.0.0`. See [release notes](https://github.com/Azure/AppConfiguration/blob/main/releaseNotes/KubernetesProvider.md) for more information on the change.
1616

1717
## Properties
1818

@@ -52,19 +52,11 @@ The `spec.auth` property isn't required if the connection string of your App Con
5252
|workloadIdentity|The settings for using workload identity.|false|object|
5353
|managedIdentityClientId|The client ID of user-assigned managed identity of virtual machine scale set.|false|string|
5454

55-
The `spec.auth.workloadIdentity` property has the following child properties. One of them must be specified.
55+
The `spec.auth.workloadIdentity` property has the following child property.
5656

5757
|Name|Description|Required|Type|
5858
|---|---|---|---|
59-
|managedIdentityClientId|The client ID of the user-assigned managed identity associated with the workload identity.|alternative|string|
60-
|managedIdentityClientIdReference|The client ID of the user-assigned managed identity can be obtained from a ConfigMap. The ConfigMap must be in the same namespace as the Kubernetes provider.|alternative|object|
61-
62-
The `spec.auth.workloadIdentity.managedIdentityClientIdReference` property has the following child properties.
63-
64-
|Name|Description|Required|Type|
65-
|---|---|---|---|
66-
|configMap|The name of the ConfigMap where the client ID of a user-assigned managed identity can be found.|true|string|
67-
|key|The key name that holds the value for the client ID of a user-assigned managed identity.|true|string|
59+
|serviceAccountName|The name of the service account associated with the workload identity.|true|string|
6860

6961
The `spec.configuration` has the following child properties.
7062

@@ -116,7 +108,7 @@ If the `spec.secret.auth` property isn't set, the system-assigned managed identi
116108
|Name|Description|Required|Type|
117109
|---|---|---|---|
118110
|servicePrincipalReference|The name of the Kubernetes Secret that contains the credentials of a service principal used for authentication with Key Vaults that don't have individual authentication methods specified.|false|string|
119-
|workloadIdentity|The settings of the workload identity used for authentication with Key Vaults that don't have individual authentication methods specified. It has the same child properties as `spec.auth.workloadIdentity`.|false|object|
111+
|workloadIdentity|The settings of the workload identity used for authentication with Key Vaults that don't have individual authentication methods specified. It has the same child property as `spec.auth.workloadIdentity`.|false|object|
120112
|managedIdentityClientId|The client ID of a user-assigned managed identity of virtual machine scale set used for authentication with Key Vaults that don't have individual authentication methods specified.|false|string|
121113
|keyVaults|The authentication methods for individual Key Vaults.|false|object array|
122114

@@ -126,7 +118,7 @@ The authentication method of each *Key Vault* can be specified with the followin
126118
|---|---|---|---|
127119
|uri|The URI of a Key Vault.|true|string|
128120
|servicePrincipalReference|The name of the Kubernetes Secret that contains the credentials of a service principal used for authentication with a Key Vault.|false|string|
129-
|workloadIdentity|The settings of the workload identity used for authentication with a Key Vault. It has the same child properties as `spec.auth.workloadIdentity`.|false|object|
121+
|workloadIdentity|The settings of the workload identity used for authentication with a Key Vault. It has the same child property as `spec.auth.workloadIdentity`.|false|object|
130122
|managedIdentityClientId|The client ID of a user-assigned managed identity of virtual machine scale set used for authentication with a Key Vault.|false|string|
131123

132124
The `spec.secret.refresh` property has the following child properties.
@@ -161,7 +153,7 @@ The `spec.featureFlag.refresh` property has the following child properties.
161153
## Installation
162154

163155
Use the following `helm install` command to install the Azure App Configuration Kubernetes Provider. See [helm-values.yaml](https://github.com/Azure/AppConfiguration-KubernetesProvider/blob/main/deploy/parameter/helm-values.yaml) for the complete list of parameters and their default values. You can override the default values by passing the `--set` flag to the command.
164-
156+
165157
```bash
166158
helm install azureappconfiguration.kubernetesprovider \
167159
oci://mcr.microsoft.com/azure-app-configuration/helmchart/kubernetes-provider \
@@ -173,6 +165,18 @@ helm install azureappconfiguration.kubernetesprovider \
173165

174166
By default, autoscaling is disabled. However, if you have multiple `AzureAppConfigurationProvider` resources to produce multiple ConfigMaps/Secrets, you can enable horizontal pod autoscaling by setting `autoscaling.enabled` to `true`.
175167

168+
```bash
169+
helm install azureappconfiguration.kubernetesprovider \
170+
oci://mcr.microsoft.com/azure-app-configuration/helmchart/kubernetes-provider \
171+
--namespace azappconfig-system \
172+
--create-namespace
173+
--set autoscaling.enabled=true
174+
```
175+
176+
## Data collection
177+
178+
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry by setting the `requestTracing.enabled=false` while installing the Azure App Configuration Kubernetes Provider. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
179+
176180
## Examples
177181

178182
### Authentication
@@ -248,17 +252,31 @@ By default, autoscaling is disabled. However, if you have multiple `AzureAppConf
248252

249253
1. [Get the OIDC issuer URL](/azure/aks/workload-identity-deploy-cluster#retrieve-the-oidc-issuer-url) of the AKS cluster.
250254

251-
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.
255+
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, tenant ID, name, and resource group.
252256

253-
1. Create the federated identity credential between the managed identity, OIDC issuer, and subject using the Azure CLI.
257+
1. [Grant the user-assigned managed identity **App Configuration Data Reader** role](/azure/azure-app-configuration/concept-enable-rbac#assign-azure-roles-for-access-rights) in Azure App Configuration.
258+
259+
1. Create a service account by adding a YAML file (e.g., *serviceAccount.yaml*) with the following content to the directory containing your AKS deployment files. The service account will be created when you apply all your deployment changes to your AKS cluster (e.g., using `kubectl apply`). Replace `<your-managed-identity-client-id>` with the client ID and `<your-managed-identity-tenant-id>` with the tenant ID of the user-assigned managed identity that has just been created. Replace `<your-service-account-name>` with your preferred name.
254260

255-
``` azurecli
256-
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
257-
```
261+
``` yaml
262+
apiVersion: v1
263+
kind: ServiceAccount
264+
metadata:
265+
name: <your-service-account-name>
266+
annotations:
267+
azure.workload.identity/client-id: <your-managed-identity-client-id>
268+
azure.workload.identity/tenant-id: <your-managed-identity-tenant-id>
269+
```
258270

259-
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.
271+
1. Create a federated identity credential for the user-assigned managed identity using the Azure CLI. Replace `<user-assigned-identity-name>` with the name and `<resource-group>` with the resource group of the newly created user-assigned managed identity. Replace `<aks-oidc-issuer>` with the OIDC issuer URL of the AKS cluster. Replace `<your-service-account-name>` with the name of the newly created service account. Replace `<federated-identity-credential-name>` with your preferred name for the federated identity credential.
272+
273+
``` azurecli
274+
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:default:<your-service-account-name> --audience api://AzureADTokenExchange
275+
```
276+
277+
Note that the subject of the federated identity credential should follow this format: `system:serviceaccount:<service-account-namespace>:<service-account-name>`.
260278

261-
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.
279+
1. Set the `spec.auth.workloadIdentity.serviceAccountName` property to the name of the service account in the following sample `AzureAppConfigurationProvider` resource. Be sure that the `AzureAppConfigurationProvider` resource and the service account are in the same namespace.
262280

263281
``` yaml
264282
apiVersion: azconfig.io/v1
@@ -271,7 +289,7 @@ By default, autoscaling is disabled. However, if you have multiple `AzureAppConf
271289
configMapName: configmap-created-by-appconfig-provider
272290
auth:
273291
workloadIdentity:
274-
managedIdentityClientId: <your-managed-identity-client-id>
292+
serviceAccountName: <your-service-account-name>
275293
```
276294

277295
#### Use connection string

0 commit comments

Comments
 (0)