Skip to content

Commit 6f1c888

Browse files
authored
Merge pull request #190774 from Blackmist/1925309-vnet-private-aks
adding info on creating/attaching aks w/internal load balancer
2 parents f8228e6 + 554a82d commit 6f1c888

File tree

2 files changed

+61
-41
lines changed

2 files changed

+61
-41
lines changed

articles/machine-learning/how-to-create-attach-kubernetes.md

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ ms.service: machine-learning
77
ms.subservice: core
88
ms.topic: how-to
99
ms.custom: devx-track-azurecli
10-
ms.author: jordane
11-
author: jpe316
10+
ms.author: ssambare
11+
author: shivanissambare
1212
ms.reviewer: larryfr
1313
ms.date: 11/05/2021
1414
---
@@ -330,28 +330,59 @@ Following example shows how to enable TLS termination with custom certificate an
330330
> For more information about how to secure model deployment on AKS cluster, please see [use TLS to secure a web service through Azure Machine Learning](how-to-secure-web-service.md)
331331
332332
## Create or attach an AKS cluster to use Internal Load Balancer with private IP
333+
333334
When you create or attach an AKS cluster, you can configure the cluster to use an Internal Load Balancer. With an Internal Load Balancer, scoring endpoints for your deployments to AKS will use a private IP within the virtual network. Following code snippets show how to configure an Internal Load Balancer for an AKS cluster.
335+
336+
# [Create](#tab/akscreate)
337+
338+
To create an AKS cluster that uses an Internal Load Balancer, use the the `load_balancer_type` and `load_balancer_subnet` parameters:
339+
334340
```python
335-
336-
from azureml.core.compute.aks import AksUpdateConfiguration
337-
from azureml.core.compute import AksCompute, ComputeTarget
338-
339-
# When you create an AKS cluster, you can specify Internal Load Balancer to be created with provisioning_config object
340-
provisioning_config = AksCompute.provisioning_configuration(load_balancer_type = 'InternalLoadBalancer')
341-
342-
# when you attach an AKS cluster, you can update the cluster to use internal load balancer after attach
343-
aks_target = AksCompute(ws,"myaks")
344-
345-
# Change to the name of the subnet that contains AKS
346-
subnet_name = "default"
347-
# Update AKS configuration to use an internal load balancer
348-
update_config = AksUpdateConfiguration(None, "InternalLoadBalancer", subnet_name)
349-
aks_target.update(update_config)
350-
# Wait for the operation to complete
351-
aks_target.wait_for_completion(show_output = True)
352-
353-
341+
from azureml.core.compute.aks import AksUpdateConfiguration
342+
from azureml.core.compute import AksCompute, ComputeTarget
343+
344+
# Change to the name of the subnet that contains AKS
345+
subnet_name = "default"
346+
# When you create an AKS cluster, you can specify Internal Load Balancer to be created with provisioning_config object
347+
provisioning_config = AksCompute.provisioning_configuration(load_balancer_type = 'InternalLoadBalancer', load_balancer_subnet = subnet_name)
348+
349+
# Create the cluster
350+
aks_target = ComputeTarget.create(workspace = ws,
351+
name = aks_name,
352+
provisioning_configuration = provisioning_config)
353+
354+
# Wait for the create process to complete
355+
aks_target.wait_for_completion(show_output = True)
356+
```
357+
358+
# [Attach](#tab/aksattach)
359+
360+
To attach an AKS cluster and use an internal load balancer (no public IP for the cluster), use the `load_balancer_type` and `load_balancer_subnet` parameters:
361+
362+
```python
363+
from azureml.core.compute import AksCompute, ComputeTarget
364+
# Set the resource group that contains the AKS cluster and the cluster name
365+
resource_group = 'myresourcegroup'
366+
cluster_name = 'myexistingcluster'
367+
# Change to the name of the subnet that contains AKS
368+
subnet_name = "default"
369+
370+
# Attach the cluster to your workgroup. If the cluster has less than 12 virtual CPUs, use the following instead:
371+
# attach_config = AksCompute.attach_configuration(resource_group = resource_group,
372+
# cluster_name = cluster_name,
373+
# cluster_purpose = AksCompute.ClusterPurpose.DEV_TEST)
374+
attach_config = AksCompute.attach_configuration(resource_group = resource_group,
375+
cluster_name = cluster_name,
376+
load_balancer_type = 'InternalLoadBalancer',
377+
load_balancer_subnet = subnet_name)
378+
aks_target = ComputeTarget.attach(ws, 'myaks', attach_config)
379+
380+
# Wait for the attach process to complete
381+
aks_target.wait_for_completion(show_output = True)
354382
```
383+
384+
---
385+
355386
>[!IMPORTANT]
356387
> If your AKS cluster is configured with an Internal Load Balancer, using a Microsoft provided certificate is not supported and you must use [custom certificate to enable TLS](how-to-secure-web-service.md#deploy-on-azure-kubernetes-service).
357388
@@ -464,6 +495,12 @@ kubectl delete secret azuremlfessl
464495
kubectl delete cm azuremlfeconfig
465496
```
466497

498+
### Load balancers should not have public IPs
499+
500+
When trying to create or attach an AKS cluster, you may receive a message that the request has been denied because "Load Balancers should not have public IPs". This message is returned when an administrator has applied a policy that prevents using an AKS cluster with a public IP address.
501+
502+
To resolve this problem, create/attach the cluster by using the `load_balancer_type` and `load_balancer_subnet` parameters. For more information, see [Internal Load Balancer (private IP)](#create-or-attach-an-aks-cluster-to-use-internal-load-balancer-with-private-ip).
503+
467504
## Next steps
468505

469506
* [Use Azure RBAC for Kubernetes authorization](../aks/manage-azure-rbac.md)

articles/machine-learning/how-to-secure-inferencing-vnet.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.topic: how-to
99
ms.reviewer: larryfr
1010
ms.author: jhirono
1111
author: jhirono
12-
ms.date: 03/02/2022
12+
ms.date: 03/07/2022
1313
ms.custom: contperf-fy20q4, tracking-python, contperf-fy21q1, devx-track-azurecli
1414

1515
---
@@ -245,26 +245,9 @@ For more information, see the [az ml computetarget create aks](/cli/azure/ml(v1)
245245

246246
---
247247

248-
When __attaching an existing cluster__ to your workspace, you must wait until after the attach operation to configure the load balancer. For information on attaching a cluster, see [Attach an existing AKS cluster](how-to-create-attach-kubernetes.md).
248+
When __attaching an existing cluster__ to your workspace, use the `load_balancer_type` and `load_balancer_subnet` parameters of [AksCompute.attach_configuration()](/python/api/azureml-core/azureml.core.compute.aks.akscompute#azureml-core-compute-aks-akscompute-attach-configuration) to configure the load balancer.
249249

250-
After attaching the existing cluster, you can then update the cluster to use an internal load balancer/private IP:
251-
252-
```python
253-
import azureml.core
254-
from azureml.core.compute.aks import AksUpdateConfiguration
255-
from azureml.core.compute import AksCompute
256-
257-
# ws = workspace object. Creation not shown in this snippet
258-
aks_target = AksCompute(ws,"myaks")
259-
260-
# Change to the name of the subnet that contains AKS
261-
subnet_name = "default"
262-
# Update AKS configuration to use an internal load balancer
263-
update_config = AksUpdateConfiguration(None, "InternalLoadBalancer", subnet_name)
264-
aks_target.update(update_config)
265-
# Wait for the operation to complete
266-
aks_target.wait_for_completion(show_output = True)
267-
```
250+
For information on attaching a cluster, see [Attach an existing AKS cluster](how-to-create-attach-kubernetes.md).
268251

269252
## Enable Azure Container Instances (ACI)
270253

0 commit comments

Comments
 (0)