Deploy an Azure API Management self-hosted gateway to Azure Kubernetes Service
APPLIES TO: Developer | Premium
This article provides the steps for deploying self-hosted gateway component of Azure API Management to Azure Kubernetes Service. For deploying self-hosted gateway to a Kubernetes cluster, see the how-to article for deployment by using a deployment YAML file or with Helm.
Note
You can also deploy self-hosted gateway to an Azure Arc-enabled Kubernetes cluster as a cluster extension.
Prerequisites
- Create an Azure API Management instance
- Create an Azure Kubernetes cluster using the Azure CLI, using Azure PowerShell, or using the Azure portal.
- Provision a gateway resource in your API Management instance.
Deploy the self-hosted gateway to AKS
Select Gateways from under Deployment and infrastructure.
Select the self-hosted gateway resource you intend to deploy.
Select Deployment.
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.
Make sure Kubernetes is selected under Deployment scripts.
Select <gateway-name>.yml file link next to Deployment to download the file.
Adjust the
config.service.endpoint
, port mappings, and container name in the .yml file as needed.Depending on your scenario, you might need to change the service type.
- The default value is
LoadBalancer
, which is the external load balancer. - You can use the internal load balancer to restrict the access to the self-hosted gateway to only internal users.
- The sample below uses
NodePort
.
- The default value is
Select the copy icon located at the right end of the Deploy text box to save the
kubectl
command to clipboard.Paste the command to the terminal (or command) window. The command expects the downloaded environment file to be present in the current directory.
kubectl apply -f <gateway-name>.yaml
Execute the command. The command instructs your AKS cluster to:
- Run the container, using self-hosted gateway's image downloaded from the Microsoft Container Registry.
- Configure the container to expose HTTP (8080) and HTTPS (443) ports.
Run the below command to check the gateway pod is running. Your pod name will be different.
kubectl get pods NAME READY STATUS RESTARTS AGE contoso-apim-gateway-59f5fb94c-s9stz 1/1 Running 0 1m
Run the below command to check the gateway service is running. Your service name and IP addresses will be different.
kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE contosogateway NodePort 10.110.230.87 <none> 80:32504/TCP,443:30043/TCP 1m
Return to the Azure portal and confirm that gateway node you deployed is reporting healthy status.
Tip
Use kubectl logs <gateway-pod-name>
command to view a snapshot of self-hosted gateway log.
Next steps
- To learn more about the self-hosted gateway, see Azure API Management self-hosted gateway overview.
- Learn how to deploy API Management self-hosted gateway to Azure Arc-enabled Kubernetes clusters.
- Learn more about the observability capabilities of the Azure API Management gateways.
- Learn more about guidance to run the self-hosted gateway on Kubernetes in production.
- Learn more about Azure Kubernetes Service.