Enabling cross cluster communication using Skupper
Securely enable communications across OpenShift clusters.
This Solution Pattern uses an HTTP Hello World application with a frontend service and a backend service. The frontend uses the backend to process requests. The frontend is deployed in the west namespace of the West cluster, and the backend is deployed in the east namespace of a East cluster.
While these instructions use this particular application for demonstration purposes, the steps are the same for any Skupper deployment.
-
You must have
oc
installed
1. Installing the Skupper cli in your local environment
The skupper
command-line tool is the primary entrypoint for
installing and configuring the Skupper infrastructure.
-
Download the latest release of the Skupper command for your platform,
For Linux or WSL on Windows, enter:
curl -fL https://github.com/skupperproject/skupper-cli/releases/download/0.2.0/skupper-cli-0.2.0-linux-amd64.tgz | tar -xzf -
For macOS, enter:
curl -fL https://github.com/skupperproject/skupper-cli/releases/download/0.2.0/skupper-cli-0.2.0-mac-amd64.tgz | tar -xzf -
This produces an executable file named
skupper
in your current directory.See the Skupper CLI release page for information on other platforms. -
Add
skupper
to your pathFor example:
mkdir -p $HOME/bin export PATH=$PATH:$HOME/bin mv skupper $HOME/bin
Try the steps again. If it’s still not working contact your administrator, or seek help at https://skupper.io
2. Configuring access to multiple namespaces
Skupper is designed for use with multiple namespaces, typically on
different clusters. The skupper
command uses your kubeconfig and
current context to select the namespace where it operates.
2.1. Configure separate terminal sessions
Start a terminal session for each of your namespaces. Set the
KUBECONFIG
environment variable to a different path in each session.
-
Start a terminal for the West cluster:
export KUBECONFIG=$HOME/.kube/config-west
-
Start a terminal for the East cluster:
export KUBECONFIG=$HOME/.kube/config-east
2.2. Log in to your clusters
-
Log into the West cluster.
-
Navigate to the OpenShift Console
-
Choose Copy Login Command from the menu displayed when you click on your username.
-
Enter the command into the West terminal session.
-
-
Log into the East cluster.
-
Log into the East cluster using the command displayed in the output, for example:
$ oc login -u developer -p developer https://api.crc.testing:6443
-
2.3. Set the current namespaces
-
In the terminal for the West cluster:
kubectl config set-context --current --namespace west
-
In the terminal for the East cluster:
kubectl new-project east kubectl config set-context --current --namespace east
Try the steps again. If it’s still not working contact your administrator, or seek help at https://skupper.io
3. Installing the Skupper router and connecting the namespaces
Running the skupper init
command in east namespace installs the router.
Connecting namespaces requires you use the following commands:
-
The
skupper connection-token
command generates a secret token that signifies permission to connect. The token also carries the connection details. -
The
skupper connect
command then uses the connection token to establish a connection to the namespace that generated it.
Anyone who has the connection token can connect to your namespace. Make sure that only those you trust have access to it. |
3.1. Install the router in both namespaces
-
In the terminal for the West:
$ skupper init
The following output is displayed:
Skupper is now installed in namespace 'west'. Use 'skupper status' to get more information.
-
In the terminal for the East:
$ skupper init --edge
The following output is displayed:
Skupper is now installed in namespace 'east'. Use 'skupper status' to get more information.
Using the --edge argument in the east namespace disables network ingress at the
Skupper router layer.
|
3.2. Connect your namespaces
-
Generate a token in the west:
skupper connection-token $HOME/secret.yaml
-
Use the token in the east to form a connection
skupper connect $HOME/secret.yaml
Try the steps again. If it’s still not working contact your administrator, or seek help at https://skupper.io
4. Exposing the services
You now have a Skupper network capable of multi-cluster communication, but no services are attached to it.
This task describes how to use the skupper
expose
command to make a Kubernetes deployment on one namespace
available on all the connected namespaces.
4.1. Deploy the frontend and backend services
-
Start the frontend in the West cluster:
oc create deployment hello-world-frontend --image quay.io/skupper/hello-world-frontend
-
Start the backend in the East cluster:
oc create deployment hello-world-backend --image quay.io/skupper/hello-world-backend
4.2. Expose the backend service
At this point, we have the frontend and backend services running, but the frontend has no way to contact the backend. The frontend and backend are in different namespaces and different clusters), and the backend has no public ingress.
Use the skupper expose
command in the East to make hello-world-backend
available in the West.
-
In the terminal for the East:
skupper expose deployment hello-world-backend --port 8080 --protocol http
-
Check that the backend service is represented in the West:
oc get services
The output should be similar to the following:
$ kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-world-backend ClusterIP 10.96.175.18 <none> 8080/TCP 1m30s
4.3. Create a route
-
In the West, expose a route:
oc expose deployment hello-world-frontend --port 8080 --type LoadBalancer
-
Navigate to the OpenShift Console
-
Switch to the west project.
-
In the Overview, expand the hello-world-frontend application.
-
Click Create Route. This creates a route and displays a URL.
Try the steps again. If it’s still not working contact your administrator, or seek help at https://skupper.io