因此,我编写了一个在path /api/v1/books
上侦听并作为部署部署在我的k8s集群上的应用程序接口,创建了服务(restapi-service
),以便我们可以从另一个pods调用该服务。现在我创建了另一个部署(restapi-ui-deployment
),它只有一个.html
页面,并且它被部署在nginx上,它最终调用我们之前创建的服务来获得响应。现在,问题是当我执行restapi-ui-deployment
的pod时,我可以成功地卷曲http://restapi-service:8081/api/v1/books
。但是,如果我们尝试从已部署的.html页面执行相同的操作,我会得到
GET http://restapi-service:8081/api/v1/books net::ERR_NAME_NOT_RESOLVED
下面是部署为restapi-ui-deployment
的代码
if (xmlObj != null){
xmlObj.open("GET", "http://restapi-service:8081/api/v1/books", true)
xmlObj.onreadystatechange = processResponse;
xmlObj.send(null)
}
else{
console.log("There was an error getting the object.")
}
function processResponse(){
if (xmlObj.status == 200 && xmlObj.readyState == 4){
console.log("Got the response successfully")
response = xmlObj.responseText
}
else{
console.log("There was an issue getting the response.")
}
}
https://stackoverflow.com/questions/57348029
复制相似问题