Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在kubernete中作为clusterIP公开的访问服务api_C#_Docker_Kubernetes_Google Cloud Platform_Google Kubernetes Engine - Fatal编程技术网

C# 在kubernete中作为clusterIP公开的访问服务api

C# 在kubernete中作为clusterIP公开的访问服务api,c#,docker,kubernetes,google-cloud-platform,google-kubernetes-engine,C#,Docker,Kubernetes,Google Cloud Platform,Google Kubernetes Engine,我有两个应用程序,都部署在同一个集群中 现在从web上,有一个从api获取数据的ajax请求,但它总是返回502连接被拒绝 这是我的jquery代码(web) 注意:当我将服务类型从ClusterIP更改为LoadBalancer时,它工作正常。ClusterIP服务(通常)仅在集群内工作。从技术上讲,您可以在外部使用CNI地址空间,但这很少见,您可能不应该指望它。在集群之外公开某些内容的正确方法是NodePort服务或LoadBalancer(即NodePort加上云负载平衡器)。介绍了这一点

我有两个应用程序,都部署在同一个集群中

现在从web上,有一个从api获取数据的ajax请求,但它总是返回
502连接被拒绝

这是我的jquery代码(web)


注意:当我将服务类型从
ClusterIP
更改为
LoadBalancer
时,它工作正常。

ClusterIP服务(通常)仅在集群内工作。从技术上讲,您可以在外部使用CNI地址空间,但这很少见,您可能不应该指望它。在集群之外公开某些内容的正确方法是NodePort服务或LoadBalancer(即NodePort加上云负载平衡器)。

介绍了这一点。作为LoadBalancer,它将使用云提供商负载平衡器公开服务。ClusterIP是一个内部ip,对其他docker容器不可见,但我的web和api都在同一个集群中,因此应该可以工作web浏览器不在集群中,这看起来像fromtend代码?是的,但此代码是在应用程序中编写的,该应用程序在同一集群中。是的,但它实际上在工作站上的web浏览器中运行。应用程序在哪里并不重要。现在我已经将服务tyoe更改为NodePort,但它仍然无法访问。
$.get("http://10.43.244.118/api/users", function (data) {
        console.log(data);
        $('#table').bootstrapTable({
            data: data
        });
    });
1\Ajax is a front-end call to api.
2\The front-end call is to directly communicate with the user(Browser) and the called end and the api service.
3\ ClusterIP is internal to the cluster,User(Browser) cannot communicate with it.
4\ NodePort and LoadBalancer can expose the internal network, of course, it can be accessed normally.