Deploy self-hosted gateway to Kubernetes with Helm

APPLIES TO: Developer | Premium

Helm is an open-source packaging tool that helps you install and manage the lifecycle of Kubernetes applications. It allows you to manage Kubernetes charts, which are packages of pre-configured Kubernetes resources.

This article provides the steps for deploying self-hosted gateway component of Azure API Management to a Kubernetes cluster by using Helm.

Note

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

Prerequisites

  • Create a Kubernetes cluster, or have access to an existing one.

    Tip

    Single-node clusters work well for development and evaluation purposes. Use Kubernetes Certified multi-node clusters on-premises or in the cloud for production workloads.

Adding the Helm repository

  1. Add Azure API Management as a new Helm repository.

    helm repo add azure-apim-gateway https://azure.github.io/api-management-self-hosted-gateway/helm-charts/
    
  2. Update repo to fetch the latest Helm charts.

    helm repo update
    
  3. Verify your Helm configuration by listing all available charts.

    $ helm search repo azure-apim-gateway
    NAME                                            CHART VERSION   APP VERSION     DESCRIPTION
    azure-apim-gateway/azure-api-management-gateway 1.0.0           2.0.0           A Helm chart to deploy an Azure API Management ...
    

Deploy the self-hosted gateway to Kubernetes

  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. Take note of your Token and Configuration URL

  6. Install the self-hosted gateway by using the Helm chart

    helm install azure-api-management-gateway \
                 --set gateway.configuration.uri='<your configuration url>' \
                 --set gateway.auth.key='<your token>' \
                 azure-apim-gateway/azure-api-management-gateway
    
  7. Execute the command. The command instructs your Kubernetes cluster to:

    • Download the image of the self-hosted gateway from the Microsoft Container Registry and run it as a container.
    • Configure the container to expose HTTP (8080) and HTTPS (8081) ports.

    Important

    By default, the gateway is using a ClusterIP service and is only exposed inside the cluster. You can change this by specifying the type of Kubernetes service during installation.

    For example, you can expose it through a load balancer by adding --set service.type=LoadBalancer

  8. Run the following command to check the gateway pod is running. Your pod name will be different.

    kubectl get pods
    NAME                                           READY     STATUS    RESTARTS   AGE
    azure-api-management-gateway-59f5fb94c-s9stz   1/1       Running   0          1m
    
  9. Run the following 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
    azure-api-management-gateway   ClusterIP   10.0.229.55     <none>        8080/TCP,8081/TCP     1m
    
  10. 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