【问题标题】:stackdriver ip range to allow in kubernetes network policy on gke允许在 gke 上的 kubernetes 网络策略中使用的 stackdriver ip 范围
【发布时间】:2019-12-15 05:21:53
【问题描述】:

我们正在 gke 上运行一些 node.js 代码,并使用 googles @google-cloud/logging-winston 库直接登录到 stackdriver - 日志正在工作,这不是问题。 我们还使用 kubernetes 网络策略来限制进出我们的 Pod 的流量。

我无法确定出口策略中允许使用哪些 IP 范围以使堆栈驱动程序日志记录正常工作。 当我允许所有目的地时,日志记录正在工作,但我想缩小一点......

【问题讨论】:

  • 我建议允许所有目的地。原因是即使您可以拉取“googleapis.com”的范围,但范围可能会发生变化。此外,GCP 不会公开共享每个 API 的 IP 范围。

标签: google-kubernetes-engine stackdriver kubernetes-networkpolicy


【解决方案1】:

可以使用以下命令找到发送堆栈驱动程序日志记录 API 请求的 IP:

dig @8.8.8.8 googleapis.com

您应该得到以下这些 IP:

googleapis.com.         299     IN      A       74.125.141.147
googleapis.com.         299     IN      A       74.125.141.104
googleapis.com.         299     IN      A       74.125.141.103
googleapis.com.         299     IN      A       74.125.141.99
googleapis.com.         299     IN      A       74.125.141.106
googleapis.com.         299     IN      A       74.125.141.105

【讨论】:

    【解决方案2】:

    我不确定使用 dns 答案是否是一种有效的方法,因为当前的 dns 结果只是事实的一部分。 根据我使用的 dns 服务器、我的“挖掘”计算机所在的位置以及我解析 dns 名称的时间,对于同一问题,我会得到不同的答案:

    我的电脑使用我的本地解析器:

    dig googleapis.com +noall +answer
    
    ; <<>> DiG 9.10.6 <<>> googleapis.com +noall +answer
    ;; global options: +cmd
    googleapis.com.     261 IN  A   216.58.207.132
    

    我的电脑使用 google 的 dns 服务器:

    dig @8.8.8.8 googleapis.com +noall +answer
    
    ; <<>> DiG 9.10.6 <<>> @8.8.8.8 googleapis.com +noall +answer
    ; (1 server found)
    ;; global options: +cmd
    googleapis.com.     106 IN  A   172.217.22.196
    

    从在 gke 环境中运行的容器中运行“挖掘”:

     # dig googleapis.com +noall +answer
    
    ; <<>> DiG 9.12.4-P2 <<>> googleapis.com +noall +answer
    ;; global options: +cmd
    googleapis.com.     299 IN  A   172.217.16.196
    

    相同的 gke 容器,但大约 10 分钟后:

     # dig googleapis.com +noall +answer
    
    ; <<>> DiG 9.12.4-P2 <<>> googleapis.com +noall +answer
    ;; global options: +cmd
    googleapis.com.     299 IN  A   172.217.18.164
    

    这就是为什么我正在寻找一些文档,这就是告诉我有问题的 ip 网络...... Google 拥有如此多的 ip 网络,只有我的 4 个 dig 命令已经回答了 4 个不同网络中的 ip……

    【讨论】:

      猜你喜欢
      • 2021-01-17
      • 1970-01-01
      • 2020-10-06
      • 2019-01-21
      • 2022-01-13
      • 1970-01-01
      • 2018-10-10
      • 1970-01-01
      • 2021-04-28
      相关资源
      最近更新 更多