简体   繁体   English

在kube.netes中,Cluster IP的用法可以替代Pod IP的用法吗?

[英]In Kubernetes, usage of Cluster IP can replace the usage of Pod IP?

In K8S, there are cluster IP and pod IP and I understand the difference between two.在K8S中,有cluster IP和pod IP,我明白两者的区别。

I have two questions.我有两个问题。

  1. Usage of Cluster IP can replace usage of Pod IP? Cluster IP 的使用可以替代 Pod IP 的使用吗? The cluster IP is used for the.networking between the servers in the same cluster.集群 IP 用于同一集群中服务器之间的联网。 Pod IP is also for the internal.network traffic. Pod IP 也用于内部网络流量。 In our company's legacy service, the pod IP is used so it needs a server which manage the pod IP of every server.在我们公司的遗留服务中,使用了 pod IP,因此它需要一个服务器来管理每个服务器的 pod IP。 We are making the new service now.我们现在正在制作新服务。 When connecting the service mesh in Micro Service Architecture (MSA) server which is scalable (by duplication of pods), can I use the cluster IP?在可扩展(通过 pod 复制)的微服务架构 (MSA) 服务器中连接服务网格时,我可以使用集群 IP 吗? If so, why the service mesh tools like ISTIO and Spring Cloud Eureka is required in MSA?如果是这样,为什么 MSA 中需要像 ISTIO 和 Spring Cloud Eureka 这样的服务网格工具? The cluster IP can be used instead of these tools.可以使用集群 IP 代替这些工具。

  2. Why the pod IP is designed to be changed when the pod is recreated?为什么 pod IP 设计为在重新创建 pod 时更改?

When you install Kube.netes, it installs a private.network which are used by the pods.当您安装 Kube.netes 时,它会安装一个 private.network 供 pod 使用。

This is a class like 10.0.0.0/24.这是一个类似于 10.0.0.0/24 的 class。 So your node in this case have 256 ipaddresses available to run your pods.因此,在这种情况下,您的节点有 256 个 ipaddresses 可用于运行您的 pod。

Those Ipaddresses are not accessible from outside your node directly.这些 Ipaddresses 无法直接从您的节点外部访问。

Each time a Pod starts one of the available Ipaddresses is assigned to the pod.每次 Pod 启动时,都会将一个可用的 IP 地址分配给该 Pod。 Thats also the so called clusterIP.那也就是所谓的clusterIP。

Normally you have more than one node.通常您有多个节点。 So on each node there is configured such a.network for the Pods.所以在每个节点上都为 Pod 配置了这样一个网络。

To communicate between the pods clusterIps on different nodes a Network Fabric must be installed in the cluster.要在不同节点上的 pod clusterIps 之间进行通信,必须在集群中安装 Network Fabric。 (ex. Flannel or Calico). (例如法兰绒或印花布)。

The Pods clusterIp you cant predict.您无法预测的 Pods clusterIp。 It can change every time a Pod is recreated.每次重新创建 Pod 时它都会更改。 To connect Pods between them create a service with type: ClusterIP.要在它们之间连接 Pod,请创建类型为 ClusterIP 的服务。

Kube.netes has an internal DNS. You can access a pod like so: Kube.netes 有一个内部 DNS。您可以像这样访问一个 pod:

servicename.namespace.svc.cluster.local:port

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

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