将所有 TCP 连接记录到 kubelet。如何?
Logging all TCP connections to kubelet. How?
我想查看与 kubelet VM 建立的所有连接。
我在 GKE 集群中安装了一个 Service Type=NodePort,这个特定的节点端口暴露在我的防火墙中。该服务运行良好。现在,我想收集有关与服务建立的 TCP 连接的日志。特别是,我对审核连接到它的客户端的 IP 感兴趣。
根据“Firewall Rules Logging overview”,我已经使用 gcloud 启用了日志记录:
gcloud compute firewall-rules update my-firewall-rule --enable-logging
强制建立到端口的 TCP 连接并获取日志(通过下面的命令)后,我没有看到列出任何 TCP 连接 – 我只看到两个记录的操作,都与我有关 运行 gcloud
上面的命令:
gcloud logging read 'resource.type="gce_firewall_rule"' --format=json
我是不是遗漏了什么?
更新。一些进一步的细节:
"GCE Subnetwork" 在“Logging > Logs ingestion”中启用
查看 VM 日志也没有显示任何日志:
gcloud logging read 'resource.type="gce_instance" resource.labels.instance_id="0000000000000000000"' --format=json
(这里全0不是真实ID)
我不使用旧网络
您似乎想查看防火墙的日志。所以你可以使用 "gce_subnetwork" 作为资源类型:
$gcloud beta logging read 'resource.type="gce_subnetwork"
我想查看与 kubelet VM 建立的所有连接。
我在 GKE 集群中安装了一个 Service Type=NodePort,这个特定的节点端口暴露在我的防火墙中。该服务运行良好。现在,我想收集有关与服务建立的 TCP 连接的日志。特别是,我对审核连接到它的客户端的 IP 感兴趣。
根据“Firewall Rules Logging overview”,我已经使用 gcloud 启用了日志记录:
gcloud compute firewall-rules update my-firewall-rule --enable-logging
强制建立到端口的 TCP 连接并获取日志(通过下面的命令)后,我没有看到列出任何 TCP 连接 – 我只看到两个记录的操作,都与我有关 运行 gcloud
上面的命令:
gcloud logging read 'resource.type="gce_firewall_rule"' --format=json
我是不是遗漏了什么?
更新。一些进一步的细节:
"GCE Subnetwork" 在“Logging > Logs ingestion”中启用
查看 VM 日志也没有显示任何日志:
gcloud logging read 'resource.type="gce_instance" resource.labels.instance_id="0000000000000000000"' --format=json
(这里全0不是真实ID)
我不使用旧网络
您似乎想查看防火墙的日志。所以你可以使用 "gce_subnetwork" 作为资源类型:
$gcloud beta logging read 'resource.type="gce_subnetwork"