Deploy to Azure Kubernetes Service

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.

Note

You can also deploy self-hosted gateway to an Azure Arc-enabled Kubernetes cluster as a cluster extension.

Prerequisites

Deploy the self-hosted gateway to AKS

  1. Select Gateways from under Deployment and infrastructure.

  2. Select the self-hosted gateway resource you intend to deploy.

  3. Select Deployment.

  4. 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 <gateway-name>.yml file link next to Deployment to download the file.

  7. Adjust the config.service.endpoint, port mappings, and container name in the .yml file as needed.

  8. 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.
  9. Select the copy icon located at the right end of the Deploy text box to save the kubectl command to clipboard.

  10. 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
    
  11. 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.
  12. 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
    
  13. 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
    
  14. 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