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
Copy file name to clipboardExpand all lines: articles/aks/static-ip.md
+21-48Lines changed: 21 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ author: mlearned
6
6
7
7
ms.service: container-service
8
8
ms.topic: article
9
-
ms.date: 03/04/2019
9
+
ms.date: 11/06/2019
10
10
ms.author: mlearned
11
11
12
12
#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
24
24
25
25
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].
26
26
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].
28
28
29
29
## Create a static IP address
30
30
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:
> 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
+
50
44
The IP address is displayed, as shown in the following condensed example output:
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:
66
57
67
58
```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
69
60
70
61
40.121.183.52
71
62
```
72
63
73
64
## Create a service using the static IP address
74
65
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:
100
67
101
68
```azurecli-interactive
102
-
az role assignment create\
69
+
az role assignment create\
103
70
--assignee <SP Client ID> \
104
-
--role "Network Contributor" \
71
+
--role "Contributor" \
105
72
--scope /subscriptions/<subscription id>/resourceGroups/<resource group name>
106
73
```
107
74
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.
109
76
110
77
```yaml
111
78
apiVersion: v1
@@ -123,6 +90,12 @@ spec:
123
90
app: azure-load-balancer
124
91
```
125
92
93
+
Create the service and deployment with the `kubectl apply` command.
94
+
95
+
```console
96
+
kubectl apply -f load-balancer-service.yaml
97
+
```
98
+
126
99
## Troubleshoot
127
100
128
101
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