title | description | author | manager | ms.service | ms.workload | ms.topic | ms.author | ms.date |
---|---|---|---|---|---|---|---|---|
Deploy a self-hosted gateway to Kubernetes with YAML |
Learn how to deploy a self-hosted gateway component of Azure API Management to Kubernetes with YAML |
dlepow |
gwallace |
api-management |
mobile |
article |
danlep |
05/25/2021 |
This article describes the steps for deploying the self-hosted gateway component of Azure API Management to a Kubernetes cluster.
Note
You can also deploy self-hosted gateway to an Azure Arc-enabled Kubernetes cluster as a cluster extension.
- Complete the following quickstart: Create an Azure API Management instance.
- 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.
- Provision a self-hosted gateway resource in your API Management instance.
-
Select Gateways under Deployment and infrastructure.
-
Select the self-hosted gateway resource that you want to deploy.
-
Select Deployment.
-
An access token in the Token text box was auto-generated for you, based on the default Expiry and Secret key values. If needed, choose values in either or both controls to generate a new token.
-
Select the Kubernetes tab under Deployment scripts.
-
Select the <gateway-name>.yml file link and download the YAML file.
-
Select the copy icon at the lower-right corner of the Deploy text box to save the
kubectl
commands to the clipboard. -
Paste commands to the terminal (or command) window. The first command creates a Kubernetes secret that contains the access token generated in step 4. The second command applies the configuration file downloaded in step 6 to the Kubernetes cluster and expects the file to be in the current directory.
-
Run the commands to create the necessary Kubernetes objects in the default namespace and start self-hosted gateway pods from the container image downloaded from the Microsoft Container Registry.
-
Run the following command to check if the deployment succeeded. Note that it might take a little time for all the objects to be created and for the pods to initialize.
kubectl get deployments NAME READY UP-TO-DATE AVAILABLE AGE <gateway-name> 1/1 1 1 18s
-
Run the following command to check if the service was successfully created. Note that your service IPs and ports will be different.
kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE <gateway-name> LoadBalancer 10.99.236.168 <pending> 80:31620/TCP,443:30456/TCP 9m1s
-
Go back to the Azure portal and select Overview.
-
Confirm that Status shows a green check mark, followed by a node count that matches the number of replicas specified in the YAML file. This status means the deployed self-hosted gateway pods are successfully communicating with the API Management service and have a regular "heartbeat."
Tip
Run the kubectl logs deployment/<gateway-name>
command to view logs from a randomly selected pod if there's more than one.
Run kubectl logs -h
for a complete set of command options, such as how to view logs for a specific pod or container.
- To learn more about the self-hosted gateway, see Self-hosted gateway overview.
- Learn how to deploy API Management self-hosted gateway to Azure Arc-enabled Kubernetes clusters.
- Learn more about guidance for running the self-hosted gateway on Kubernetes in production.