Skip to content

Commit b69a958

Browse files
committed
[CLOUD-769] Improve guide on AKS setup
1 parent 8005b57 commit b69a958

File tree

1 file changed

+116
-44
lines changed

1 file changed

+116
-44
lines changed

docs/setup_installation/azure/getting_started.md

+116-44
Original file line numberDiff line numberDiff line change
@@ -24,78 +24,137 @@ 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`
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+
sleep 30 # give Azure some time to persist the new role
96+
97+
az role assignment create --role hopsfs-storage-permissions --assignee $UA_IDENTITY_PRINCIPAL_ID --scope $STORAGE_ID
98+
```
6699

67-
export storage_id=`az storage account show --name $storage_account_name --resource-group $resource_group --query "id" --output tsv`
100+
Also, assign roles to pull/push images from/to the container registry:
68101

69-
export acr_id=`az acr show --name $registry_name --resource-group $resource_group --query "id" --output tsv`
102+
```bash
103+
az role assignment create --assignee $UA_IDENTITY_PRINCIPAL_ID --role AcrPull --scope $ACR_ID
104+
az role assignment create --assignee $UA_IDENTITY_PRINCIPAL_ID --role "AcrPush" --scope $ACR_ID
105+
az role assignment create --assignee $UA_IDENTITY_PRINCIPAL_ID --role "AcrDelete" --scope $ACR_ID
70106
```
71107

72-
### Step 1.5: Assign Roles to Managed Identity
108+
### Step 1.5: Create Service Principal for Hopsworks services
73109

74-
```bash
75-
az role assignment create --assignee $managed_id --role "Storage Blob Data Contributor" --scope $storage_id
110+
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.
76111

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
112+
```bash
113+
export SP_PASSWORD=`az ad sp create-for-rbac --name $SP_NAME --scopes $ACR_ID --role acrpush --query "password" --output tsv`
114+
export SP_USER_NAME=`az ad sp list --display-name $SP_NAME --query "[].appId" --output tsv`
80115
```
81116

82-
### Step 1.6: Allow AKS cluster access to ACR repository.
117+
### Step 1.6: Create an AKS Kubernetes Cluster
118+
119+
Provision an AKS cluster with a number of nodes:
83120

84121
```bash
85-
az aks update --resource-group $resource_group --name $cluster_name --attach-acr $registry_name
122+
az aks create --resource-group $RESOURCE_GROUP --name $KUBERNETES_CLUSTER_NAME --network-plugin azure \
123+
--enable-cluster-autoscaler --min-count 1 --max-count 4 --node-count 3 --node-vm-size Standard_D16_v4 \
124+
--attach-acr $CONTAINER_REGISTRY_NAME \
125+
--assign-identity $UA_IDENTITY_RESOURCE_ID --assign-kubelet-identity $UA_IDENTITY_RESOURCE_ID \
126+
--enable-managed-identity --generate-ssh-keys
86127
```
87128

88129
## Step 2: Configure kubectl
89130

90131
```bash
91-
az aks get-credentials --resource-group $resource_group --name $cluster_name --file ~/my-aks-kubeconfig.yaml
132+
az aks get-credentials --resource-group $RESOURCE_GROUP --name $KUBERNETES_CLUSTER_NAME --file ~/my-aks-kubeconfig.yaml
92133
export KUBECONFIG=~/my-aks-kubeconfig.yaml
93134
kubectl config current-context
94135
```
95136

96-
## Step 3: Setup Hopsworks for Deployment
137+
## Step 3: Create Secret for the Service Principal
138+
139+
### Step 3.1: Create Hopsworks namespace
140+
141+
```bash
142+
kubectl create namespace hopsworks
143+
```
144+
145+
### Step 3.2: Create secret
97146

98-
### Step 3.1: Add the Hopsworks Helm repository
147+
```bash
148+
kubectl create secret docker-registry azregcred \
149+
--namespace hopsworks \
150+
--docker-server=$CONTAINER_REGISTRY_NAME.azurecr.io \
151+
--docker-username=$SP_USER_NAME \
152+
--docker-password=$SP_PASSWORD
153+
```
154+
155+
## Step 4: Setup Hopsworks for Deployment
156+
157+
### Step 4.1: Add the Hopsworks Helm repository
99158

100159
To obtain access to the Hopsworks helm chart repository, please obtain
101160
an evaluation/startup licence [here](https://www.hopsworks.ai/try).
@@ -108,34 +167,49 @@ helm repo add hopsworks $HOPSWORKS_REPO
108167
helm repo update hopsworks
109168
```
110169

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
170+
### Step 4.2: Create helm values file
118171

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

121-
```bash
174+
```yaml
122175
global:
123176
_hopsworks:
124177
storageClassName: null
125-
cloudProvider: "AWS"
126-
managedDockerRegistry:
178+
cloudProvider: "AZURE"
179+
managedDockerRegistery:
127180
enabled: true
128-
domain: "rchopsworksrepo.azurecr.io"
181+
domain: "CONTAINER_REGISTRY_NAME.azurecr.io"
129182
namespace: "hopsworks"
130-
131-
managedObjectStorage:
132-
enabled: true
133-
endpoint: "https://rchopsworksbucket.blob.core.windows.net"
183+
credHelper:
184+
enabled: false
185+
secretName: ""
186+
134187
minio:
135188
enabled: false
189+
190+
hopsworks:
191+
variables:
192+
docker_operations_managed_docker_secrets: &azregcred "azregcred"
193+
docker_operations_image_pull_secrets: *azregcred
194+
dockerRegistry:
195+
preset:
196+
usePullPush: false
197+
secrets:
198+
- *azregcred
199+
200+
hopsfs:
201+
objectStorage:
202+
enabled: true
203+
provider: "AZURE"
204+
azure:
205+
storage:
206+
account: "STORAGE_ACCOUNT_NAME"
207+
container: "STORAGE_ACCOUNT_CONTAINER_NAME"
208+
identityClientId: "UA_IDENTITY_CLIENT_ID"
209+
136210
```
137211

138-
## Step 4: Deploy Hopsworks
212+
## Step 5: Deploy Hopsworks
139213

140214
Deploy Hopsworks in the created namespace.
141215

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

160-
161-
162-
## Step 5: Next steps
234+
## Step 6: Next steps
163235

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

0 commit comments

Comments
 (0)