Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 将google云中的外部IP地址设置为我保留的静态地址_Node.js_Google Cloud Platform_Google Apis Explorer - Fatal编程技术网

Node.js 将google云中的外部IP地址设置为我保留的静态地址

Node.js 将google云中的外部IP地址设置为我保留的静态地址,node.js,google-cloud-platform,google-apis-explorer,Node.js,Google Cloud Platform,Google Apis Explorer,我最近开始与谷歌云合作,并构建了一个节点应用程序,根据我设置的图像自动部署实例 脚本运行良好,我遇到的唯一问题是,我似乎无法分配使用配置保留的静态IP地址,我是node和google cloud的新手,不确定我做错了什么 任何帮助或指导都将不胜感激 我的配置看起来像: const config = { machineType: 'e2-micro', http:true, https:true, networkInterfaces:

我最近开始与谷歌云合作,并构建了一个节点应用程序,根据我设置的图像自动部署实例

脚本运行良好,我遇到的唯一问题是,我似乎无法分配使用配置保留的静态IP地址,我是node和google cloud的新手,不确定我做错了什么

任何帮助或指导都将不胜感激

我的配置看起来像:

const config = {
        machineType: 'e2-micro',
        http:true,
        https:true,
        networkInterfaces: [
            {
            accessConfigs: [
                {
                  type: 'ONE_TO_ONE_NAT',
                  name: 'External NAT',
                  natIP: '0.0.0.0',// this is an ip address that is passed into this as a variable in that format(it is not a scope issue)
                  setPublicPtr: false,
                  networkTier: 'PREMIUM', //ip address is reserved using this network tier as well
                }
              ],
              
 
      kind: 'compute#networkInterface'

      }],
        
        
        disks: [
          {
            boot: true,
            initializeParams: {
              sourceImage:
                'https://www.googleapis.com/compute/v1/projects' +
                '/myproject/global/images/devimage'
            }
          }
        ],
        metadata: {
           
            items: [
              {
                key: 'startup-script',
                value: 'sudo node index.js'
              }
            ],
            kind: 'compute#metadata'
          },
        
        };

请注意,到目前为止,还没有办法通过将静态IP分配给现有的计算引擎实例

为了对现有的计算引擎实例执行此操作,您需要利用

但是,要将静态IP分配给新的计算引擎实例,您确实可以通过API通过类似于以下内容的请求进行分配:

{
"name": "INSTANCE_NAME",
  "machineType": "zones/ZONE/machineTypes/MACHINE_TYPE",
  "networkInterfaces": [{
    "accessConfigs": [{
      "type": "ONE_TO_ONE_NAT",
      "name": "External NAT",
      "natIP": "IP_ADDRESS"
     }],
    "network": "global/networks/default"
  }],
  "disks": [{
     "autoDelete": "true",
     "boot": "true",
     "type": "PERSISTENT",
     "initializeParams": {
        "sourceImage": "projects/debian-cloud/global/images/v20150818"
     }
   }]
 }

在这种情况下,在创建新实例和分配IP地址时,可能没有提供实例的名称。

您能分享更多关于您的体系结构的信息吗?您在计算引擎上部署了吗?直接在internet上,还是在负载平衡器后面?