Skip to content

Commit 04abbaf

Browse files
committed
Fix indents
1 parent 9e09757 commit 04abbaf

File tree

1 file changed

+65
-66
lines changed

1 file changed

+65
-66
lines changed

AKS-Hybrid/workload-identity.md

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ az identity federated-credential show --name $FedIdCredentialName --resource-gro
204204
> [!NOTE]
205205
> After you add a federated identity credential, it takes a few seconds to propagate. Token requests made immediately afterward might fail until the cache refreshes. To prevent this issue, consider adding a brief delay after creating the federated identity credential.
206206
207-
208207
## Step 4: Deploy your application
209208

210209
When you deploy your application pods, the manifest should reference the service account created in the **Create Kubernetes service account** step. The following manifest shows how to reference the account, specifically the `metadata\namespace` and `spec\serviceAccountName` properties. Make sure to specify an image for `image` and a container name
@@ -248,71 +247,71 @@ The following example shows how to use the Azure role-based access control (Azur
248247

249248
1. Create a key vault with purge protection and RBAC authorization enabled. You can also use an existing key vault if it is configured for both purge protection and RBAC authorization:
250249

251-
```azurecli
252-
az keyvault create --name $KVName --resource-group $resource_group_name --location $Location --enable-purge-protection --enable-rbac-authorization
253-
254-
# retrieve the key vault ID for role assignment
255-
$KVId=$(az keyvault show --resource-group $resource_group_name --name $KVName --query id --output tsv)
256-
```
257-
258-
2. Assign the RBAC [Key Vault Secrets Officer](/azure/role-based-access-control/built-in-roles/security#key-vault-secrets-officer) role to yourself so that you can create a secret in the new key vault. New role assignments can take up to five minutes to propagate and be updated by the authorization server.
259-
260-
```azurecli
261-
az role assignment create --assignee-object-id $MSIPrincipalId --role "Key Vault Secrets Officer" --scope $KVId --assignee-principal-type ServicePrincipal
262-
```
263-
264-
3. Create a secret in the key vault:
265-
266-
```azurecli
267-
az keyvault secret set --vault-name $KVName --name $KVSecretName --value "Hello!"
268-
```
269-
270-
4. Assign the [Key Vault Secrets User](/azure/role-based-access-control/built-in-roles/security#key-vault-secrets-user) role to the user-assigned managed identity that you created previously. This step gives the managed identity permission to read secrets from the key vault:
271-
272-
```azurecli
273-
az role assignment create --assignee-object-id $MSIPrincipalId --role "Key Vault Secrets User" --scope $KVId --assignee-principal-type ServicePrincipal
274-
```
275-
276-
5. Create an environment variable for the key vault URL:
277-
278-
```azurecli
279-
$KVUrl=$(az keyvault show --resource-group $resource_group_name --name $KVName --query properties.vaultUri --output tsv)
280-
```
281-
282-
6. Deploy a pod that references the service account and key vault URL:
283-
284-
```azurecli
285-
$yaml = @"
286-
apiVersion: v1
287-
kind: Pod
288-
metadata:
289-
name: sample-quick-start
290-
namespace: $SERVICE_ACCOUNT_NAMESPACE
291-
labels:
292-
azure.workload.identity/use: "true"
293-
spec:
294-
serviceAccountName: $SERVICE_ACCOUNT_NAME
295-
containers:
296-
- image: ghcr.io/azure/azure-workload-identity/msal-go
297-
name: oidc
298-
env:
299-
- name: KEYVAULT_URL
300-
value: $KVUrl
301-
- name: SECRET_NAME
302-
value: $KVSecretName
303-
nodeSelector:
304-
kubernetes.io/os: linux
305-
"@
306-
307-
# Replace variables within the YAML content
308-
$yaml = $yaml -replace '\$SERVICE_ACCOUNT_NAMESPACE', $SERVICE_ACCOUNT_NAMESPACE `
309-
-replace '\$SERVICE_ACCOUNT_NAME', $SERVICE_ACCOUNT_NAME `
310-
-replace '\$KVUrl', $KVUrl `
311-
-replace '\$KVSecretName', $KVSecretName
312-
313-
# Apply the YAML configuration
314-
$yaml | kubectl --kubeconfig $aks_cluster_name apply -f -
315-
```
250+
```azurecli
251+
az keyvault create --name $KVName --resource-group $resource_group_name --location $Location --enable-purge-protection --enable-rbac-authorization
252+
253+
# retrieve the key vault ID for role assignment
254+
$KVId=$(az keyvault show --resource-group $resource_group_name --name $KVName --query id --output tsv)
255+
```
256+
257+
1. Assign the RBAC [Key Vault Secrets Officer](/azure/role-based-access-control/built-in-roles/security#key-vault-secrets-officer) role to yourself so that you can create a secret in the new key vault. New role assignments can take up to five minutes to propagate and be updated by the authorization server.
258+
259+
```azurecli
260+
az role assignment create --assignee-object-id $MSIPrincipalId --role "Key Vault Secrets Officer" --scope $KVId --assignee-principal-type ServicePrincipal
261+
```
262+
263+
1. Create a secret in the key vault:
264+
265+
```azurecli
266+
az keyvault secret set --vault-name $KVName --name $KVSecretName --value "Hello!"
267+
```
268+
269+
1. Assign the [Key Vault Secrets User](/azure/role-based-access-control/built-in-roles/security#key-vault-secrets-user) role to the user-assigned managed identity that you created previously. This step gives the managed identity permission to read secrets from the key vault:
270+
271+
```azurecli
272+
az role assignment create --assignee-object-id $MSIPrincipalId --role "Key Vault Secrets User" --scope $KVId --assignee-principal-type ServicePrincipal
273+
```
274+
275+
1. Create an environment variable for the key vault URL:
276+
277+
```azurecli
278+
$KVUrl=$(az keyvault show --resource-group $resource_group_name --name $KVName --query properties.vaultUri --output tsv)
279+
```
280+
281+
1. Deploy a pod that references the service account and key vault URL:
282+
283+
```azurecli
284+
$yaml = @"
285+
apiVersion: v1
286+
kind: Pod
287+
metadata:
288+
name: sample-quick-start
289+
namespace: $SERVICE_ACCOUNT_NAMESPACE
290+
labels:
291+
azure.workload.identity/use: "true"
292+
spec:
293+
serviceAccountName: $SERVICE_ACCOUNT_NAME
294+
containers:
295+
- image: ghcr.io/azure/azure-workload-identity/msal-go
296+
name: oidc
297+
env:
298+
- name: KEYVAULT_URL
299+
value: $KVUrl
300+
- name: SECRET_NAME
301+
value: $KVSecretName
302+
nodeSelector:
303+
kubernetes.io/os: linux
304+
"@
305+
306+
# Replace variables within the YAML content
307+
$yaml = $yaml -replace '\$SERVICE_ACCOUNT_NAMESPACE', $SERVICE_ACCOUNT_NAMESPACE `
308+
-replace '\$SERVICE_ACCOUNT_NAME', $SERVICE_ACCOUNT_NAME `
309+
-replace '\$KVUrl', $KVUrl `
310+
-replace '\$KVSecretName', $KVSecretName
311+
312+
# Apply the YAML configuration
313+
$yaml | kubectl --kubeconfig $aks_cluster_name apply -f -
314+
```
316315

317316
## Next steps
318317

0 commit comments

Comments
 (0)