Relay Cluster
This task involves creating multi-hop connectivity between a client and a server using relay clusters. Multi-hop connectivity using a relay may be necessary for several reasons, such as:
- When the client needs to use an indirect connection due to network path limitations.
- Using multiple relays allows for explicit selection between multiple network paths without impacting or changing the underlying routing information.
- Using multiple relays provides failover for the network paths.
In this task, we’ll establish multi-hop connectivity across clusters using ClusterLink to access a remote nginx server. In this case, the client will not access the service directly in the server cluster but will pass through a relay cluster. The example uses three clusters:
- Client cluster - runs ClusterLink along with a client.
- Relay cluster - runs ClusterLink and connects the services between the client and the server.
- Server cluster - runs ClusterLink along with an nginx server.
System illustration:
Run basic nginx Tutorial
This is an extension of the basic nginx toturial. Please run it first and set up the nginx server and client cluster.
Create relay Cluster with ClusterLink
Open third terminal for the relay cluster:
Relay cluster:
cd nginx-tutorial kind create cluster --name=relay
Setup
KUBECONFIG
the relay cluster:Relay cluster:
kubectl config use-context kind-relay cp ~/.kube/config $PWD/config-relay export KUBECONFIG=$PWD/config-relay
Create peer certificates for the relay:
Relay cluster:
clusterlink create peer-cert --name relay
Note
The relay cluster certificates should use the same Fabric CA files as the server and the client.
Deploy ClusterLink on the relay cluster:
Relay cluster:
clusterlink deploy peer --name relay --ingress=NodePort --ingress-port=30443
Enable cross-cluster access using the relay
Establish connectivity between the relay and the server by adding the server peer, importing the nginx service from the server, and adding the allow policy.
Relay cluster:
export TEST_FILES=https://raw.githubusercontent.com/clusterlink-net/clusterlink/main/demos/nginx/testdata export SERVER_IP=`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' server-control-plane` curl -s $TEST_FILES/clusterlink/peer-server.yaml | envsubst | kubectl apply -f - kubectl apply -f $TEST_FILES/clusterlink/import-nginx.yaml kubectl apply -f $TEST_FILES/clusterlink/allow-policy.yaml
Establish connectivity between the relay and the client by adding the relay peer to the client cluster, exporting the nginx service in the relay, and importing it into the client.
Relay cluster:
kubectl apply -f $TEST_FILES/clusterlink/export-nginx.yaml
Client cluster:
export TEST_FILES=https://raw.githubusercontent.com/clusterlink-net/clusterlink/main/demos/nginx/testdata export RELAY_IP=`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' relay-control-plane` curl -s $TEST_FILES/clusterlink/peer-relay.yaml | envsubst | kubectl apply -f - kubectl apply -f $TEST_FILES/clusterlink/import-nginx-relay.yaml
Test service connectivity
Test the connectivity between the clusters (through the relay) with a batch job of the curl
command:
Client cluster:
kubectl apply -f $TEST_FILES/nginx-relay-job.yaml
Verify the job succeeded:
kubectl logs jobs/curl-nginx-relay-homepage
Sample output
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
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>
Cleanup
Delete the kind clusters: Client cluster:
kind delete cluster --name=client
Server cluster:
kind delete cluster --name=server
kind delete cluster --name=relay
Remove the tutorial directory:
cd .. && rm -rf nginx-tutorial
Unset the environment variables: Client cluster:
unset KUBECONFIG TEST_FILES
Server cluster:
unset KUBECONFIG TEST_FILES
Rekay cluster:
unset KUBECONFIG TEST_FILES
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.