Skip to content

Commit 1ffff9f

Browse files
authored
[CLOUD-769] Improve guide on AKS setup (#451)
* [CLOUD-769] Improve guide on AKS setup * Address comments * Add AcrDelete role
1 parent fdbf397 commit 1ffff9f

File tree

1 file changed

+110
-45
lines changed

1 file changed

+110
-45
lines changed

docs/setup_installation/azure/getting_started.md

+110-45
Original file line numberDiff line numberDiff line change
@@ -24,78 +24,130 @@ To run all the commands on this page the user needs to have at least the followi
2424

2525
You will also need to have a role such as *Application Administrator* on the Azure Active Directory to be able to create the hopsworks.ai service principal.
2626

27-
## Step 1: Azure AKS Setup
27+
## Step 1: Azure Kubernetes Service (AKS) Setup
2828

2929
### Step 1.1: Create an Azure Blob Storage Account
3030

3131
Create a storage account to host project data. Ensure that the storage account is in the same region as the AKS cluster for performance and cost reasons:
3232

3333
```bash
34-
az storage account create --name $storage_account_name --resource-group $resource_group --location $region
34+
az storage account create --name $STORAGE_ACCOUNT_NAME --resource-group $RESOURCE_GROUP --location $REGION
3535
```
3636

37-
Also create a corresponding container:
37+
Also, create the corresponding container:
3838

3939
```bash
40-
az storage container create --account-name $storage_account_name --name $container_name
40+
az storage container create --account-name $STORAGE_ACCOUNT_NAME --name $CONTAINER_NAME
4141
```
4242

43-
4443
### Step 1.2: Create an Azure Container Registry (ACR)
4544

4645
Create an ACR to store the images used by Hopsworks:
4746

4847
```bash
49-
az acr create --resource-group $resource_group --name $registry_name --sku Basic --location $region
48+
az acr create --resource-group $RESOURCE_GROUP --name $CONTAINER_REGISTRY_NAME --sku Basic --location $REGION
49+
50+
export ACR_ID=`az acr show --name $CONTAINER_REGISTRY_NAME --resource-group $RESOURCE_GROUP --query "id" --output tsv`
5051
```
5152

52-
### Step 1.3: Create an AKS Kubernetes Cluster
53+
### Step 1.3: Create a User-Assigned Managed Identity
5354

54-
Provision an AKS cluster with a number of nodes:
55+
Create a user-assigned managed identity to grant AKS access to the storage account and container registry:
5556

5657
```bash
57-
az aks create --resource-group $resource_group --name $cluster_name --enable-cluster-autoscaler --min-count 1 --max-count 4 --node-count 3 --node-vm-size Standard_D16_v4 --network-plugin azure --enable-managed-identity --generate-ssh-keys
58+
az identity create --name $UA_IDENTITY_NAME --resource-group $RESOURCE_GROUP
59+
60+
export UA_IDENTITY_PRINCIPAL_ID=`az identity show --name $UA_IDENTITY_NAME --resource-group $RESOURCE_GROUP --query principalId --output tsv`
61+
export UA_IDENTITY_CLIENT_ID=`az identity show --name $UA_IDENTITY_NAME --resource-group $RESOURCE_GROUP --query clientId --output tsv`
62+
export UA_IDENTITY_RESOURCE_ID=`az identity show --name $UA_IDENTITY_NAME --resource-group $RESOURCE_GROUP --query id --output tsv`
5863
```
5964

60-
### Step 1.4: Retrieve setup Identifiers
65+
### Step 1.4: Grant permissions to the User-Assigned Managed Identity
6166

62-
Create a set of environment variables for use in later steps.
67+
Create a custom role definition with the minimum permissions needed to read and write to the storage account:
6368

6469
```bash
65-
export managed_id=`az aks show --resource-group $resource_group --name $cluster_name --query "identity.principalId" --output tsv`
66-
67-
export storage_id=`az storage account show --name $storage_account_name --resource-group $resource_group --query "id" --output tsv`
68-
69-
export acr_id=`az acr show --name $registry_name --resource-group $resource_group --query "id" --output tsv`
70+
export STORAGE_ID=`az storage account show --name $STORAGE_ACCOUNT_NAME --resource-group $RESOURCE_GROUP --query "id" --output tsv`
71+
72+
az role definition create --role-definition '{
73+
"Name": "hopsfs-storage-permissions",
74+
"IsCustom": true,
75+
"Description": "Allow HopsFS to access the storage container",
76+
"Actions": [
77+
"Microsoft.Storage/storageAccounts/blobServices/containers/write",
78+
"Microsoft.Storage/storageAccounts/blobServices/containers/read",
79+
"Microsoft.Storage/storageAccounts/blobServices/write",
80+
"Microsoft.Storage/storageAccounts/blobServices/read",
81+
"Microsoft.Storage/storageAccounts/listKeys/action"
82+
],
83+
"NotActions": [],
84+
"DataActions": [
85+
"Microsoft.Storage/storageAccounts/blobServices/containers/blobs/delete",
86+
"Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read",
87+
"Microsoft.Storage/storageAccounts/blobServices/containers/blobs/move/action",
88+
"Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write"
89+
],
90+
"AssignableScopes": [
91+
"'$STORAGE_ID'"
92+
]
93+
}'
94+
95+
az role assignment create --role hopsfs-storage-permissions --assignee-object-id $UA_IDENTITY_PRINCIPAL_ID --assignee-principal-type ServicePrincipal --scope $STORAGE_ID
7096
```
7197

72-
### Step 1.5: Assign Roles to Managed Identity
98+
### Step 1.5: Create Service Principal for Hopsworks services
99+
100+
Create a service principal to grant Hopsworks applications with access to the container registry. For example, Hopsworks uses this service principal to push new Python environments created via the Hopsworks UI.
73101

74102
```bash
75-
az role assignment create --assignee $managed_id --role "Storage Blob Data Contributor" --scope $storage_id
103+
export SP_PASSWORD=`az ad sp create-for-rbac --name $SP_NAME --scopes $ACR_ID --role AcrPush --years 1 --query "password" --output tsv`
104+
export SP_USER_NAME=`az ad sp list --display-name $SP_NAME --query "[].appId" --output tsv`
105+
export SP_RESOURCE_ID=`az ad sp list --display-name $SP_NAME --query "[].id" --output tsv`
76106

77-
az role assignment create --assignee $managed_id --role AcrPull --scope $acr_id
78-
az role assignment create --assignee $managed_id --role "AcrPush" --scope $acr_id
79-
az role assignment create --assignee $managed_id --role "AcrDelete" --scope $acr_id
107+
az role assignment create --role AcrDelete --assignee-object-id $SP_RESOURCE_ID --assignee-principal-type ServicePrincipal --scope $ACR_ID
80108
```
81109

82-
### Step 1.6: Allow AKS cluster access to ACR repository.
110+
### Step 1.6: Create an AKS Kubernetes Cluster
111+
112+
Provision an AKS cluster with a number of nodes:
83113

84114
```bash
85-
az aks update --resource-group $resource_group --name $cluster_name --attach-acr $registry_name
115+
az aks create --resource-group $RESOURCE_GROUP --name $KUBERNETES_CLUSTER_NAME --network-plugin azure \
116+
--enable-cluster-autoscaler --min-count 1 --max-count 4 --node-count 3 --node-vm-size Standard_D8_v4 \
117+
--attach-acr $CONTAINER_REGISTRY_NAME \
118+
--assign-identity $UA_IDENTITY_RESOURCE_ID --assign-kubelet-identity $UA_IDENTITY_RESOURCE_ID \
119+
--enable-managed-identity --generate-ssh-keys
86120
```
87121

88122
## Step 2: Configure kubectl
89123

90124
```bash
91-
az aks get-credentials --resource-group $resource_group --name $cluster_name --file ~/my-aks-kubeconfig.yaml
125+
az aks get-credentials --resource-group $RESOURCE_GROUP --name $KUBERNETES_CLUSTER_NAME --file ~/my-aks-kubeconfig.yaml
92126
export KUBECONFIG=~/my-aks-kubeconfig.yaml
93127
kubectl config current-context
94128
```
95129

96-
## Step 3: Setup Hopsworks for Deployment
130+
## Step 3: Create Secret for the Service Principal
131+
132+
### Step 3.1: Create Hopsworks namespace
133+
134+
```bash
135+
kubectl create namespace hopsworks
136+
```
97137

98-
### Step 3.1: Add the Hopsworks Helm repository
138+
### Step 3.2: Create secret
139+
140+
```bash
141+
kubectl create secret docker-registry azregcred \
142+
--namespace hopsworks \
143+
--docker-server=$CONTAINER_REGISTRY_NAME.azurecr.io \
144+
--docker-username=$SP_USER_NAME \
145+
--docker-password=$SP_PASSWORD
146+
```
147+
148+
## Step 4: Setup Hopsworks for Deployment
149+
150+
### Step 4.1: Add the Hopsworks Helm repository
99151

100152
To obtain access to the Hopsworks helm chart repository, please obtain
101153
an evaluation/startup licence [here](https://www.hopsworks.ai/try).
@@ -108,34 +160,49 @@ helm repo add hopsworks $HOPSWORKS_REPO
108160
helm repo update hopsworks
109161
```
110162

111-
### Step 3.2: Create Hopsworks namespace
112-
113-
```bash
114-
kubectl create namespace hopsworks
115-
```
116-
117-
### Step 3.3: Create helm values file
163+
### Step 4.2: Create helm values file
118164

119165
Below is a simplifield values.azure.yaml file to get started which can be updated for improved performance and further customisation.
120166

121-
```bash
167+
```yaml
122168
global:
123169
_hopsworks:
124170
storageClassName: null
125-
cloudProvider: "AWS"
126-
managedDockerRegistry:
171+
cloudProvider: "AZURE"
172+
managedDockerRegistery:
127173
enabled: true
128-
domain: "rchopsworksrepo.azurecr.io"
174+
domain: "CONTAINER_REGISTRY_NAME.azurecr.io"
129175
namespace: "hopsworks"
130-
131-
managedObjectStorage:
132-
enabled: true
133-
endpoint: "https://rchopsworksbucket.blob.core.windows.net"
176+
credHelper:
177+
enabled: false
178+
secretName: ""
179+
134180
minio:
135181
enabled: false
182+
183+
hopsworks:
184+
variables:
185+
docker_operations_managed_docker_secrets: &azregcred "azregcred"
186+
docker_operations_image_pull_secrets: *azregcred
187+
dockerRegistry:
188+
preset:
189+
usePullPush: false
190+
secrets:
191+
- *azregcred
192+
193+
hopsfs:
194+
objectStorage:
195+
enabled: true
196+
provider: "AZURE"
197+
azure:
198+
storage:
199+
account: "STORAGE_ACCOUNT_NAME"
200+
container: "STORAGE_ACCOUNT_CONTAINER_NAME"
201+
identityClientId: "UA_IDENTITY_CLIENT_ID"
202+
136203
```
137204

138-
## Step 4: Deploy Hopsworks
205+
## Step 5: Deploy Hopsworks
139206

140207
Deploy Hopsworks in the created namespace.
141208

@@ -157,9 +224,7 @@ Upon completion (circa 20 minutes), setup a load balancer to access Hopsworks:
157224
kubectl expose deployment hopsworks --type=LoadBalancer --name=hopsworks-service --namespace <namespace>
158225
```
159226

160-
161-
162-
## Step 5: Next steps
227+
## Step 6: Next steps
163228

164229
Check out our other guides for how to get started with Hopsworks and the Feature Store:
165230

0 commit comments

Comments
 (0)