简体   繁体   English

使用https和TLS保护Kubernetes集群中的内部服务通信

[英]Securing internal service communication in a Kubernetes cluster with https and TLS

I'm working on a set of microservices and I need to secure the communication between the individual services (using https + TLS) 我正在开发一组微服务,我需要确保各个服务之间的通信安全(使用https + TLS)

The service deployments have a Service object set up with an assigned Cluster IP. 服务部署具有使用分配的群集IP设置的服务对象。 kube-dns automatically creates a DNS record with format *.cluster.local when the services are created. 创建服务时,kube-dns会自动创建格式为* .cluster.local的DNS记录。 The problem is that I'm not allowed to create TLS certificates with a SN containing "local" in my org. 问题是我不允许在组织中使用包含“ local”的SN创建TLS证书。 So any certificate that I create for the services would end up failing certificate validation because the SN doesn't match the domain name. 因此,我为服务创建的任何证书都将导致证书验证失败,因为SN与域名不匹配。 What I would like to do is to add a CNAME to kube-dns with my own custom domain name (ie servicename.cluster-internal.com) that would return the *.cluster.local domain, which would then resolve to the correct ClusterIP. 我想做的是使用自己的自定义域名(即servicename.cluster-internal.com)向Cube-dns添加一个CNAME,该域名将返回* .cluster.local域,然后该域将解析为正确的ClusterIP。 。 I would create the certificates with the SN set to my custom domains so that certificate validation would not fail when the services try to handshake and set up a secure connection. 我将在SN设置为我的自定义域的情况下创建证书,以便当服务尝试握手并建立安全连接时,证书验证不会失败。

I'm open to other ways of doing this, but I would prefer not to take dependencies on other types of DNS providers or to have to write my own. 我愿意接受其他方式执行此操作,但是我不希望不依赖于其他类型的DNS提供程序,也不必自己编写。

Before we solved the issue the correct way, we disabled certificate validation in the services that were running in the cluster. 在我们以正确的方式解决问题之前,我们在群集中运行的服务中禁用了证书验证。 I don't recommend this approach, but it's an easier way to unblock. 我不推荐这种方法,但是这是一种更轻松的解锁方法。

We solved this the correct way by customizing our DNS. 我们通过自定义DNS解决了正确的方法。 Since we deploy clusters with ACS-Engine, it was only a matter of redeploying our clusters with some updated options in the cluster definition . 由于我们使用ACS-Engine部署集群,因此只需在集群定义中使用一些更新的选项重新部署集群即可

See below: 见下文:

"kubernetesConfig": {
"kubeletConfig": {
    "--cluster-domain": "domain.you.own"
  }
}

This gave us the ability to cut certs in "domain.you.own" and turn certificate validation back on. 这使我们能够剪切“ domain.you.own”中的证书,然后重新启用证书验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM