从一个子集群通过服务名称访问其他子集群的service

如何访问部署在子集群中的服务

对于调度到子集群中的服务, 我们可以从其他子集群中通过服务名称直接访问.

1. 根据部署策略将应用部署到子集群中

请参考 this example. 来部署应用.

$ kubectl clusternet apply -f examples/scheduling-with-mcs-api/scheduling
namespace/baz created
deployment.apps/nginx-app created
service/nginx-svc created
serviceexport.multicluster.x-k8s.io/nginx-svc created
subscription.apps.clusternet.io/scheduling-with-mcs-api created

2. 测试服务的可用性

Fleetboard会帮我们把endpointslices 同步在所有子集群中,现在你可以在子集群中检查下这些endpointslice和clusternet部署的service。

$ kubectl get endpointslice -n syncer-operator
NAME                               ADDRESSTYPE   PORTS   ENDPOINTS                          AGE
cluster1-baz-nginx-svc-v5vw6   IPv4          80      20.112.0.3,20.112.1.5,20.112.1.4   36h
$ kubectl exec -it nginx-app-9fb9fffdd-dsjxm -n baz -c alpine -- sh
/ # curl nginx-svc.baz.svc.fleetboard.local
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>