You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Microservices are perfect for building APIs. You can use [Azure Kubernetes Service (AKS)](https://azure.microsoft.com/services/kubernetes-service/) to quickly deploy and operate a [microservices-based architecture](/azure/architecture/guide/architecture-styles/microservices) in the cloud. You can then use [Azure API Management](https://aka.ms/apimrocks) to publish your microservices as APIs for internal and external consumption. This article describes the options for deploying API Management with AKS. It assumes a basic knowledge of Kubernetes, API Management, and Azure networking.
20
+
Microservices are perfect for building APIs. You can use [Azure Kubernetes Service (AKS)](https://azure.microsoft.com/services/kubernetes-service/) to quickly deploy and operate a [microservices-based architecture](/azure/architecture/guide/architecture-styles/microservices) in the cloud. You can then use [Azure API Management](https://aka.ms/apimrocks) to publish your microservices as APIs for internal and external consumption. This article describes the options for using API Management to publish AKS microservices-based architectures as APIs. It assumes a basic knowledge of Kubernetes, API Management, and Azure networking.
21
21
22
22
## Background
23
23
@@ -35,7 +35,7 @@ In a Kubernetes cluster, containers are deployed in [Pods](https://kubernetes.io
35
35
36
36
To solve this problem, Kubernetes introduced the concept of [Services](https://kubernetes.io/docs/concepts/services-networking/service/). A Kubernetes Service is an abstraction layer that defines a logical group of Pods and enables external traffic exposure, load balancing, and service discovery for those Pods.
37
37
38
-
When you're ready to publish your microservices as APIs by using API Management, you need to think about how to map your Services in Kubernetes to APIs in API Management. There are no set rules for this mapping. It depends on how you designed and partitioned your business capabilities or domains into microservices at the beginning. For instance, if the pods behind a Service are responsible for all operations on a given resource (for example, Customer), you might map the Service to one API. If operations on a resource are partitioned into multiple microservices (for example, GetOrder and PlaceOrder), you might aggregate multiple Services into a single API in API Management. (See the following diagram.)
38
+
When you're ready to publish your microservices as APIs by using API Management, you need to think about how to map your Services in Kubernetes to APIs in API Management. There are no set rules for this mapping. It depends on how you designed and partitioned your business capabilities or domains into microservices at the beginning. For instance, if the Pods behind a Service are responsible for all operations on a given resource (for example, Customer), you might map the Service to one API. If operations on a resource are partitioned into multiple microservices (for example, GetOrder and PlaceOrder), you might aggregate multiple Services into a single API in API Management. (See the following diagram.)
39
39
40
40
The mappings can also evolve. Because API Management creates a facade in front of the microservices, it allows you to refactor and right-size your microservices over time.
41
41
@@ -49,7 +49,7 @@ An AKS cluster is always deployed in a virtual network, but an API Management in
49
49
50
50
### Option 1: Expose Services publicly
51
51
52
-
You can publicly expose Services in an AKS cluster by using NodePort, LoadBalancer, or ExternalName [Service types](/azure/aks/concepts-network-services). When you do, Services are accessible directly from the public internet. After deploying API Management in front of the cluster, you need to ensure that all inbound traffic goes through API Management by applying authentication in the microservices. For instance, API Management can include an access token in each request made to the cluster. Each microservice must validate the token before processing the request.
52
+
You can publicly expose Services in an AKS cluster by using the NodePort, LoadBalancer, or ExternalName [Service types](/azure/aks/concepts-network-services). When you do, Services are accessible directly from the public internet. After deploying API Management in front of the cluster, you need to ensure that all inbound traffic goes through API Management by applying authentication in the microservices. For instance, API Management can include an access token in each request made to the cluster. Each microservice must validate the token before processing the request.
53
53
54
54
This option might provide the easiest way to deploy API Management in front of AKS, especially if you already have authentication logic implemented in your microservices.
55
55
@@ -66,7 +66,7 @@ Cons:
66
66
67
67
### Option 2: Install an ingress controller
68
68
69
-
Although option 1 might be easier, it has notable drawbacks, as noted earlier. If an API Management instance doesn't reside in the cluster virtual network, Mutual TLS authentication (mTLS) is a robust way of ensuring that traffic is secure and trusted in both directions between an API Management instance and an AKS cluster.
69
+
Although option 1 might be easier, it has notable drawbacks, as noted earlier. If an API Management instance doesn't reside in the cluster virtual network, mutual TLS authentication (mTLS) is a robust way of ensuring that traffic is secure and trusted in both directions between an API Management instance and an AKS cluster.
70
70
71
71
Mutual TLS authentication is [natively supported](./api-management-howto-mutual-certificates.md) by API Management. You can enable it in Kubernetes by [installing an ingress controller](/azure/aks/ingress-own-tls). (See the following diagram.) As a result, authentication is performed in the ingress controller, which simplifies the microservices. Additionally, you can add the IP addresses of API Management to the ingress allowlist to ensure that only API Management has access to the cluster. If you use API Management [Premium](./api-management-using-with-internal-vnet.md) or [Standard V2](./integrate-vnet-outbound.md) tier, you can achieve network-level isolation.
72
72
@@ -79,7 +79,7 @@ Pros:
79
79
80
80
Cons:
81
81
* Increases complexity of cluster configuration because you need to install, configure, and maintain the ingress controller and manage certificates used for mTLS
82
-
* Adds security risk because of public visibility of ingress controller endpoints, unless you use API Management Standard v2 or Premium tier.
82
+
* Adds security risk because of public visibility of ingress controller endpoints, unless you use API Management Standard v2 or Premium tier
83
83
84
84
When you publish APIs via API Management, it's easy and typical to secure access to those APIs by using subscription keys. Developers who need to consume the published APIs must include a valid subscription key in HTTP requests when they make calls to those APIs. Otherwise, the calls are rejected immediately by the API Management gateway. They aren't forwarded to the backend services.
85
85
@@ -102,10 +102,10 @@ If all API consumers reside within the cluster virtual network, you can use the
102
102
The AKS cluster isn't publicly visible in either case. In contrast to Option 2, the ingress controller might not be necessary. Depending on your scenario and configuration, authentication might still be required between API Management and your microservices. For instance, if you use a service mesh, you always need mutual TLS authentication.
103
103
104
104
Pros:
105
-
*The most secure option because the AKS cluster has no public endpoint
105
+
*Provides the most secure option because the AKS cluster has no public endpoint
106
106
* Simplifies cluster configuration because there's no public endpoint
107
-
*Ability to hide both API Management and AKS inside the virtual network by using the internal mode
108
-
*Ability to control network traffic by using Azure networking capabilities like NSG
107
+
*Provides the ability to hide both API Management and AKS inside the virtual network by using the internal mode
108
+
*Provides the ability to control network traffic by using Azure networking capabilities like NSG
109
109
110
110
Cons:
111
111
* Increases the complexity of deploying and configuring API Management to work inside the virtual network
0 commit comments