首页 文章

在计算引擎内部IP上连接到Redis时,Google Cloud功能会超时

提问于
浏览
1

我使用https://console.cloud.google.com/launcher/details/bitnami-launchpad/redis-ha创建了一个Redis实例

和网络接口是:

enter image description here

我正在尝试从Firebase触发器连接到此Redis实例 .

The question is: what firewall rule do I need to connect from a cloud function to a compute instance?

请提供尽可能多的详细信息,例如IP范围,入口/出口等,以及是否必须将Redis客户端连接到内部IP或外部IP上的实例 .

这是代码:

const redis = require('redis');

let redisInstance = redis.createClient({
    /* surely external IP needn't be used
       here as it's all GCP infra? */
    host: '10.1.2.3',
    port: 6379
})

redisInstance.on('connect', () => {
    console.log(`connected`);
});

redisInstance.on('error', (err) => {
    console.log(`Connection error ${err}`);
});

日志中的错误是

连接错误错误:Redis连接到10.1.2.3:6379失败 - 连接ETIMEDOUT 10.1.2.3:6379

我看了Google Cloud Function cannot connect to Redis但是在设置规则时对选项不够具体 .

我尝试过的

我尝试使用以下设置设置防火墙规则:

  • ingress

  • network:默认

  • 源过滤器:我的firebase服务帐户

  • protocols / ports:全部

  • 目标:全部

只是关于服务帐户的说明:

由Firebase创建

  • 在IAM中具有 Editor 角色
    已知
  • 可以使用我的Firebase触发器中的BigQuery和其他Firebase服务

这个相同的防火墙规则已经生效了几个小时了,我还重新部署了测试Redis的触发器,但仍然获得了ETIMEDOUT

enter image description here

更新

2018 -06-25早上

我打电话给GCP Gold支持,这个问题对运营商来说并不明显,所以他们会打开一个案子,调查并留下一些笔记 .

2018 -06-25下午

使用许可防火墙规则(源 0.0.0.0/0 ,目标"all targets")并连接到Redis实例's external IP address works (of course!). However, I mentioned many times now on the phone call I don' t希望Redis实例对Internet开放,如果有某种解决方案涉及网桥/ VPN,那么我可以连接到来自 Cloud 功能的 10.x.x.x 地址 .

经营者说他们会在2天内回复我 .

2018 -06-25下午晚些时候

我自己回答了it doesn't seem to be possible从 Cloud 功能连接到计算引擎内部IP .

2 回答

  • 3

    看起来目前可以从Google Cloud Funtions连接到Google Compute Engine内部IP,因此我的所有(以及我有用的金牌支持运营商)的努力都是徒劳的 .

    这是(开放)问题:https://issuetracker.google.com/issues/36859738

  • 1

    正如the question you referred to中所述,当您创建new firewall rule时,您将源过滤器字段从IP范围更改为服务帐户 . 在以下步骤中,您不需要指定任何IP,只需指定 Cloud 功能的服务帐户的名称 .

相关问题