首页 > 解决方案 > Kubernetes - 外部 IP 与内部 IP

问题描述

当我运行以下命令从我的本地集群获取信息时,

kubectl 集群信息转储

我看到每个节点的以下内容。

在主人

"addresses": [
                    {
                        "type": "ExternalIP",
                        "address": "10.10.15.47"
                    },
                    {
                        "type": "InternalIP",
                        "address": "10.10.15.66"
                    },
                    {
                        "type": "InternalIP",
                        "address": "10.10.15.47"
                    },
                    {
                        "type": "InternalIP",
                        "address": "169.254.6.180"
                    },
                    {
                        "type": "Hostname",
                        "address": "k8s-dp-masterecad4834ec"
                    }
                ],

在工作节点 1 上

"addresses": [
                    {
                        "type": "ExternalIP",
                        "address": "10.10.15.57"
                    },
                    {
                        "type": "InternalIP",
                        "address": "10.10.15.57"
                    },
                    {
                        "type": "Hostname",
                        "address": "k8s-dp-worker5887dd1314"
                    }
                ],

在工作节点 2 上

"addresses": [
                    {
                        "type": "ExternalIP",
                        "address": "10.10.15.33"
                    },
                    {
                        "type": "InternalIP",
                        "address": "10.10.15.33"
                    },
                    {
                        "type": "Hostname",
                        "address": "k8s-dp-worker6d2f4b4c53"
                    }
                ],

我的问题是..

1.) 为什么有些节点有不同的 ExternalIP 和 InternalIP 而有些没有?2.) 同样对于具有不同 ExternalIP 和 InternalIP 的节点在相同的 CIDR 范围内,两者都可以从外部访问。这两个 IP 地址的内部/外部是什么?(目的是什么?) 3.) 为什么有些节点有随机的 169.xxx IP 地址?

尝试仍然了解有关 Kubernetes 的更多信息,如果有人可以帮助我理解这将非常有帮助。我使用 contiv 作为网络插件

标签: kubernetes

解决方案


What you see is part of the status of these nodes:

  • InternalIP: IP address of the node accessible only from within the cluster
  • ExternalIP: IP address of the node accessible from everywhere
  • Hostname: hostname of the node as reported by the kernel

These fields are set when a node is added to the cluster and their exact meaning depends on the cluster configuration and is not completely standardised, as stated in the Kubernetes documentation.

So, the values that you see are like this, because your specific Kubernetes configuration sets them like this. With another configuration you get different values.

For example, on Amazon EKS, each node has a distinct InternalIP, ExternalIP, InternalDNS, ExternalDNS, and Hostname (identical to InternalIP). Amazon EKS sets these fields to the corresponding values of the node in the cloud infrastructure.


推荐阅读