You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -22,51 +22,48 @@ An internal load balancer does not have a public IP and makes a Kubernetes servi
22
22
23
23
## Before you begin
24
24
25
-
This article assumes that you have an existing AKS cluster. If you need an AKS cluster, you can create one [using Azure CLI][aks-quickstart-cli], [Azure PowerShell][aks-quickstart-powershell], or [the Azure portal][aks-quickstart-portal].
26
-
27
-
You also need the Azure CLI version 2.0.59 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][install-azure-cli].
28
-
29
-
If you want to use an existing subnet or resource group, the AKS cluster identity needs permission to manage network resources. For information, see [Use kubenet networking with your own IP address ranges in AKS][use-kubenet] or [Configure Azure CNI networking in AKS][advanced-networking]. If you're configuring your load balancer to use an [IP address in a different subnet][different-subnet], ensure the AKS cluster identity also has read access to that subnet.
30
-
31
-
For more information on permissions, see [Delegate AKS access to other Azure resources][aks-sp].
25
+
* This article assumes that you have an existing AKS cluster. If you need an AKS cluster, you can create one using [Azure CLI][aks-quickstart-cli], [Azure PowerShell][aks-quickstart-powershell], or the [Azure portal][aks-quickstart-portal].
26
+
* You need the Azure CLI version 2.0.59 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][install-azure-cli].
27
+
* If you want to use an existing subnet or resource group, the AKS cluster identity needs permission to manage network resources. For information, see [Use kubenet networking with your own IP address ranges in AKS][use-kubenet] or [Configure Azure CNI networking in AKS][advanced-networking]. If you're configuring your load balancer to use an [IP address in a different subnet][different-subnet], ensure the AKS cluster identity also has read access to that subnet.
28
+
* For more information on permissions, see [Delegate AKS access to other Azure resources][aks-sp].
32
29
33
30
## Create an internal load balancer
34
31
35
-
To create an internal load balancer, create a service manifest named `internal-lb.yaml` with the service type *LoadBalancer* and the *azure-load-balancer-internal* annotation as shown in the following example:
2. Deploy the internal load balancer using the [`kubectl apply`][kubectl-apply] command. This command creates an Azure load balancer in the node resource group connected to the same virtual network as your AKS cluster.
57
50
58
-
This command creates an Azure load balancer in the node resource group that's connected to the same virtual network as your AKS cluster.
51
+
```azurecli-interactive
52
+
kubectl apply -f internal-lb.yaml
53
+
```
59
54
60
-
When you view the service details, the IP address of the internal load balancer is shown in the *EXTERNAL-IP* column. In this context, *External* refers to the external interface of the load balancer. It doesn't mean that it receives a public, external IP address. This IP address is dynamically assigned from the same subnet as the AKS cluster.
55
+
3. View the service details using the `kubectl get service` command.
61
56
62
-
It may take a minute or two for the IP address to change from *\<pending\>* to an actual internal IP address, as shown in the following example:
57
+
```azurecli-interactive
58
+
kubectl get service internal-app
59
+
```
63
60
64
-
```
65
-
kubectl get service internal-app
61
+
The IP address of the internal load balancer is shown in the `EXTERNAL-IP` column, as shown in the following example output. In this context, *External* refers to the external interface of the load balancer. It doesn't mean that it receives a public, external IP address. This IP address is dynamically assigned from the same subnet as the AKS cluster.
@@ -76,12 +73,14 @@ You can use the [`az network vnet subnet list`][az-network-vnet-subnet-list] Azu
76
73
77
74
For more information on subnets, see [Add a node pool with a unique subnet][unique-subnet].
78
75
79
-
If you want to use a specific IP address with the load balancer, there are two ways:
76
+
If you want to use a specific IP address with the load balancer, you have two options: **set service annotations** or **add the *LoadBalancerIP* property to the load balancer YAML manifest**.
80
77
81
78
> [!IMPORTANT]
82
79
> Adding the *LoadBalancerIP* property to the load balancer YAML manifest is deprecating following [upstream Kubernetes](https://github.com/kubernetes/kubernetes/pull/107235). While current usage remains the same and existing services are expected to work without modification, we **highly recommend setting service annotations** instead.
83
80
84
-
* **Set service annotations**: Use `service.beta.kubernetes.io/azure-load-balancer-ipv4` for an IPv4 address and `service.beta.kubernetes.io/azure-load-balancer-ipv6` for an IPv6 address.
81
+
### [Set service annotations](#tab/set-service-annotations)
82
+
83
+
1. Set service annotations using `service.beta.kubernetes.io/azure-load-balancer-ipv4` for an IPv4 address and `service.beta.kubernetes.io/azure-load-balancer-ipv6` for an IPv6 address.
85
84
86
85
```yaml
87
86
apiVersion: v1
@@ -99,7 +98,9 @@ If you want to use a specific IP address with the load balancer, there are two w
99
98
app: internal-app
100
99
```
101
100
102
-
* **Add the *LoadBalancerIP* property to the load balancer YAML manifest**: Add the *Service.Spec.LoadBalancerIP* property to the load balancer YAML manifest. This field is deprecating following [upstream Kubernetes](https://github.com/kubernetes/kubernetes/pull/107235), and it can't support dual-stack. Current usage remains the same and existing services are expected to work without modification.
101
+
### [Add the *LoadBalancerIP* property to the load balancer YAML manifest](#tab/add-load-balancer-ip-property)
102
+
103
+
1. Add the *Service.Spec.LoadBalancerIP* property to the load balancer YAML manifest. This field is deprecating following [upstream Kubernetes](https://github.com/kubernetes/kubernetes/pull/107235), and it can't support dual-stack. Current usage remains the same and existing services are expected to work without modification.
103
104
104
105
```yaml
105
106
apiVersion: v1
@@ -117,101 +118,110 @@ If you want to use a specific IP address with the load balancer, there are two w
117
118
app: internal-app
118
119
```
119
120
120
-
When you view the service details, the IP address in the *EXTERNAL-IP* column should reflect your specified IP address.
121
+
---
121
122
122
-
```
123
-
kubectl get service internal-app
123
+
2. View the service details using the `kubectl get service` command.
For more information on configuring your load balancer in a different subnet, see [Specify a different subnet][different-subnet]
130
137
131
138
## Connect Azure Private Link service to internal load balancer
132
139
133
140
### Before you begin
134
141
135
-
You must have the following resources:
136
-
137
-
* Kubernetes version 1.22.x or later.
138
-
* An existing resource group with a VNet and subnet. This resource group is where you'll [create the private endpoint](#create-a-private-endpoint-to-the-private-link-service). If you don't have these resources, see [Create a virtual network and subnet][aks-vnet-subnet].
142
+
* You need Kubernetes version 1.22.x or later.
143
+
* You need an existing resource group with a VNet and subnet. This resource group is where you [create the private endpoint](#create-a-private-endpoint-to-the-private-link-service). If you don't have these resources, see [Create a virtual network and subnet][aks-vnet-subnet].
139
144
140
145
### Create a Private Link service connection
141
146
142
-
To attach an Azure Private Link service to an internal load balancer, create a service manifest named `internal-lb-pls.yaml` with the service type *LoadBalancer* and the *azure-load-balancer-internal* and *azure-pls-create* annotation as shown in the following example. For more options, refer to the [Azure Private Link Service Integration](https://kubernetes-sigs.github.io/cloud-provider-azure/topics/pls-integration/) design document.
Deploy the internal load balancer using [`kubectl apply`][kubectl-apply] and specify the name of your YAML manifest.
161
-
162
-
```console
163
-
kubectl apply -f internal-lb-pls.yaml
164
-
```
165
-
166
-
This command creates an Azure load balancer in the node resource group that's connected to the same virtual network as your AKS cluster.
147
+
1. Create a service manifest named `internal-lb-pls.yaml` with the service type `LoadBalancer` and the `azure-load-balancer-internal` and `azure-pls-create` annotations. For more options, refer to the [Azure Private Link Service Integration](https://kubernetes-sigs.github.io/cloud-provider-azure/topics/pls-integration/) design document.
167
148
168
-
When you view the service details, the IP address of the internal load balancer is shown in the *EXTERNAL-IP* column. In this context, *External* refers to the external interface of the load balancer. It doesn't mean that it receives a public, external IP address.
It may take a minute or two for the IP address to change from *\<pending\>* to an actual internal IP address, as shown in the following example:
165
+
2. Deploy the internal load balancer using the [`kubectl apply`][kubectl-apply] command. This command creates an Azure load balancer in the node resource group connected to the same virtual network as your AKS cluster and a Private Link Service object that connects to the frontend IP configuration of the load balancer associated with the Kubernetes service.
3. View the service details using the `kubectl get service` command.
178
172
179
-
A Private Link Service object is also created. This Private Link Service object connects to the frontend IP configuration of the load balancer associated with the Kubernetes service. You can get the details of the Private Link Service object with the following sample command:
173
+
```azurecli-interactive
174
+
kubectl get service internal-app
175
+
```
180
176
181
-
```azurecli-interactive
182
-
# Create a variable for the resource group
177
+
The IP address of the internal load balancer is shown in the `EXTERNAL-IP` column, as shown in the following example output. In this context, *External* refers to the external interface of the load balancer. It doesn't mean that it receives a public, external IP address.
183
178
184
-
AKS_MC_RG=$(az aks show -g myResourceGroup --name myAKSCluster --query nodeResourceGroup -o tsv)
4. View the details of the Private Link Service object using the [`az network private-link-service list`][az-network-private-link-service-list] command.
187
185
188
-
az network private-link-service list -g $AKS_MC_RG --query "[].{Name:name,Alias:alias}" -o table
186
+
```azurecli-interactive
187
+
# Create a variable for the node resource group
188
+
189
+
AKS_MC_RG=$(az aks show -g myResourceGroup --name myAKSCluster --query nodeResourceGroup -o tsv)
190
+
191
+
# View the details of the Private Link Service object
192
+
193
+
az network private-link-service list -g $AKS_MC_RG --query "[].{Name:name,Alias:alias}" -o table
### Create a Private Endpoint to the Private Link service
197
205
198
-
A Private Endpoint allows you to privately connect to your Kubernetes service object via the Private Link Service you created. To do so, follow the sample commands.
199
-
200
-
```azurecli-interactive
201
-
# Create a variable for the private link service
202
-
203
-
AKS_PLS_ID=$(az network private-link-service list -g $AKS_MC_RG --query "[].id" -o tsv)
204
-
205
-
# Create the private endpoint
206
-
207
-
$ az network private-endpoint create \
208
-
-g myOtherResourceGroup \
209
-
--name myAKSServicePE \
210
-
--vnet-name myOtherVNET \
211
-
--subnet pe-subnet \
212
-
--private-connection-resource-id $AKS_PLS_ID \
213
-
--connection-name connectToMyK8sService
214
-
```
206
+
A Private Endpoint allows you to privately connect to your Kubernetes service object via the Private Link Service you created.
207
+
208
+
* Create the private endpoint using the [`az network private-endpoint create`][az-network-private-endpoint-create] command.
209
+
210
+
```azurecli-interactive
211
+
# Create a variable for the private link service
212
+
213
+
AKS_PLS_ID=$(az network private-link-service list -g $AKS_MC_RG --query "[].id" -o tsv)
214
+
215
+
# Create the private endpoint
216
+
217
+
$ az network private-endpoint create \
218
+
-g myOtherResourceGroup \
219
+
--name myAKSServicePE \
220
+
--vnet-name myOtherVNET \
221
+
--subnet pe-subnet \
222
+
--private-connection-resource-id $AKS_PLS_ID \
223
+
--connection-name connectToMyK8sService
224
+
```
215
225
216
226
## Use private networks
217
227
@@ -221,36 +231,35 @@ For more information, see [configure your own virtual network subnets with Kuben
221
231
222
232
You don't need to make any changes to the previous steps to deploy an internal load balancer that uses a private network in an AKS cluster. The load balancer is created in the same resource group as your AKS cluster, but it's instead connected to your private virtual network and subnet, as shown in the following example:
> You may need to assign a minimum of *Microsoft.Network/virtualNetworks/subnets/read* and *Microsoft.Network/virtualNetworks/subnets/join/action* permission to AKS MSI on the Azure Virtual Network resources. You can view the cluster identity with [az aks show][az-aks-show], such as `az aks show --resource-group myResourceGroup --name myAKSCluster --query "identity"`. To create a role assignment, use the [az role assignment create][az-role-assignment-create] command.
242
+
> You may need to assign a minimum of *Microsoft.Network/virtualNetworks/subnets/read* and *Microsoft.Network/virtualNetworks/subnets/join/action* permission to AKS MSI on the Azure Virtual Network resources. You can view the cluster identity with [az aks show][az-aks-show], such as `az aks show --resource-group myResourceGroup --name myAKSCluster --query "identity"`. To create a role assignment, use the [`az role assignment create`][az-role-assignment-create] command.
234
243
235
244
### Specify a different subnet
236
245
237
-
Add the *azure-load-balancer-internal-subnet* annotation to your service to specify a subnet for your load balancer. The subnet specified must be in the same virtual network as your AKS cluster. When deployed, the load balancer *EXTERNAL-IP* address is part of the specified subnet.
* Add the `azure-load-balancer-internal-subnet` annotation to your service to specify a subnet for your load balancer. The subnet specified must be in the same virtual network as your AKS cluster. When deployed, the load balancer `EXTERNAL-IP` address is part of the specified subnet.
0 commit comments