Google云端运行:服务可以知道自己的网址吗? [英] Google cloud run: Can a service know its own url?

查看:73
本文介绍了Google云端运行:服务可以知道自己的网址吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道部署在云上的容器是否可以某种方式获得其自己的服务网址,还是不可能?

I'm wondering if a container deployed on cloud run can somehow obtain its own service url or is it impossible?

我想知道这一点,因为我想要一个可以自己创建Google云任务的云运行工作者.

I'm wanting to know this because I want a cloud run worker that creates google cloud tasks for itself.

如果可能,怎么办?

推荐答案

我写了我的github

I wrote an article to self call Cloud Run service to prevent Cold Start. The code that I wrote in Go is in my github

想法是调用元数据服务器以找到项目编号和区域(例如,您没有对此进行硬编码或使用env var),然后调用名称空间API.

The idea is to call the metadata server to find the project number and the region (like this you don't have this hardcoded or in env var), and then you call the namespace API.

如果您需要其他语言的帮助,请告诉我.

If you need help to write it in another language, let me know.

这篇关于Google云端运行:服务可以知道自己的网址吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆