Skip to content

Commit 748cca0

Browse files
Merge pull request #234109 from cynthn/patch-77
[Doc-a-thon] Update tutorial-kubernetes-workload-identity.md
2 parents a357c08 + 61ddaff commit 748cca0

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

articles/aks/learn/tutorial-kubernetes-workload-identity.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ The following output example resembles successful creation of the resource group
6767

6868
To install the aks-preview extension, run the following command:
6969

70-
```azurecli
70+
```azurecli-interactive
7171
az extension add --name aks-preview
7272
```
7373

7474
Run the following command to update to the latest version of the extension released:
7575

76-
```azurecli
76+
```azurecli-interactive
7777
az extension update --name aks-preview
7878
```
7979

@@ -112,7 +112,7 @@ After a few minutes, the command completes and returns JSON-formatted informatio
112112
113113
To get the OIDC Issuer URL and save it to an environmental variable, run the following command. Replace the default value for the arguments `-n`, which is the name of the cluster and `-g`, the resource group name:
114114

115-
```bash
115+
```azurecli-interactive
116116
export AKS_OIDC_ISSUER="$(az aks show -n myAKSCluster -g myResourceGroup --query "oidcIssuerProfile.issuerUrl" -otsv)"
117117
```
118118

@@ -146,7 +146,7 @@ export FICID="fic-test-fic-name"
146146

147147
Use the Azure CLI [az keyvault create][az-keyvault-create] command to create a Key Vault in the resource group created earlier.
148148

149-
```azurecli
149+
```azurecli-interactive
150150
az keyvault create --resource-group "${RESOURCE_GROUP}" --location "${LOCATION}" --name "${KEYVAULT_NAME}"
151151
```
152152

@@ -159,7 +159,7 @@ At this point, your Azure account is the only one authorized to perform any oper
159159

160160
To add a secret to the vault, you need to run the Azure CLI [az keyvault secret set][az-keyvault-secret-set] command to create it. The password is the value you specified for the environment variable `KEYVAULT_SECRET_NAME` and stores the value of **Hello!** in it.
161161

162-
```azurecli
162+
```azurecli-interactive
163163
az keyvault secret set --vault-name "${KEYVAULT_NAME}" --name "${KEYVAULT_SECRET_NAME}" --value 'Hello!'
164164
```
165165

@@ -173,29 +173,29 @@ export KEYVAULT_URL="$(az keyvault show -g ${RESOURCE_GROUP} -n ${KEYVAULT_NAME}
173173

174174
Use the Azure CLI [az account set][az-account-set] command to set a specific subscription to be the current active subscription. Then use the [az identity create][az-identity-create] command to create a managed identity.
175175

176-
```azurecli
176+
```azurecli-interactive
177177
az account set --subscription "${SUBSCRIPTION}"
178178
```
179179

180-
```azurecli
180+
```azurecli-interactive
181181
az identity create --name "${UAID}" --resource-group "${RESOURCE_GROUP}" --location "${LOCATION}" --subscription "${SUBSCRIPTION}"
182182
```
183183

184184
Next, you need to set an access policy for the managed identity to access the Key Vault secret by running the following commands:
185185

186-
```bash
186+
```azurecli-interactive
187187
export USER_ASSIGNED_CLIENT_ID="$(az identity show --resource-group "${RESOURCE_GROUP}" --name "${UAID}" --query 'clientId' -otsv)"
188188
```
189189

190-
```azurecli
190+
```azurecli-interactive
191191
az keyvault set-policy --name "${KEYVAULT_NAME}" --secret-permissions get --spn "${USER_ASSIGNED_CLIENT_ID}"
192192
```
193193

194194
### Create Kubernetes service account
195195

196196
Create a Kubernetes service account and annotate it with the client ID of the Managed Identity created in the previous step. Use the [az aks get-credentials][az-aks-get-credentials] command and replace the default value for the cluster name and the resource group name.
197197

198-
```azurecli
198+
```azurecli-interactive
199199
az aks get-credentials -n myAKSCluster -g "${RESOURCE_GROUP}"
200200
```
201201

@@ -225,7 +225,7 @@ Serviceaccount/workload-identity-sa created
225225

226226
Use the [az identity federated-credential create][az-identity-federated-credential-create] command to create the federated identity credential between the managed identity, the service account issuer, and the subject.
227227

228-
```azurecli
228+
```azurecli-interactive
229229
az identity federated-credential create --name ${FICID} --identity-name ${UAID} --resource-group ${RESOURCE_GROUP} --issuer ${AKS_OIDC_ISSUER} --subject system:serviceaccount:${SERVICE_ACCOUNT_NAMESPACE}:${SERVICE_ACCOUNT_NAME}
230230
```
231231

@@ -300,7 +300,7 @@ kubectl delete pod quick-start
300300
kubectl delete sa "${SERVICE_ACCOUNT_NAME}" --namespace "${SERVICE_ACCOUNT_NAMESPACE}"
301301
```
302302

303-
```azurecli
303+
```azurecli-interactive
304304
az group delete --name "${RESOURCE_GROUP}"
305305
```
306306

0 commit comments

Comments
 (0)