Fabian Schmied
Fabian Schmied

Reputation: 4154

How can I easily set up HTTPS between ASP.NET Core Pods inside a Kubernetes cluster?

Assume an application consisting of different web services implemented with ASP.NET Core, each of which is deployed as a Pod in a Kubernetes cluster (AKS to be exact). Now, suppose I want to secure the cluster-internal communication between those services via HTTPS. This requires me to:

  1. get TLS certificates for each of the services,
  2. have the Pods trust those TLS certificates (or, rather, the signing CA), and
  3. rotate the certificates when their validity period ends.

What I've already learned:

In my mind, this could be really simple: Just set up Kestrel with LettuceEncrypt, configure it against the cluster root CA, and have all the Pods trust that CA (by importing the corresponding certificate as a trusted root).

Is it that simple? Or what am I missing?

Update 2022-07-26: Note that I need to support Windows containers.

Upvotes: 1

Views: 1207

Answers (1)

Philip Welz
Philip Welz

Reputation: 2807

For this purpose you should use mTLS. To archive this with an AKS Cluster you can easily active the Open Service Mesh Add-On. With OSM enabled, you can now encrypt communications between service endpoints deployed in the cluster. The cool thing is the the OSM Add-on integrates with Azure Monitor.

Here an example to do mTLS with ingress-nginx :

To proxy connections to HTTPS backends, we will configure the Ingress and IngressBackend configurations to use https as the backend protocol, and have OSM issue a certificate that Nginx will use as the client certificate to proxy HTTPS connections to TLS backends. The client certificate and CA certificate will be stored in a Kubernetes secret that Nginx will use to authenticate service mesh backends.

Upvotes: 2

Related Questions