cookies - 有没有办法为 GKE 负载均衡器获取域而不是 ip?
问题描述
编辑:我正在开发一个项目,该项目每天以 100% 自动的方式在 GKE 上部署多个项目。我们的项目是用nodejs开发的,下面是一段伪代码:
projects = get_all_projects_today() // returns 15 projects for today (for example)
for project in projects
deploy_to_GKE(project) //generate a deployment manifest for project and post it to GKE (using api call)
public_ip = create_service_on_GKE(project, type=Loadbalancer) //generate a service manifest (type loadbalancer) for project, post it to GKE (using api call) and returns the public created ip address
get_domain_from_ip(public_ip) //how to do this !
部署的项目必须可以通过域名访问,而不是像这样的 ip,例如:
appx.mysite.com, or
mysite.com/appx
结束编辑
这是我使用的服务清单示例:
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "backend-__ID__"
},
"spec": {
"selector": {
"app": "backend-__ID__"
},
"type": "LoadBalancer",
"ports": [
{
"name": "app1",
"protocol": "TCP",
"port": 8080,
"targetPort": "8080"
},
{
"name": "app2",
"protocol": "TCP",
"port": "3010",
"targetPort": "3010"
}
]
}
}
从外部访问项目的唯一方法是使用 ip 地址(Endpoint),但这会阻止使用 cookie(我们不能在 ip 上设置 cookie,我们应该使用域名)。
那么有没有办法从 GKE 命名域中自动获取 Endpoints 以从外部访问项目?
我尝试使用反向 DNS 查找来获取外部 ip 的域名,但这不起作用:(
谢谢
解决方案
我找到了!
使用反向 dns 查找,我发现 google 提供了这样的域:[LOADBALANCER_IP].bc.googleusercontent.com。
反向 dns 查找站点示例:https ://mxtoolbox.com/ReverseLookup.aspx
推荐阅读
- python - 如何将单元格访问到数据框中
- javascript - 调试 Flask 应用程序
- r - 如何将列表转换为具有重新排列和单独命名列的复杂表?
- javascript - 当我点击按钮时隐藏的内容不显示,这是为什么呢?
- typescript - DI:类的构造函数注入如何多次调用
- java - 使用 dispatchCommand 在命令中添加方法
- testing - 使用 FsCheck 我在测试中得到不同的结果,一次 100% 通过,另一次错误
- sql - 如何计算来自相同 ID 的不同值?
- makefile - 为调试和发布目标配置 makefile
- javascript - 描述一下这段代码是如何工作的 Symbol.iterator