Skip to content

Commit dc25697

Browse files
committed
articles-about-ingress-for-aks
1 parent 28abb95 commit dc25697

File tree

3 files changed

+65
-66
lines changed

3 files changed

+65
-66
lines changed

articles/application-gateway/ingress-controller-autoscale-pods.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Autoscale AKS pods with Azure Application Gateway metrics
3-
description: This article provides instructions on how to scale your AKS backend pods using Application Gateway metrics and Azure Kubernetes Metric Adapter
3+
description: This article provides instructions on how to scale your AKS back-end pods by using Application Gateway metrics and the Azure Kubernetes Metrics Adapter.
44
services: application-gateway
55
author: greg-lindsay
66
ms.service: azure-application-gateway
@@ -10,35 +10,31 @@ ms.date: 9/17/2024
1010
ms.author: greglin
1111
---
1212

13-
# Autoscale your AKS pods using Application Gateway Metrics (Beta)
13+
# Autoscale your AKS pods by using Application Gateway metrics
1414

1515
As incoming traffic increases, it becomes crucial to scale up your applications based on the demand.
1616

17-
In the following tutorial, we explain how you can use Application Gateway's `AvgRequestCountPerHealthyHost` metric to scale up your application. `AvgRequestCountPerHealthyHost` measures average requests sent to a specific backend pool and backend HTTP setting combination.
17+
This article explains how you can use the `AvgRequestCountPerHealthyHost` metric in Azure Application Gateway to scale up an application. The `AvgRequestCountPerHealthyHost` metric measures average requests sent to a specific combination of a back-end pool and a back-end HTTP setting.
1818

19-
Use following two components:
19+
Use the following two components:
2020

21-
* [`Azure Kubernetes Metric Adapter`](https://github.com/Azure/azure-k8s-metrics-adapter) - We use the metric adapter to expose Application Gateway metrics through the metric server. The Azure Kubernetes Metric Adapter is an open source project under Azure, similar to the Application Gateway Ingress Controller.
22-
* [`Horizontal Pod Autoscaler`](/azure/aks/concepts-scale#horizontal-pod-autoscaler) - We use HPA to use Application Gateway metrics and target a deployment for scaling.
21+
- [Azure Kubernetes Metrics Adapter](https://github.com/Azure/azure-k8s-metrics-adapter): You use this component to expose Application Gateway metrics through the metric server. It's an open-source project under Azure, similar to the Application Gateway Ingress Controller.
22+
- [Horizontal Pod Autoscaler](/azure/aks/concepts-scale#horizontal-pod-autoscaler): You use this component to apply Application Gateway metrics and target a deployment for scaling.
2323

2424
> [!NOTE]
25-
> The Azure Kubernetes Metrics Adapter is no longer maintained. Kubernetes Event-driven Autoscaling (KEDA) is an alternative.<br>
26-
> Also see [Application Gateway for Containers](for-containers/overview.md).
25+
> The Azure Kubernetes Metrics Adapter is no longer maintained. Kubernetes Event-driven Autoscaling (KEDA) is an alternative.
2726
28-
> [!TIP]
29-
> Also see [What is Application Gateway for Containers](for-containers/overview.md).
27+
## Set up the Azure Kubernetes Metrics Adapter
3028

31-
## Setting up Azure Kubernetes Metric Adapter
32-
33-
1. First, create a Microsoft Entra service principal and assign it `Monitoring Reader` access over Application Gateway's resource group.
29+
1. Create a Microsoft Entra service principal and assign it `Monitoring Reader` access over the Application Gateway instance's resource group:
3430

3531
```azurecli
3632
applicationGatewayGroupName="<application-gateway-group-id>"
3733
applicationGatewayGroupId=$(az group show -g $applicationGatewayGroupName -o tsv --query "id")
3834
az ad sp create-for-rbac -n "azure-k8s-metric-adapter-sp" --role "Monitoring Reader" --scopes applicationGatewayGroupId
3935
```
4036
41-
1. Now, deploy the [`Azure Kubernetes Metric Adapter`](https://github.com/Azure/azure-k8s-metrics-adapter) using the Microsoft Entra service principal created previously.
37+
1. Deploy the Azure Kubernetes Metrics Adapter by using the Microsoft Entra service principal that you created previously:
4238
4339
```bash
4440
kubectl create namespace custom-metrics
@@ -50,7 +46,7 @@ Use following two components:
5046
kubectl apply -f kubectl apply -f https://raw.githubusercontent.com/Azure/azure-k8s-metrics-adapter/master/deploy/adapter.yaml -n custom-metrics
5147
```
5248
53-
1. Create an `ExternalMetric` resource with name `appgw-request-count-metric`. This resource instructs the metric adapter to expose `AvgRequestCountPerHealthyHost` metric for `myApplicationGateway` resource in `myResourceGroup` resource group. You can use the `filter` field to target a specific backend pool and backend HTTP setting in the Application Gateway.
49+
1. Create an `ExternalMetric` resource with the name `appgw-request-count-metric`. This resource instructs the metric adapter to expose the `AvgRequestCountPerHealthyHost` metric for the `myApplicationGateway` resource in the `myResourceGroup` resource group. You can use the `filter` field to target a specific back-end pool and back-end HTTP setting in the Application Gateway instance.
5450
5551
```yaml
5652
apiVersion: azure.com/v1alpha2
@@ -60,8 +56,8 @@ Use following two components:
6056
spec:
6157
type: azuremonitor
6258
azure:
63-
resourceGroup: myResourceGroup # replace with your application gateway's resource group name
64-
resourceName: myApplicationGateway # replace with your application gateway's name
59+
resourceGroup: myResourceGroup # replace with your Application Gateway instance's resource group name
60+
resourceName: myApplicationGateway # replace with your Application Gateway instance's name
6561
resourceProviderNamespace: Microsoft.Network
6662
resourceType: applicationGateways
6763
metric:
@@ -70,7 +66,8 @@ Use following two components:
7066
filter: BackendSettingsPool eq '<backend-pool-name>~<backend-http-setting-name>' # optional
7167
```
7268
73-
You can now make a request to the metric server to see if our new metric is getting exposed:
69+
You can now make a request to the metric server to see if the new metric is being exposed:
70+
7471
```bash
7572
kubectl get --raw "/apis/external.metrics.k8s.io/v1beta1/namespaces/default/appgw-request-count-metric"
7673
# Sample Output
@@ -93,13 +90,14 @@ kubectl get --raw "/apis/external.metrics.k8s.io/v1beta1/namespaces/default/appg
9390
# }
9491
```
9592

96-
## Using the new metric to scale up the deployment
93+
## Use the new metric to scale up the deployment
94+
95+
After you expose `appgw-request-count-metric` through the metric server, you're ready to use the [Horizontal Pod Autoscaler](/azure/aks/concepts-scale#horizontal-pod-autoscaler) to scale up your target deployment.
9796

98-
Once we're able to expose `appgw-request-count-metric` through the metric server, we're ready to use [`Horizontal Pod Autoscaler`](/azure/aks/concepts-scale#horizontal-pod-autoscaler) to scale up our target deployment.
97+
The following example targets a sample deployment named `aspnet`. You scale up pods when `appgw-request-count-metric` is `200` per pod, up to a maximum of `10` pods.
9998

100-
In following example, we target a sample deployment `aspnet`. We scale up Pods when `appgw-request-count-metric` > 200 per Pod up to a max of `10` Pods.
99+
Replace your target deployment name and apply the following autoscale configuration:
101100

102-
Replace your target deployment name and apply the following auto scale configuration:
103101
```yaml
104102
apiVersion: autoscaling/v2
105103
kind: HorizontalPodAutoscaler
@@ -119,10 +117,13 @@ spec:
119117
targetAverageValue: 200
120118
```
121119
122-
Test your setup by using a load test tool like apache bench:
120+
Test your setup by using a load test tool like ApacheBench:
121+
123122
```bash
124123
ab -n10000 http://<applicaiton-gateway-ip-address>/
125124
```
126125

127126
## Next steps
128-
- [**Troubleshoot Ingress Controller issues**](ingress-controller-troubleshoot.md): Troubleshoot any issues with the Ingress Controller.
127+
128+
- [Troubleshoot Application Gateway Ingress Controller issues](ingress-controller-troubleshoot.md)
129+
- [What is Application Gateway for Containers?](for-containers/overview.md)

articles/application-gateway/ingress-controller-expose-websocket-server.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Expose a WebSocket server to Application Gateway
3-
description: This article provides information on how to expose a WebSocket server to Application Gateway with ingress controller for AKS clusters.
3+
description: This article provides information on how to expose a WebSocket server to Application Gateway with an ingress controller for AKS clusters.
44
services: application-gateway
55
author: greg-lindsay
66
ms.service: azure-application-gateway
@@ -11,12 +11,12 @@ ms.author: greglin
1111

1212
# Expose a WebSocket server to Application Gateway
1313

14-
As outlined in the Application Gateway v2 documentation - it [provides native support for the WebSocket and HTTP/2 protocols](features.md#websocket-and-http2-traffic). Both Application Gateway and the Kubernetes Ingress don't have a user-configurable setting to selectively enable or disable WebSocket support.
14+
Azure Application Gateway v2 [provides native support for the WebSocket and HTTP/2 protocols](features.md#websocket-and-http2-traffic). Both Application Gateway and the Kubernetes ingress don't have a user-configurable setting to selectively enable or disable WebSocket support.
1515

16-
> [!TIP]
17-
> Also see [What is Application Gateway for Containers](for-containers/overview.md).
16+
## YAML for WebSocket server deployment
17+
18+
The following Kubernetes deployment YAML shows the minimum configuration for deploying a WebSocket server, which is the same as deploying a regular web server:
1819

19-
The following Kubernetes deployment YAML shows the minimum configuration used to deploy a WebSocket server, which is the same as deploying a regular web server:
2020
```yaml
2121
apiVersion: apps/v1
2222
kind: Deployment
@@ -73,9 +73,10 @@ spec:
7373
servicePort: 80
7474
```
7575
76-
Given that all the prerequisites are fulfilled, and you have an Application Gateway controlled by a Kubernetes Ingress in your AKS, the deployment shown previously would result in a WebSockets server exposed on port 80 of your Application Gateway's public IP and the `ws.contoso.com` domain.
76+
Assuming that all the prerequisites are fulfilled, and you have an Application Gateway instance controlled by a Kubernetes ingress in Azure Kubernetes Service (AKS), the preceding deployment would result in a WebSocket server exposed on port 80 of your Application Gateway instance's public IP address and the `ws.contoso.com` domain.
7777

7878
The following cURL command would test the WebSocket server deployment:
79+
7980
```shell
8081
curl -i -N -H "Connection: Upgrade" \
8182
-H "Upgrade: websocket" \
@@ -86,10 +87,15 @@ curl -i -N -H "Connection: Upgrade" \
8687
http://1.2.3.4:80/ws
8788
```
8889

89-
## WebSocket Health Probes
90+
## WebSocket health probes
91+
92+
If your deployment doesn't explicitly define health probes, Application Gateway attempts an HTTP `GET` operation on your WebSocket server endpoint.
93+
Depending on the server implementation (such as [this example](https://github.com/gorilla/websocket/blob/master/examples/chat/main.go)), you might need WebSocket-specific headers (`Sec-Websocket-Version`, for instance).
94+
95+
Because Application Gateway doesn't add WebSocket headers, the Application Gateway health probe response from your WebSocket server is most likely `400 Bad Request`. Application Gateway then marks your pods as unhealthy. This status eventually results in a `502 Bad Gateway` for the consumers of the WebSocket server.
96+
97+
To avoid the `502 Bad Gateway` error, you might need to add an HTTP `GET` handler for a health check to your server. For example, `/health` returns `200 OK`.
98+
99+
## Related content
90100

91-
If your deployment doesn't explicitly define health probes, Application Gateway would attempt an HTTP GET on your WebSocket server endpoint.
92-
Depending on the server implementation ([here's one we love](https://github.com/gorilla/websocket/blob/master/examples/chat/main.go)) WebSocket specific headers may be required (`Sec-Websocket-Version` for instance).
93-
Since Application Gateway doesn't add WebSocket headers, the Application Gateway's health probe response from your WebSocket server is most likely `400 Bad Request`.
94-
As a result, Application Gateway marks your pods as unhealthy. This status eventually results in a `502 Bad Gateway` for the consumers of the WebSocket server.
95-
To avoid the bad gateway error, you might need to add an HTTP GET handler for a health check to your server (`/health` for instance, which returns `200 OK`).
101+
- [What is Application Gateway for Containers?](for-containers/overview.md)

0 commit comments

Comments
 (0)