kubernetes - Kubernetes 集群节点内部 IP
问题描述
我有一个 Kubernetes 集群,有 3 个控制、5 个工作人员和 2 个边缘节点。我需要获取每个节点的内部 IP,以创建允许使用 IPBlock 的流量的网络策略。
NAME STATUS ROLES VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
control1 Ready <none> v1.17.4 10.91.1.158 10.91.1.158 CentOS Linux 7 (Core) 4.18.0-147.5.1.el8_1.x86_64 docker://19.3.8
worker1 Ready <none> v1.17.4 10.91.1.159 10.91.1.159 CentOS Linux 7 (Core) 4.18.0-147.5.1.el8_1.x86_64 docker://19.3.8
worker2 Ready <none> v1.17.4 10.91.1.160 10.91.1.160 CentOS Linux 7 (Core) 4.18.0-147.5.1.el8_1.x86_64 docker://19.3.8
edge1 Ready <none> v1.17.4 10.91.1.161 10.91.1.161 CentOS Linux 7 (Core) 4.18.0-147.5.1.el8_1.x86_64 docker://19.3.8
示例网络策略:
Name: my-network-policy
Namespace: test
Spec:
PodSelector: <none> (Allowing the specific traffic to all pods in this namespace)
Allowing ingress traffic:
To Port: <any> (traffic allowed to all ports)
From:
IPBlock:
CIDR: 10.91.1.158/32
Except:
From:
IPBlock:
CIDR: 10.91.1.159/32
Except:
From:
NamespaceSelector: network-policy=test
From:
NamespaceSelector: network-policy in (test)
Not affecting egress traffic
Policy Types: Ingress
有什么方法可以使用 Kube API 获取这些带有 CIDR 的内部 IP 吗?或任何 kubectl 命令。
解决方案
推荐阅读
- python - 如何测试任何字符串是否在列表中?
- sql - 如何在 SQL Server 中的触发器上分隔字符串
- reactjs - renderStatic 的头盔错误
- java - 如何解决 spring-boot 中的 URI 编码问题?
- android - 具有应用内区域设置更改的 Android App Bundle
- python - 带 None 的 f 字符串格式说明符抛出 TypeError
- angular - 使用 ng-packagr 构建库时更改 aot metdata.json 文件生成的目录
- ruby-on-rails - spark post rails 550 5.7.1 未配置的发送域
- java - Android - 将drawablebitmap的边框作为MapView中的标记
- javascript - Websocket 与 SockJS 对象