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.

Note

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.

Prerequisites

Deploy the gateway to Kubernetes

  1. Select Gateways from under Settings.
  2. Select the gateway resource you intend to deploy.
  3. Select Deployment.
  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.
  5. Make sure Kubernetes is selected under Deployment scripts.
  6. Select .yml file link next to Deployment to download the file.
  7. Adjust the port mappings and container name in the yml file as needed.
  8. Select the copy icon located at the right end of the Deploy text box to save the kubectl command to clipboard.
  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.
    kubectl apply -f <gateway-name>.yaml
  1. 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.
  2. 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
  1. 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
  1. Go back to the Azure portal and confirm that gateway node you just deployed is reporting healthy status.

gateway status

Tip

Use kubectl logs command to view a snapshot of self-hosted gateway log.

Next steps