为什么部署在两个不同命名空间上的Kube对象能够相互通信



我是Kubernetes的新手,有一个与我正在尝试实践的部署有关的问题。下面是场景::

- I have two namespace :: n1 and n2 
- I have a curl pod deployed at n1 I
- have a nginx service of type Nodeport running at n2. My service has  
exposed a deployment that is managing the pod
My question is, though the two resources are running in two different namespace why is my curl pod running in n1 is able to curl service running at n2 with its IP?ie 
[ k exec curl -n n1 -- curl http://18.108.65.98:8080]
[ k exec curl -n n1 -- curl http://my-nginx.n2:8080 ]

这是预期的行为吗?如果是,那么当在两个不同的命名空间中运行的两个服务试图通信而无法通信时,为什么这种行为不同?

Why do we have to then set the RBAC access for them to communicate.

无论命名空间如何,pod都可以通过IP进行通信。通常或在现实世界部署中,Pods通过服务相互通信,根据需要,服务可以是CLUSTERIP、NODEPORT或LOADBALANCER类型。Yon还可以通过其DNS名称访问服务,其格式为:-

<service-name>.<service-namespace>.svc.cluster.local

当部署在两个不同命名空间中的POD内运行的两个应用程序尝试通信时,它们需要拥有一组权限来调用某些操作。这些操作是通过RBAC(基于角色和基于集群(允许和控制的,RBAC允许在两个不同的环境中运行的服务相互通信。

最新更新