Skip to content

Commit 014544e

Browse files
Merge pull request #252625 from schaffererin/dnsannotationpublicipaks
Updated incorrect documentation per GitHub issue
2 parents 79e073b + 57aef2a commit 014544e

File tree

1 file changed

+66
-55
lines changed

1 file changed

+66
-55
lines changed

articles/aks/static-ip.md

Lines changed: 66 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,26 @@ This article shows you how to create a static public IP address and assign it to
1919

2020
## Before you begin
2121

22-
* This article assumes that you have an existing AKS cluster. If you need an AKS cluster, see the AKS quickstart [using the Azure CLI][aks-quickstart-cli], [using Azure PowerShell][aks-quickstart-powershell], or [using the Azure portal][aks-quickstart-portal].
2322
* You 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].
2423
* 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].
2524

26-
## Create a static IP address
25+
## Create an AKS cluster
26+
27+
1. Create an Azure resource group using the [`az group create`][az-group-create] command.
28+
29+
```azurecli-interactive
30+
az group create --name myNetworkResourceGroup --location eastus
31+
```
2732
28-
1. Create a resource group for your IP address
33+
2. Create an AKS cluster using the [`az aks create`][az-aks-create] command.
2934
3035
```azurecli-interactive
31-
az group create --name myNetworkResourceGroup
36+
az aks create --name myAKSCluster --resource-group myNetworkResourceGroup --generate-ssh-keys
3237
```
3338
34-
2. Use the [`az network public ip create`][az-network-public-ip-create] command to create a static public IP address. The following example creates a static IP resource named *myAKSPublicIP* in the *myNetworkResourceGroup* resource group.
39+
## Create a static IP address
40+
41+
1. Create a static public IP address using the [`az network public ip create`][az-network-public-ip-create] command.
3542
3643
```azurecli-interactive
3744
az network public-ip create \
@@ -44,19 +51,25 @@ This article shows you how to create a static public IP address and assign it to
4451
> [!NOTE]
4552
> If you're 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.
4653
47-
3. After you create the static public IP address, use the [`az network public-ip list`][az-network-public-ip-list] command to get the IP address. Specify the name of the node resource group and public IP address you created, and query for the *ipAddress*.
54+
2. Get the name of the node resource group using the [`az aks show`][az-aks-show] command and query for the `nodeResourceGroup` property.
55+
56+
```azurecli-interactive
57+
az aks show --name myAKSCluster --resource-group myNetworkResourceGroup --query nodeResourceGroup -o tsv
58+
```
59+
60+
3. Get the static 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`.
4861
4962
```azurecli-interactive
50-
az network public-ip show --resource-group myNetworkResourceGroup --name myAKSPublicIP --query ipAddress --output tsv
63+
az network public-ip show --resource-group <node resource group> --name myAKSPublicIP --query ipAddress --output tsv
5164
```
5265
5366
## Create a service using the static IP address
5467
55-
1. Before creating a service, use the [`az role assignment create`][az-role-assignment-create] command to ensure the cluster identity used by the AKS cluster has delegated permissions to the node resource group.
68+
1. Ensure the cluster identity used by the AKS cluster has delegated permissions to the node resource group using the [`az role assignment create`][az-role-assignment-create] command.
5669
5770
```azurecli-interactive
58-
CLIENT_ID=$(az aks show --name <cluster name> --resource-group <cluster resource group> --query identity.principalId -o tsv)
59-
RG_SCOPE=$(az group show --name myNetworkResourceGroup --query id -o tsv)
71+
CLIENT_ID=$(az aks show --name myAKSCluster --resource-group myNetworkResourceGroup --query identity.principalId -o tsv)
72+
RG_SCOPE=$(az group show --name <node resource group> --query id -o tsv)
6073
az role assignment create \
6174
--assignee ${CLIENT_ID} \
6275
--role "Network Contributor" \
@@ -69,79 +82,78 @@ This article shows you how to create a static public IP address and assign it to
6982
2. Create a file named `load-balancer-service.yaml` and copy in the contents of the following YAML file, providing your own public IP address created in the previous step and the node resource group name.
7083
7184
> [!IMPORTANT]
72-
> 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. To set service annotations, you can 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.
85+
> 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. To set service annotations, you can 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, as shown in the example YAML.
7386
7487
```yaml
7588
apiVersion: v1
7689
kind: Service
7790
metadata:
7891
annotations:
79-
service.beta.kubernetes.io/azure-load-balancer-resource-group: myNetworkResourceGroup
92+
service.beta.kubernetes.io/azure-load-balancer-resource-group: <node resource group>
93+
service.beta.kubernetes.io/azure-load-balancer-ipv4: <public IP address>
8094
name: azure-load-balancer
8195
spec:
82-
loadBalancerIP: 40.121.183.52
8396
type: LoadBalancer
8497
ports:
8598
- port: 80
8699
selector:
87100
app: azure-load-balancer
88101
```
89102
90-
3. Use the `kubectl apply` command to create the service and deployment.
103+
3. Set a public-facing DNS label to the service using the `service.beta.kubernetes.io/azure-dns-label-name` service annotation. This publishes a fully qualified domain name (FQDN) for your service using Azure's public DNS servers and top-level domain. The annotation value must be unique within the Azure location, so we recommend you use a sufficiently qualified label. Azure automatically appends a default suffix in the location you selected, such as `<location>.cloudapp.azure.com`, to the name you provide, creating the FQDN.
91104
92-
```console
93-
kubectl apply -f load-balancer-service.yaml
105+
> [!NOTE]
106+
> If you want to publish the service on your own domain, see [Azure DNS][azure-dns-zone] and the [external-dns][external-dns] project.
107+
108+
```yaml
109+
apiVersion: v1
110+
kind: Service
111+
metadata:
112+
annotations:
113+
service.beta.kubernetes.io/azure-load-balancer-resource-group: <node resource group>
114+
service.beta.kubernetes.io/azure-load-balancer-ipv4: <public IP address>
115+
service.beta.kubernetes.io/azure-dns-label-name: <unique-service-label>
116+
name: azure-load-balancer
117+
spec:
118+
type: LoadBalancer
119+
ports:
120+
- port: 80
121+
selector:
122+
app: azure-load-balancer
94123
```
95124
96-
## Apply a DNS label to the service
97-
98-
If your service uses a dynamic or static public IP address, you can use the `service.beta.kubernetes.io/azure-dns-label-name` service annotation to set a public-facing DNS label. This publishes a fully qualified domain name (FQDN) for your service using Azure's public DNS servers and top-level domain. The annotation value must be unique within the Azure location, so it's recommended to use a sufficiently qualified label. Azure automatically appends a default suffix in the location you selected, such as `<location>.cloudapp.azure.com`, to the name you provide, creating the FQDN.
99-
100-
```yaml
101-
apiVersion: v1
102-
kind: Service
103-
metadata:
104-
annotations:
105-
service.beta.kubernetes.io/azure-dns-label-name: myserviceuniquelabel
106-
name: azure-load-balancer
107-
spec:
108-
type: LoadBalancer
109-
ports:
110-
- port: 80
111-
selector:
112-
app: azure-load-balancer
113-
```
125+
4. Create the service and deployment using the `kubectl apply` command.
114126
115-
To see the DNS label for your load balancer, run the following command:
127+
```console
128+
kubectl apply -f load-balancer-service.yaml
129+
```
116130
117-
```console
118-
kubectl describe service azure-load-balancer
119-
```
131+
5. To see the DNS label for your load balancer, use the `kubectl describe service` command.
120132
121-
The DNS label will be listed under the `Annotations`, as shown in the following condensed example output:
133+
```console
134+
kubectl describe service azure-load-balancer
135+
```
122136
123-
```console
124-
Name: azure-load-balancer
125-
Namespace: default
126-
Labels: <none>
127-
Annotations: service.beta.kuberenetes.io/azure-dns-label-name: myserviceuniquelabel
128-
...
129-
```
137+
The DNS label will be listed under the `Annotations`, as shown in the following condensed example output:
130138
131-
> [!NOTE]
132-
> To publish the service on your own domain, see [Azure DNS][azure-dns-zone] and the [external-dns][external-dns] project.
139+
```output
140+
Name: azure-load-balancer
141+
Namespace: default
142+
Labels: <none>
143+
Annotations: service.beta.kuberenetes.io/azure-dns-label-name: <unique-service-label>
144+
```
133145
134146
## Troubleshoot
135147
136-
If the static IP address defined in the *loadBalancerIP* property of the Kubernetes service manifest doesn't exist or hasn't been created in the node resource group and there are no additional delegations configured, the load balancer service creation fails. To troubleshoot, review the service creation events using the [`kubectl describe`][kubectl-describe] command. Provide the name of the service specified in the YAML manifest, as shown in the following example:
148+
If the static IP address defined in the `loadBalancerIP` property of the Kubernetes service manifest doesn't exist or hasn't been created in the node resource group and there are no other delegations configured, the load balancer service creation fails. To troubleshoot, review the service creation events using the [`kubectl describe`][kubectl-describe] command. Provide the name of the service specified in the YAML manifest, as shown in the following example:
137149
138150
```console
139151
kubectl describe service azure-load-balancer
140152
```
141153

142-
The output will show you information about the Kubernetes service resource. The following example output shows a `Warning` in the `Events`: "`user supplied IP address was not found`." In this scenario, make sure you've created the static public IP address in the node resource group and that the IP address specified in the Kubernetes service manifest is correct.
154+
The output shows you information about the Kubernetes service resource. The following example output shows a `Warning` in the `Events`: "`user supplied IP address was not found`." In this scenario, make sure you created the static public IP address in the node resource group and that the IP address specified in the Kubernetes service manifest is correct.
143155

144-
```console
156+
```output
145157
Name: azure-load-balancer
146158
Namespace: default
147159
Labels: <none>
@@ -165,7 +177,7 @@ Events:
165177

166178
## Next steps
167179

168-
For additional control over the network traffic to your applications, you may want to [create an ingress controller][aks-ingress-basic]. You can also [create an ingress controller with a static public IP address][aks-static-ingress].
180+
For more control over the network traffic to your applications, you may want to [create an ingress controller][aks-ingress-basic]. You can also [create an ingress controller with a static public IP address][aks-static-ingress].
169181

170182
<!-- LINKS - External -->
171183
[kubectl-describe]: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#describe
@@ -177,10 +189,9 @@ For additional control over the network traffic to your applications, you may wa
177189
[az-network-public-ip-list]: /cli/azure/network/public-ip#az_network_public_ip_list
178190
[aks-ingress-basic]: ingress-basic.md
179191
[aks-static-ingress]: ingress-static-ip.md
180-
[aks-quickstart-cli]: ./learn/quick-kubernetes-deploy-cli.md
181-
[aks-quickstart-portal]: ./learn/quick-kubernetes-deploy-portal.md
182-
[aks-quickstart-powershell]: ./learn/quick-kubernetes-deploy-powershell.md
183192
[install-azure-cli]: /cli/azure/install-azure-cli
184193
[ip-sku]: ../virtual-network/ip-services/public-ip-addresses.md#sku
185194
[az-role-assignment-create]: /cli/azure/role/assignment#az-role-assignment-create
186195
[az-aks-show]: /cli/azure/aks#az-aks-show
196+
[az-aks-create]: /cli/azure/aks#az-aks-create
197+
[az-group-create]: /cli/azure/group#az-group-create

0 commit comments

Comments
 (0)