Connect your services across different environments using Red Hat Service Interconnect

Red Hat Service Interconnect enables application and service connectivity across different environments through Layer 7 addressing and routing. In this activity, you will learn how to build a virtual application network (also known as a service network) and create connections across multiple clouds using Red Hat Service Interconnect.

Access the Developer Sandbox

What will I need to complete this activity?

  • You will use the Developer Sandbox and your local laptop to deploy the front end and the database, respectively.
  • Podman or Docker installed on your local machine.
  • A no-cost Developer Sandbox account; follow these instructions to set up your sandbox if you haven't already done so. 
  • OpenShift command-line interface (CLI) installed on your local machine.

If you need help

If you get stuck, something isn’t working, or you simply have questions, contact us via email at devsandbox@redhat.com.


Initialize the gateway 

Now that you have set up your service network, it's time to initialize the gateway.

Note: How you initialize your gateway, depends on the environment you use.

If you’re using Docker on a Mac, create a file with the name simple_docker.yaml and paste the following into it:

name: simple
qdr-listeners:
    - name: amqp
      host: localhost
      port: 5672
bindings:
    - name: database
      host: host.docker.internal
      service:
        address: database:5432
        protocol: tcp
        ports:
            - 5432
      target_ports:
        - 5432

Initialize the Docker gateway:

skupper gateway init --config simple_docker.yaml --type docker

If you’re using Podman on RHEL, create a file with the name simple_podman.yaml and paste the following into it:

name: simple
qdr-listeners:
    - name: amqp
      host: localhost
      port: 5672
bindings:
    - name: database
      host: localhost
      service:
        address: database:5432
        protocol: tcp
        ports:
            - 5432
      target_ports:
        - 5432

Initialize the Podman gateway: 

skupper gateway init --config simple_podman.yaml --type podman

You should see an output similar to the one below:

Skupper gateway: 'username-mac-username'. Use 'skupper gateway status' to get more information.

Your local computer should now appear in the console, as shown in Figure 6.

The local computer is visible in the Sites tab along with the service network.
Figure 6: Successfully adding your local computer to your console.

Though you have linked both the cluster and your local environment, you have not exposed any services yet. By default, none of the services are exposed by Red Hat Service Interconnect, so you have to explicitly mention which services you want to expose over the service network.

Verify your services by going back to the console. Click on the Components tab (Figure 7). You should now see the Patient Portal Front end (patient-portal-frontend) process from your namespace (your site on OpenShift) as well as the gateway process running on your local machine (the “Private Datacenter”).

The patient portal front-end and gateway are visible in the Skupper Components tab.
Figure 7: The patient portal is displayed in the Components tab, along with the gateway.

By going to the Processes tab in the Topology section, you can see the current state of processes in our topology, including the site information (Figure 8).

The process tab showing a more detailed view.
Figure 8: The Processes view shows a detailed view of processes and their sites.

Expose the database service

Now expose the database service over the service network. This will allow the front end on the public cluster to connect to the database as if it was a local service. In reality, the OpenShift service is a proxy for the real service running on your computer;

Expose the database over the service network:

skupper expose service database --address database --port 5432 --protocol tcp

You should see an output similar to the one below:

service database exposed as database

You have now established a secure link between the sites and exposed the database as a service on your OpenShift cluster (Figure 9). 

In the Components tab of the Skupper UI, an arrow is shown pointing from the front-end application icon to the database icon.
Figure 9: The database is linked to the front-end application.

In the Processes tab, you can even see more detailed information about the established service connectivity (Figure 10). 

Note: If you don’t see the connecting arrows in the Components or Processes view right away, skip ahead to refreshing the Patient Portal front end in your browser (issuing some traffic over the connection) or wait a few moments. 

The processes view with an arrow connecting the two processes
Figure 10: Processes view showing the established connection.

Note: We are not exposing the database and payment processor service to the internet; only the services that are part of the service network enabled by Red Hat Service Interconnect can access them.

Get a list of services deployed in the sandbox namespace:

oc get service

You should see an output similar to the one below: 

NAME                      TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                               AGE
database                  ClusterIP   172.30.208.188   <none>        5432/TCP                              8m55s
modelmesh-serving         ClusterIP   None             <none>        8033/TCP,8008/TCP,8443/TCP,2112/TCP   7d3h
patient-portal-frontend   ClusterIP   172.30.144.46    <none>        8080/TCP                              77m
skupper                   ClusterIP   172.30.54.88     <none>        8010/TCP,8080/TCP,8081/TCP            47m
skupper-router            ClusterIP   172.30.102.71    <none>        55671/TCP,45671/TCP                   47m
skupper-router-local      ClusterIP   172.30.75.28     <none>        5671/TCP                              47m

The database service is the proxy service created by exposing the database deployment on your local environment over the service network. After a few seconds, go back to the browser tab where you opened the patient portal front end and refresh it (Figure 11). You should now be able to see the list of patients and doctors that you have retrieved from the database. This indicates that you have successfully connected your front end to the database using Red Hat Service Interconnect. 

The patient portal now shows a list of names below the “Log in as a patient” and the “Log in as a doctor” text.
Figure 11: The patient portal now displays patient and doctor names from the database.

Note: Wait a few moments for the patient data to show up. If the patient data doesn't appear after establishing the connection and refreshing the front end, try restarting the front-end pod.

oc delete pods -l deployment=patient-portal-frontend

Metrics

You can open a detailed view of the processes by clicking on them in the Processes view or listing them from the side menu (Figure 12). That's where you can view the metrics of established connections in your service network:

Detailed metrics view showing site, component and throughput
Figure 12: Metrics for the connection between the patient-portal-frontend and the database.

Conclusion

Congratulations! You built a secure service network between services on two different environments and allowed applications to connect and communicate over the secure network using Red Hat Service Interconnect. To learn more, visit our Red Hat Service Interconnect product page.

Previous resource
Install the front-end application on your OpenShift cluster