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
+50-8Lines changed: 50 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ ms.author: allensu
7
7
ms.subservice: aks-networking
8
8
ms.custom: devx-track-azurecli
9
9
ms.topic: how-to
10
-
ms.date: 09/22/2023
10
+
ms.date: 06/03/2024
11
11
#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.
12
12
---
13
13
@@ -65,11 +65,53 @@ This article shows you how to create a static public IP address and assign it to
65
65
66
66
## Create a service using the static IP address
67
67
68
-
1. Ensure the cluster identity used by the AKS cluster has delegated permissions to the public IP's resource group using the [`az role assignment create`][az-role-assignment-create] command.
68
+
1. First, determine which type of managed identity your AKS cluster is using, system-assigned or user-assigned. If you're not certain, call the [az aks show][az-aks-show] command and query for the identity's *type* property.
69
+
70
+
```azurecli
71
+
az aks show \
72
+
--name myAKSCluster \
73
+
--resource-group myResourceGroup \
74
+
--query identity.type \
75
+
--output tsv
76
+
```
77
+
78
+
If the cluster is using a managed identity, the value of the *type* property will be either **SystemAssigned** or **UserAssigned**.
79
+
80
+
If the cluster is using a service principal, the value of the *type* property will be null. Consider upgrading your cluster to use a managed identity.
81
+
82
+
1. If your AKS cluster uses a system-assigned managed identity, then query for the managed identity's principal ID as follows:
83
+
84
+
```azurecli-interactive
85
+
# Get the principal ID for a system-assigned managed identity.
86
+
CLIENT_ID=$(az aks show \
87
+
--name myAKSCluster \
88
+
--resource-group myNetworkResourceGroup \
89
+
--query identity.principalId \
90
+
--output tsv)
91
+
```
92
+
93
+
If your AKS cluster uses a user-assigned managed identity, then the principal ID will be null. Query for the user-assigned managed identity's client ID instead:
94
+
95
+
```azurecli-interactive
96
+
# Get the client ID for a user-assigned managed identity.
1. Assign delegated permissions for the managed identity used by the AKS cluster for the public IP's resource group by calling the [`az role assignment create`][az-role-assignment-create] command.
69
105
70
106
```azurecli-interactive
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)
107
+
# Get the resource ID for the node resource group.
108
+
RG_SCOPE=$(az group show \
109
+
--name <node resource group> \
110
+
--query id \
111
+
--output tsv)
112
+
113
+
# Assign the Network Contributor role to the managed identity,
114
+
# scoped to the node resource group.
73
115
az role assignment create \
74
116
--assignee ${CLIENT_ID} \
75
117
--role "Network Contributor" \
@@ -79,7 +121,7 @@ This article shows you how to create a static public IP address and assign it to
79
121
> [!IMPORTANT]
80
122
> If you customized your outbound IP, make sure your cluster identity has permissions to both the outbound public IP and the inbound public IP.
81
123
82
-
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.
124
+
1. 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.
83
125
84
126
> [!IMPORTANT]
85
127
> 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 either use `service.beta.kubernetes.io/azure-pip-name` for public IP name, or 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.
@@ -103,7 +145,7 @@ This article shows you how to create a static public IP address and assign it to
103
145
> [!NOTE]
104
146
> Adding the `service.beta.kubernetes.io/azure-pip-name` annotation ensures the most efficient LoadBalancer creation and is highly recommended to avoid potential throttling.
105
147
106
-
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.
148
+
1. 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.
107
149
108
150
> [!NOTE]
109
151
> If you want to publish the service on your own domain, see [Azure DNS][azure-dns-zone] and the [external-dns][external-dns] project.
@@ -125,13 +167,13 @@ This article shows you how to create a static public IP address and assign it to
125
167
app: azure-load-balancer
126
168
```
127
169
128
-
4. Create the service and deployment using the `kubectl apply` command.
170
+
1. Create the service and deployment using the `kubectl apply` command.
129
171
130
172
```console
131
173
kubectl apply -f load-balancer-service.yaml
132
174
```
133
175
134
-
5. To see the DNS label for your load balancer, use the `kubectl describe service` command.
176
+
1. To see the DNS label for your load balancer, use the `kubectl describe service` command.
0 commit comments