Skip to content

Commit a516f56

Browse files
committed
update workflow
1 parent 3ba3130 commit a516f56

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
run: |
5050
KUBELET_ID=$(az aks show \
5151
-g "${{ env.RESOURCE_GROUP }}" \
52-
-n "aks-${{ env.CLUSTER_NAME }}" \
52+
-n "${{ env.CLUSTER_NAME }}" \
5353
--query identityProfile.kubeletidentity.objectId -o tsv)
5454
5555
ACR_ID=$(az acr show \

README.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,31 @@ Here is an example using User Assigned Managed Identity
5757

5858
```bash
5959
MI_NAME="github-actions-identity"
60-
RESOURCE_GROUP="rg-pvt-aks-h100"
60+
RESOURCE_GROUP_MI="rg-github-actions-identity"
6161
LOCATION="eastus2"
6262
REGISTRY_NAME="gbbpvt"
6363

64+
# Managed ID resource group
6465
az group create \
65-
--name "$RESOURCE_GROUP" \
66+
--name "$RESOURCE_GROUP_MI" \
6667
--location "$LOCATION"
6768

6869
az identity create \
6970
--name "$MI_NAME" \
70-
--resource-group "$RESOURCE_GROUP" \
71+
--resource-group "$RESOURCE_GROUP_MI" \
72+
--location "$LOCATION"
73+
74+
# deployment resource group
75+
RESOURCE_GROUP="rg-pvt-aks-h100"
76+
az group create \
77+
--name "$RESOURCE_GROUP" \
7178
--location "$LOCATION"
7279
```
7380

7481
Save these values:
7582

7683
```bash
77-
CLIENT_ID=$(az identity show -g "$RESOURCE_GROUP" -n "$MI_NAME" --query clientId -o tsv)
84+
CLIENT_ID=$(az identity show -g "$RESOURCE_GROUP_MI" -n "$MI_NAME" --query clientId -o tsv)
7885
SUBSCRIPTION_ID=$(az account show --query id -o tsv)
7986
TENANT_ID=$(az account show --query tenantId -o tsv)
8087
@@ -88,15 +95,16 @@ Here is an example using User Assigned Managed Identity
8895
Grant `Contributor` or a scoped role like `acrpull` if only pulling from ACR:
8996

9097
```bash
91-
MI_PRINCIPAL_ID=$(az identity show -g "$RESOURCE_GROUP" -n "$MI_NAME" --query principalId -o tsv)
92-
ACR_ID=$(az acr show -n "$REGISTRY_NAME" -g "$RESOURCE_GROUP" --query id -o tsv)
98+
MI_PRINCIPAL_ID=$(az identity show -g "$RESOURCE_GROUP_MI" -n "$MI_NAME" --query principalId -o tsv)
9399
94100
# Assign "Contributor" to the MI
95101
az role assignment create \
96102
--assignee-object-id "$MI_PRINCIPAL_ID" \
97103
--role Contributor \
98104
--scope /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP
99105
106+
ACR_ID=$(az acr show -n "$REGISTRY_NAME" -g "$RESOURCE_GROUP" --query id -o tsv)
107+
100108
# Assign "User Access Administrator" to allow role assignments
101109
az role assignment create \
102110
--assignee-object-id "$MI_PRINCIPAL_ID" \
@@ -106,15 +114,17 @@ Here is an example using User Assigned Managed Identity
106114

107115
1. Configure Federated Identity Credential for GitHub
108116

109-
Replace `<GITHUB_ORG>` and `<REPO>` accordingly:
117+
Replace `GITHUB_ORG` and `REPO` accordingly:
110118

111119
```bash
120+
GITHUB_ORG="appdevgbb"
121+
REPO="pattern-private-aks-gpu"
112122
az identity federated-credential create \
113123
--name github-actions \
114124
--identity-name "$MI_NAME" \
115-
--resource-group "$RESOURCE_GROUP" \
125+
--resource-group "$RESOURCE_GROUP_MI" \
116126
--issuer "https://token.actions.githubusercontent.com" \
117-
--subject "repo:<GITHUB_ORG>/<REPO>:ref:refs/heads/main" \
127+
--subject "repo:$GITHUB_ORG/$REPO:ref:refs/heads/main" \
118128
--audiences "api://AzureADTokenExchange"
119129
```
120130

@@ -138,12 +148,10 @@ Here is an example using User Assigned Managed Identity
138148
EOF
139149
```
140150
141-
# Set variables
142-
RESOURCE_GROUP="rg-pvt-aks-h100"
143-
MI_NAME="github-actions-identity"
151+
144152
145153
# Get identity info
146-
CLIENT_ID=$(az identity show -g "$RESOURCE_GROUP" -n "$MI_NAME" --query clientId -o tsv)
154+
CLIENT_ID=$(az identity show -g "$RESOURCE_GROUP_MI" -n "$MI_NAME" --query clientId -o tsv)
147155
TENANT_ID=$(az account show --query tenantId -o tsv)
148156
SUBSCRIPTION_ID=$(az account show --query id -o tsv)
149157

0 commit comments

Comments
 (0)