Skip to content

Commit e522de3

Browse files
committed
[AKS] update static IP for standard load balanacer
1 parent e812008 commit e522de3

File tree

1 file changed

+21
-48
lines changed

1 file changed

+21
-48
lines changed

articles/aks/static-ip.md

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: mlearned
66

77
ms.service: container-service
88
ms.topic: article
9-
ms.date: 03/04/2019
9+
ms.date: 11/06/2019
1010
ms.author: mlearned
1111

1212
#Customer intent: As a cluster operator or developer, I want to create and manage static IP address resources in Azure that I can use beyond the lifecycle of an individual Kubernetes service deployed in an AKS cluster.
@@ -24,88 +24,55 @@ This article assumes that you have an existing AKS cluster. If you need an AKS c
2424

2525
You also need the Azure CLI version 2.0.59 or later installed and configured. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][install-azure-cli].
2626

27-
Currently only *Basic IP SKU*is supported. Work is in progress to support the *Standard IP* resource SKU. For more information, see [IP address types and allocation methods in Azure][ip-sku].
27+
This article covers using a *Standard* SKU IP with a *Standard* SKU load balancer. For more information, see [IP address types and allocation methods in Azure][ip-sku].
2828

2929
## Create a static IP address
3030

31-
When you create a static public IP address for use with AKS, the IP address resource should be created in the **node** resource group. If you want to separate the resources, see the following section to [Use a static IP address outside of the node resource group](#use-a-static-ip-address-outside-of-the-node-resource-group).
32-
33-
First, get the node resource group name with the [az aks show][az-aks-show] command and add the `--query nodeResourceGroup` query parameter. The following example gets the node resource group for the AKS cluster name *myAKSCluster* in the resource group name *myResourceGroup*:
34-
35-
```azurecli-interactive
36-
$ az aks show --resource-group myResourceGroup --name myAKSCluster --query nodeResourceGroup -o tsv
37-
38-
MC_myResourceGroup_myAKSCluster_eastus
39-
```
40-
41-
Now create a static public IP address with the [az network public ip create][az-network-public-ip-create] command. Specify the node resource group name obtained in the previous command, and then a name for the IP address resource, such as *myAKSPublicIP*:
31+
Create a static public IP address with the [az network public ip create][az-network-public-ip-create] command. The following creates a static IP resource named *myAKSPublicIP* in the *myResourceGroup* resource group:
4232

4333
```azurecli-interactive
4434
az network public-ip create \
45-
--resource-group MC_myResourceGroup_myAKSCluster_eastus \
35+
--resource-group myResourceGroup \
4636
--name myAKSPublicIP \
37+
--sku Standard \
4738
--allocation-method static
4839
```
4940

41+
> [!NOTE]
42+
> If you are using a *Basic* SKU load balancer in your AKS cluster, use *Basic* for the *sku* parameter when defining a public IP. Only *Basic* SKU IPs work with the *Basic* SKU load balancer and only *Standard* SKU IPs work with *Standard* SKU load balancers.
43+
5044
The IP address is displayed, as shown in the following condensed example output:
5145

5246
```json
5347
{
5448
"publicIp": {
55-
"dnsSettings": null,
56-
"etag": "W/\"6b6fb15c-5281-4f64-b332-8f68f46e1358\"",
57-
"id": "/subscriptions/<SubscriptionID>/resourceGroups/MC_myResourceGroup_myAKSCluster_eastus/providers/Microsoft.Network/publicIPAddresses/myAKSPublicIP",
58-
"idleTimeoutInMinutes": 4,
49+
...
5950
"ipAddress": "40.121.183.52",
60-
[...]
51+
...
6152
}
6253
}
6354
```
6455

6556
You can later get the public IP address using the [az network public-ip list][az-network-public-ip-list] command. Specify the name of the node resource group and public IP address you created, and query for the *ipAddress* as shown in the following example:
6657

6758
```azurecli-interactive
68-
$ az network public-ip show --resource-group MC_myResourceGroup_myAKSCluster_eastus --name myAKSPublicIP --query ipAddress --output tsv
59+
$ az network public-ip show --resource-group myResourceGroup --name myAKSPublicIP --query ipAddress --output tsv
6960
7061
40.121.183.52
7162
```
7263

7364
## Create a service using the static IP address
7465

75-
To create a service with the static public IP address, add the `loadBalancerIP` property and the value of the static public IP address to the YAML manifest. Create a file named `load-balancer-service.yaml` and copy in the following YAML. Provide your own public IP address created in the previous step.
76-
77-
```yaml
78-
apiVersion: v1
79-
kind: Service
80-
metadata:
81-
name: azure-load-balancer
82-
spec:
83-
loadBalancerIP: 40.121.183.52
84-
type: LoadBalancer
85-
ports:
86-
- port: 80
87-
selector:
88-
app: azure-load-balancer
89-
```
90-
91-
Create the service and deployment with the `kubectl apply` command.
92-
93-
```console
94-
kubectl apply -f load-balancer-service.yaml
95-
```
96-
97-
## Use a static IP address outside of the node resource group
98-
99-
With Kubernetes 1.10 or later, you can use a static IP address that is created outside the node resource group. The service principal used by the AKS cluster must have delegated permissions to the other resource group, as shown in the following example:
66+
Before creating a service, ensure the service principal used by the AKS cluster has delegated permissions to the other resource group. For example:
10067

10168
```azurecli-interactive
102-
az role assignment create\
69+
az role assignment create \
10370
--assignee <SP Client ID> \
104-
--role "Network Contributor" \
71+
--role "Contributor" \
10572
--scope /subscriptions/<subscription id>/resourceGroups/<resource group name>
10673
```
10774

108-
To use an IP address outside the node resource group, add an annotation to the Service definition. The following example sets the annotation to the resource group named *myResourceGroup*. Provide your own resource group name:
75+
To create a *LoadBalancer* service with the static public IP address, add the `loadBalancerIP` property and the value of the static public IP address to the YAML manifest. Create a file named `load-balancer-service.yaml` and copy in the following YAML. Provide your own public IP address created in the previous step. The following example also sets the annotation to the resource group named *myResourceGroup*. Provide your own resource group name.
10976

11077
```yaml
11178
apiVersion: v1
@@ -123,6 +90,12 @@ spec:
12390
app: azure-load-balancer
12491
```
12592
93+
Create the service and deployment with the `kubectl apply` command.
94+
95+
```console
96+
kubectl apply -f load-balancer-service.yaml
97+
```
98+
12699
## Troubleshoot
127100

128101
If the static IP address defined in the *loadBalancerIP* property of the Kubernetes service manifest does not exist, or has not been created in the node resource group and no additional delegations configured, the load balancer service creation fails. To troubleshoot, review the service creation events with the [kubectl describe][kubectl-describe] command. Provide the name of the service as specified in the YAML manifest, as shown in the following example:

0 commit comments

Comments
 (0)