【发布时间】:2019-10-19 13:27:33
【问题描述】:
编辑:我正在开发一个项目,该项目每天以 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 的域名,但这不起作用:(
谢谢
【问题讨论】:
标签: cookies dns load-balancing google-kubernetes-engine