Deploy a self-hosted Azure API Management gateway to Kubernetes
This article provides the steps for deploying self-hosted Azure API Management gateway into a Kubernetes Cluster.
Self-hosted gateway feature is in preview. During the preview, the self-hosted gateway is available only in the Developer and Premium tiers at no additional charge. Developer tier is limited to a single self-hosted gateway deployment.
- Complete the following quickstart: Create an Azure API Management instance
- Create a Kubernetes cluster. Minikube is a good option for development and evaluation purposes. For production workloads, you can use Azure Kubernetes Service or a Kubernetes cluster in a foreign cloud.
- Provision a gateway resource in your API Management instance.
Deploy the gateway to Kubernetes
- Select Gateways from under Settings.
- Select the gateway resource you intend to deploy.
- Select Deployment.
- 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.
- Make sure Kubernetes is selected under Deployment scripts.
.ymlfile link next to Deployment to download the file.
- Adjust the port mappings and container name in the yml file as needed.
- Select the copy icon located at the right end of the Deploy text box to save the
kubectlcommand to clipboard.
- 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.
kubectl apply -f <gateway-name>.yaml
- 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.
- Run the below command to check the gateway pod is running. Note that your pod name will be different.
kubectl get pods NAME READY STATUS RESTARTS AGE local-gateway-55f774f844-bv9wt 1/1 Running 0 1m
- Run the below command to check the gateway service is running. Note that your service name will be different.
kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE localgateway NodePort 10.110.230.87 <none> 80:32504/TCP,443:30043/TCP 1m
- Go back to the Azure portal and confirm that gateway node you just deployed is reporting healthy status.
kubectl logs command to view a snapshot of self-hosted gateway log.