Skip to content

Commit 8a44605

Browse files
committed
Updates for self-hosted gateway GA
1 parent c04971f commit 8a44605

File tree

5 files changed

+105
-57
lines changed

5 files changed

+105
-57
lines changed

articles/api-management/api-management-features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ Each API Management [pricing tier](https://aka.ms/apimpricing) offers a distinct
4343

4444
<sup>1</sup> Enables the use of Azure AD (and Azure AD B2C) as an identity provider for user sign in on the developer portal.<br/>
4545
<sup>2</sup> Including related functionality e.g. users, groups, issues, applications and email templates and notifications.<br/>
46-
<sup>3</sup> Limited to a single self-hosted gateway deployment with a single gateway node.<br/>
46+
<sup>3</sup> In the Developer tier self-hosted gateways are limited to single gateway node.<br/>
Lines changed: 84 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,113 @@
11
---
2-
title: Deploy a self-hosted Azure API Management gateway to Kubernetes | Microsoft Docs
3-
description: Learn how to deploy a self-hosted Azure API Management gateway to Kubernetes
2+
title: Deploy Azure API Management self-hosted gateway to Kubernetes | Microsoft Docs
3+
description: Learn how to deploy self-hosted gateway to Kubernetes
44
services: api-management
5-
documentationcenter: ''
6-
author: miaojiang
5+
author: vladvino
76
manager: gwallace
8-
editor: ''
9-
107
ms.service: api-management
118
ms.workload: mobile
12-
ms.tgt_pltfrm: na
139
ms.topic: article
14-
ms.date: 03/31/2020
1510
ms.author: apimpm
16-
11+
ms.date: 04/23/2020
1712
---
13+
# Deploy Azure API Management self-hosted gateway to Kubernetes
1814

19-
# Deploy a self-hosted Azure API Management gateway to Kubernetes
20-
21-
This article provides the steps for deploying self-hosted Azure API Management gateway into a Kubernetes Cluster.
15+
This article describes the steps for deploying self-hosted gateway to a Kubernetes cluster.
2216

2317
## Prerequisites
2418

2519
- Complete the following quickstart: [Create an Azure API Management instance](get-started-create-service-instance.md)
26-
- Create a Kubernetes cluster. [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/) is a good option for development and evaluation purposes. For production workloads, you can use [Azure Kubernetes Service](https://azure.microsoft.com/services/kubernetes-service/) or a Kubernetes cluster in a foreign cloud.
27-
- [Provision a gateway resource in your API Management instance](api-management-howto-provision-self-hosted-gateway.md).
20+
- Create a Kubernetes cluster.
21+
> [!TIP]
22+
> [Single-node clusters](https://kubernetes.io/docs/setup/#learning-environment) work well for development and evaluation purposes. Use [Kubernetes Certified](https://kubernetes.io/partners/#conformance) multi-node clusters on-premises or in the cloud for production workloads.
23+
- [Provision a self-hosted gateway resource in your API Management instance](api-management-howto-provision-self-hosted-gateway.md).
2824

29-
## Deploy the gateway to Kubernetes
25+
## Deploy the self-hosted gateway to Kubernetes
3026

31-
1. Select **Gateways** from under **Settings**.
32-
2. Select the gateway resource you intend to deploy.
27+
1. Select **Gateways** from under **Deployment and infrastructure**.
28+
2. Select the self-hosted gateway resource you intend to deploy.
3329
3. Select **Deployment**.
34-
4. Note that a new token in the **Token** text box was autogenerated for you using the default **Expiry** and **Secret Key** values. Adjust either or both if desired and select **Generate** to create a new token.
35-
5. Make sure **Kubernetes** is selected under **Deployment scripts**.
36-
6. Select **<gateway-name>.yml** file link next to **Deployment** to download the file.
37-
7. Adjust the port mappings and container name in the yml file as needed.
38-
8. Select the **copy** icon located at the right end of the **Deploy** text box to save the `kubectl` command to clipboard.
39-
9. Paste the command to the terminal (or command) window. Note that the command expects the downloaded environment file to be present in the current directory.
40-
```console
41-
kubectl apply -f <gateway-name>.yaml
42-
```
43-
10. Execute the command. The command instructs your Kubernetes cluster to run the container, using self-hosted gateway's image downloaded from the Microsoft Container Registry, and to configure the container to expose HTTP (8080) and HTTPS (443) ports.
44-
11. Run the below command to check the gateway pod is running. Note that your pod name will be different.
30+
4. Note that an access token in the **Token** text box was autogenerated for you using the default **Expiry** and **Secret key** values. If needed, pick desired values in either or both controls to generate a new token.
31+
5. Select **Kubernetes** tab under **Deployment scripts**.
32+
6. Click on the **<gateway-name>.yml** file link and download the YAML file.
33+
7. Select **copy** icon located at the bottom right corner of the **Deploy** text box to save the `kubectl` commands to the clipboard.
34+
8. Paste commands to the terminal (or command) window. The first command creates a Kubernetes secret containing access token generated in step 4. Second command applies the configuration file downloaded in step 6 to the Kubernetes cluster and expects the the file to be present in the current directory.
35+
9. Execute the commands to create the necessary Kubernetes objects in the [default namespace](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/) and start self-hosted gateway pod(s) from [container image](https://aka.ms/apim/sputnik/repo) downloaded from the Microsoft Container Registry.
36+
10. Execute command shown bellow to check if the deployment succeeded . Note that it might take a little time for all the objects to be created and for pod(s) to initialize.
4537
```console
46-
kubectl get pods
47-
NAME READY STATUS RESTARTS AGE
48-
local-gateway-55f774f844-bv9wt 1/1 Running 0 1m
38+
kubectl get deployments
39+
NAME READY UP-TO-DATE AVAILABLE AGE
40+
<gateway-name> 1/1 1 1 18s
4941
```
50-
12. Run the below command to check the gateway service is running. Note that your service name will be different.
42+
11. Execute command shown bellow to check if the service was successfully created. Note that your service IPs and ports will be different.
5143
```console
5244
kubectl get services
53-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
54-
localgateway NodePort 10.110.230.87 <none> 80:32504/TCP,443:30043/TCP 1m
45+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
46+
<gateway-name> LoadBalancer 10.99.236.168 <pending> 80:31620/TCP,443:30456/TCP 9m1s
5547
```
56-
13. Go back to the Azure portal and confirm that gateway node you just deployed is reporting healthy status.
48+
12. Go back to the Azure portal and select **Overview**.
49+
13. **Status** showing a green checkmark icon followed by the node count matching the number of replicas specified in the YAML file confirms that deployed self-hosted gateway pods are successfully communicating with the API Management service and have a regular "heartbeat".
5750

5851
![gateway status](media/api-management-howto-deploy-self-hosted-gateway-to-k8s/status.png)
5952

6053
> [!TIP]
61-
> Use <code>kubectl logs <gateway-pod-name></code> command to view a snapshot of self-hosted gateway log.
54+
> Execute <code>kubectl logs deployment/<gateway-name></code> command to view logs from a randomly selected pod if there are more than one.
55+
> Execute <code>kubectl logs -h</code> for a complete set of command options, e.g. how to view logs for a specific pod or container.
6256
63-
## Next steps
57+
## Production deployment considerations
58+
59+
### Access token
60+
Without a valid access token self-hosted gateway is unable to access and download configuration from configuration data endpoint of the associated API Management service. Access token can be valid for a maximum of 30 days. It must be regenerated and the cluster configured with a fresh token either manually or via automation before it expires. When automating token refresh use this management API [operation](https://docs.microsoft.com/rest/api/apimanagement/2019-12-01/gateway/generatetoken) to generated a new token. Follow this [link](https://kubernetes.io/docs/concepts/configuration/secret) for information on managing Kubernetes secrets.
61+
62+
### Namespace
63+
Kubernetes [namespaces](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/) help with dividing a single cluster among multiple teams, projects, or applications. Namespaces provide a scope for resources and names and can be associated with a resource quota and access control policies.
64+
Commands provided in the Azure portal create self-hosted gateway resources in the **default** namespace which is automatically created, exists in every cluster, and can't be deleted.
65+
Consider [creating and deploying](https://kubernetesbyexample.com/ns/) self-hosted gateway into a separate namespace in production.
66+
67+
### Number of replicas
68+
Minimal number of replicas suitable in production is two.
69+
70+
By default, self-hosted gateway is deployed with a **RollingUpdate** deployment [strategy](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy). Review the default values and consider explicitly setting [**maxUnavailable**](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#max-unavailable) and [**maxSurge**](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#max-surge) fields, especially when using a high replica count.
71+
72+
### Container resources
73+
By default, the YAML file provided in the Azure portal doesn't specify container resource requests.
6474

65-
* To learn more about the self-hosted gateway, see [Azure API Management self-hosted gateway overview](self-hosted-gateway-overview.md)
66-
* Learn more about [Azure Kubernetes Service](https://docs.microsoft.com/azure/aks/intro-kubernetes)
75+
It's impossible to reliably predict and recommend the amount of per-container CPU and memory resources and the number of replicas required for supporting a specific workload due to many factors at play, e.g.:
6776

77+
- Specific hardware the cluster is running on
78+
- Presence and type of virtualization
79+
- Number and rate of concurrent client connections
80+
- Request rate
81+
- Kind and number of configured policies
82+
- Payload size and if payloads are buffered or streamed
83+
- Backend service latency
84+
85+
We recommend setting resource request to 2 cores and 2 GiB as a starting point, performing a load test and scaling up/out or down/in based the results.
86+
87+
### Container image tag
88+
The YAML file provided in the Azure portal uses the **latest** tag which always references the most recent version of the self-hosted gateway container image.
89+
90+
Consider using a specific version tag in production to avoid unintentional upgrade to a newer version.
91+
92+
Follow this [link](https://mcr.microsoft.com/v2/azure-api-management/gateway/tags/list) to see the full list of available tags.
93+
94+
### DNS policy
95+
DNS name resolution plays a critical role in self-hosted gateway's ability to connect to dependencies in Azure and dispatch API calls to backend services.
96+
97+
The YAML file provided in the Azure portal applies the default [**ClusterFirst**](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy) policy which causes name resolution requests not resolved by the cluster DNS to be forwarded to the upstream DNS server inherited from the node.
98+
99+
Follow this [link](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service) to learn about name resolution in Kubernetes and consider customizing [DNS policy](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy) or D[NS configuration](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-config) as appropriate for your setup.
100+
101+
### Configuration backup
102+
Follow this [link](self-hosted-gateway-overview.md#connectivity-to-azure) to learn about self-hosted gateway behavior in the presence of a temporary Azure connectivity outage.
103+
Configure local storage volume for the self-hosted gateway container, so it can persist a backup copy of the latest downloaded configuration and, if connectivity is down, use it upon restart. The volume mount path must be <code>/apim/config</code>. See an example [here](https://github.com/Azure/api-management-self-hosted-gateway/blob/master/examples/self-hosted-gateway-with-configuration-backup.yaml).
104+
To learn about storage in Kubernetes follow this [link](https://kubernetes.io/docs/concepts/storage/volumes/).
105+
106+
### Local logs and metrics
107+
Self-hosted gateway sends telemetry to [Azure Monitor](api-management-howto-use-azure-monitor.md) and [Azure Application Insights](api-management-howto-app-insights.md) per configuration settings in the associated API Management service.
108+
When [connectivity to Azure](self-hosted-gateway-overview.md#connectivity-to-azure) is temporarily lost, the flow of telemetry to Azure is interrupted and the data is lost for the duration of the outage.
109+
Consider [setting up local monitoring](api-management-howto-configure-local-metrics-and-logs.md) to ensure ability to observe the API traffic and prevent telemetry loss during Azure connectivity outages.
110+
111+
## Next steps
68112

113+
* To learn more about the self-hosted gateway, see [Azure API Management self-hosted gateway overview](self-hosted-gateway-overview.md)
68.1 KB
Loading

articles/api-management/self-hosted-gateway-overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Self-hosted Azure API Management gateway overview | Microsoft Docs
3-
description: Learn how self-hosted Azure API Management gateway helps organizations manage APIs in the hybrid and multicloud environments.
2+
title: Azure API Management self-hosted gateway overview | Microsoft Docs
3+
description: Learn how Azure API Management self-hosted gateway helps organizations manage APIs in the hybrid and multicloud environments.
44
services: api-management
55
documentationcenter: ''
66
author: vlvinogr
@@ -11,7 +11,7 @@ ms.service: api-management
1111
ms.workload: mobile
1212
ms.tgt_pltfrm: na
1313
ms.topic: article
14-
ms.date: 03/31/2020
14+
ms.date: 04/24/2020
1515
ms.author: apimpm
1616
---
1717

includes/api-management-service-limits.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ author: vladvino
88
ms.assetid: 1b813833-39c8-46be-8666-fd0960cfbf04
99
ms.service: api-management
1010
ms.topic: include
11-
ms.date: 01/10/2020
11+
ms.date: 04/14/2020
1212
ms.author: vlvinogr
1313
ms.custom: include file
1414
---
@@ -21,21 +21,24 @@ ms.custom: include file
2121
| Maximum cached response size | 2 MiB |
2222
| Maximum policy document size | 256 KiB<sup>5</sup> |
2323
| Maximum custom gateway domains per service instance<sup>6</sup> | 20 |
24-
| Maximum number of CA certificates per service instance | 10 |
25-
| Maximum number of service instances per subscription<sup>7</sup> | 20 |
26-
| Maximum number of subscriptions per service instance<sup>7</sup> | 500 |
27-
| Maximum number of client certificates per service instance<sup>7</sup> | 50 |
28-
| Maximum number of APIs per service instance<sup>7</sup> | 50 |
29-
| Maximum number of API operations per service instance<sup>7</sup> | 1,000 |
30-
| Maximum total request duration<sup>7</sup> | 30 seconds |
31-
| Maximum buffered payload size<sup>7</sup> | 2 MiB |
32-
| Maximum request URL size<sup>8</sup> | 4096 bytes |
24+
| Maximum number of CA certificates per service instance<sup>7</sup> | 10 |
25+
| Maximum number of service instances per subscription<sup>8</sup> | 20 |
26+
| Maximum number of subscriptions per service instance<sup>8</sup> | 500 |
27+
| Maximum number of client certificates per service instance<sup>8</sup> | 50 |
28+
| Maximum number of APIs per service instance<sup>8</sup> | 50 |
29+
| Maximum number of API operations per service instance<sup>8</sup> | 1,000 |
30+
| Maximum total request duration<sup>8</sup> | 30 seconds |
31+
| Maximum buffered payload size<sup>8</sup> | 2 MiB |
32+
| Maximum request URL size<sup>9</sup> | 4096 bytes |
33+
| Maximum number of self-hosted gateways<sup>10</sup> | 25 |
3334

34-
<sup>1</sup>Scaling limits depend on the pricing tier. To see the pricing tiers and their scaling limits, see [API Management pricing](https://azure.microsoft.com/pricing/details/api-management/).<br/>
35+
<sup>1</sup>Scaling limits depend on the pricing tier. For details on the pricing tiers and their scaling limits, see [API Management pricing](https://azure.microsoft.com/pricing/details/api-management/).<br/>
3536
<sup>2</sup>Per unit cache size depends on the pricing tier. To see the pricing tiers and their scaling limits, see [API Management pricing](https://azure.microsoft.com/pricing/details/api-management/).<br/>
3637
<sup>3</sup>Connections are pooled and reused unless explicitly closed by the back end.<br/>
3738
<sup>4</sup>This limit is per unit of the Basic, Standard, and Premium tiers. The Developer tier is limited to 1,024. This limit doesn't apply to the Consumption tier.<br/>
3839
<sup>5</sup>This limit applies to the Basic, Standard, and Premium tiers. In the Consumption tier, policy document size is limited to 4 KiB.<br/>
39-
<sup>6</sup>This resource is available in the Premium tier only.<br/>
40-
<sup>7</sup>This resource applies to the Consumption tier only.<br/>
41-
<sup>8</sup>Applies to the Consumption tier only. Includes an up to 2048 bytes long query string.<br/>
40+
<sup>6</sup>Multiple custom domains are supported in the Developer and Premium tiers only.<br/>
41+
<sup>7</sup>CA certificates are not supported in the Consumption tier.<br/>
42+
<sup>8</sup>This resource applies to the Consumption tier only.<br/>
43+
<sup>9</sup>Applies to the Consumption tier only. Includes an up to 2048 bytes long query string.<br/>
44+
<sup>10</sup>Self-hosted gateways are supported in the Developer and Premium tiers only. The limit applies to the number of [self-hosted gateway resources](https://docs.microsoft.com/rest/api/apimanagement/2019-12-01/gateway). To raise this limit please contact [support](https://azure.microsoft.com/support/options/). Note, that the number of nodes (or replicas) associated with a self-hosted gateway resource is unlimited in the Premium tier and capped at a single node in the Developer tier.

0 commit comments

Comments
 (0)