公网访问相关

最近更新时间:2023-05-17 15:41:01

我的收藏
本文将提供在进行 构建深度学习容器镜像在 TKE Serverless 上运行深度学习 实践时可能遇到的常见问题解答。

容器如何访问公网?

因为任务过程中可能需要下载训练用数据集,所以可能需要进行访问公网操作。而容器初始状态无法访问公网,直接运行带下载数据集的指令将会进行如下报错:
W tensorflow/core/platform/cloud/google_auth_provider.cc:184] All attempts to get a Google authentication bearer token failed, returning an empty token. Retrieving token from files failed with "Not found: Could not locate the credentials file.". Retrieving token from GCE failed with "Failed precondition: Error executing an HTTP request: libcurl code 6 meaning 'Couldn't resolve host name', error details: Could not resolve host: metadata".
E tensorflow/core/platform/cloud/curl_http_request.cc:614] The transmission of request 0x5b328e0 (URI: https://www.googleapis.com/storage/v1/b/tfds-data/o/dataset_info%2Fmnist%2F3.0.1?fields=size%2Cgeneration%2Cupdated) has been stuck at 0 of 0 bytes for 61 seconds and will be aborted....
针对上述问题,提供两种访问公网的方式:
使用 NAT 网关:适用于某个 VPC 下的多个实例需要与公网通信。请按照 通过 NAT 网关访问外网 文档进行操作。
注意
创建的 NAT 网关和路由表需要与 TKE Serverless 集群同地域、同私有网络 VPC。
使用弹性公网 IP(EIP):适用于单个或少量实例需要实现公网互通。请按照 使用弹性公网 IP 访问外网 文档进行操作。