【问题标题】:How to configure Firewall Rules and DNS settings on GCP with VPC Service Controls when using Cloud Composer and Cloud Functions in the same project?在同一项目中使用 Cloud Composer 和 Cloud Functions 时,如何使用 VPC Service Controls 在 GCP 上配置防火墙规则和 DNS 设置?
【发布时间】:2021-07-25 19:15:09
【问题描述】:

我们在为单个项目配置 VPC Service Controls 下的两个 GCP 组件(GCP Cloud Composer、GCP Functions)时遇到问题。我们可以使用 VPC Service Controls 单独配置它们,但是一旦添加第二个组件,我们就会遇到麻烦。

一旦我们为 Cloud Function 配置了防火墙规则和 DNS 设置,Composer 就会开始失败。 Composer 监控工具(用于 webserver、SQL server 等)显示 composer 不健康。

我们做错了什么?

我们使用过的文档:
https://cloud.google.com/functions/docs/securing/using-vpc-service-controls
https://cloud.google.com/composer/docs/configuring-vpc-sc

对于 Composer,我们使用以下设置:

  • 3 个节点
  • 标准机器类型
  • 镜像版本:composer-1.16.3-airflow-1.10.15
  • python: v3
  • 私有 IP 编写器

我们为 VPC Service Controls 启用的 API:

  • Google Cloud Dataproc API
  • 云函数 API
  • 谷歌云发布/订阅 API
  • 云 SQL API
  • 谷歌云存储 API
  • 谷歌计算引擎 API
  • Google Kubernetes 引擎 API
  • Google 容器注册表 API
  • 云监控 API
  • Cloud Composer API
  • 工件注册表 API

防火墙设置(基于文档):

Name Type Targets Filters Protocols / Ports Action Priority
composer-egress-gke-cluster-all-port Egress Apply to all IP ranges: 10.10.0.0/16 tcp, udp Allow 1000
composer-egress-healthcheck Egress Apply to all IP ranges: 130.211.0.0/22, 35.191.0.0/16 tcp:80,443 Allow 1000
composer-egress-port53 Egress Apply to all IP ranges: 0.0.0.0/0 tcp:53, udp:53 Allow 1000
composer-egress-webserver Egress Apply to all IP ranges: 172.31.251.0/24 tcp:3306,3307 Allow 1000
restricted-google-apis Egress Apply to all IP ranges: 199.36.153.4/30 tcp:443 Allow 1000
composer-deny-all Egress Apply to all IP ranges: 0.0.0.0/0 all Deny 2000
composer-ingress-helthcheck Ingress Apply to all IP ranges: 130.211.0.0/22, 35.191.0.0/16 tcp:80,443 Allow 1000
ingress-iap Ingress Apply to all IP ranges: 35.235.240.0/20 tcp Allow 1000
gke-europe-west1-composer-dns-xxx-xxx-all Ingress gke-europe-west1-composer-dns-xxx-xxx-node IP ranges: 10.124.0.0/14 tcp;udp;esp;ah;sctp;icmp Allow 1000
gke-europe-west1-composer-dns-xxx-xxx-master Ingress gke-europe-west1-composer-dns-xxx-xxx-node IP ranges: 172.16.8.0/28 tcp:10250,443 Allow 1000
gke-europe-west1-composer-dns-xxx-xxx-vms Ingress gke-europe-west1-composer-dns-xxx-xxx-node IP ranges: 10.10.0.0/16 tcp:1-65535;udp:1-65535;icmp Allow 1000

DNS 设置(基于文档):

DNS 名称:googleapis.com。 类型:私人

DNS name Type TTl(Seconds) Data
*.googleapis.com. CNAME 300 restricted.googleapis.com.
googleapis.com. SOA 21600 ns-gcp-private.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 3600 259200 300
googleapis.com. NS 21600 ns-gcp-private.googledomains.com.

DNS 名称:cloudfunctions.net。 类型:私人

DNS name Type TTl(Seconds) Data
*.cloudfunctions.net. A 300 199.36.153.4,199.36.153.5,199.36.153.6,199.36.153.7
cloudfunctions.net NS 21600 ns-gcp-private.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 3600 259200 300
cloudfunctions.net. SOA 21600 ns-gcp-private.googledomains.com.

DNS 名称:pkg.dev。 类型:私人

DNS name Type TTl(Seconds) Data
*.pkg.dev. CNAME 300 pkg.dev.
pkg.dev. SOA 21600 ns-gcp-private.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 3600 259200 300
pkg.dev. NS 21600 ns-gcp-private.googledomains.com.
pkg.dev. A 300 199.36.153.4,199.36.153.5,199.36.153.6,199.36.153.7

DNS 名称:gcr.io。 类型:私人

DNS name Type TTl(Seconds) Data
*.gcr.io. CNAME 300 gcr.io.
gcr.io. SOA 21600 ns-gcp-private.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 3600 259200 300
gcr.io. NS 21600 ns-gcp-private.googledomains.com.
gcr.io. A 300 199.36.153.4,199.36.153.5,199.36.153.6,199.36.153.7

感谢您的任何想法或帮助。

【问题讨论】:

  • 您能否提供一些您收到的日志或实际错误消息?从你的描述很难说是什么导致了这里的问题。
  • 这个问题是很难获取相关日志... Composer在设置防火墙规则和DNS设置后根据它的监控UI开始失败。这个 UI 似乎以不一致的方式总结了结果。更改时间分辨率后,有时显示失败,有时一切都是绿色的。在 Composer 的子网上启用日志记录后,StackDriver 被太多记录转储以正确调试它。同时我们也发现了问题所在,我将在下面描述它。

标签: google-cloud-platform google-cloud-functions google-cloud-composer google-cloud-dns google-vpc


【解决方案1】:

同时我们已经解决了问题:

  • 最成问题的是googleapis.com. 中缺少包含IP 地址的A 类型的DNS 记录。
  • 第二个问题是来自 Cloud Function 的 VPC SC 设置文档的防火墙规则阻止了以下之间的通信:
    • 子网上 Composer 的节点
    • 在工作节点和主节点(为作曲家创建的 Kubernetes 集群的)之间,该节点在不同的项目中自动创建,并通过网络对等连接到作曲家工作人员的子网

当这些服务中的两个应该一起使用时,这两个文档显然没有涵盖这种特殊情况。解决上述问题后,它已经开始工作了。

我们仍然遇到的问题:

  • 此类问题很难调试,因为 composer 的监控 UI 显示信息的方式似乎不一致
  • 在子网上启用 StackDriver 日志后,很难使用它进行调试,因为它的信息太多,而且它们记录在“信息”级别,而不是“警告”或“错误”级别

【讨论】:

    猜你喜欢
    • 2016-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-06
    • 2021-07-29
    • 1970-01-01
    • 2020-01-14
    • 1970-01-01
    相关资源
    最近更新 更多