Connecting an application to a service using the Developer perspective

In addition to grouping multiple components within an application, you can also use the Topology view to connect components with each other. You can either use a binding connector or a visual one to connect components.

A binding connection between the components can be established only if the target node is an Operator-backed service. This is indicated by the Create a binding connector tool-tip which appears when you drag an arrow to such a target node. When an application is connected to a service by using a binding connector a ServiceBinding resource is created. Then, the Service Binding Operator controller projects the necessary binding data into the application deployment. After the request is successful, the application is redeployed establishing an interaction between the connected components.

A visual connector establishes only a visual connection between the components, depicting an intent to connect. No interaction between the components is established. If the target node is not an Operator-backed service the Create a visual connector tool-tip is displayed when you drag an arrow to a target node.

Discovering and identifying Operator-backed bindable services

As a user, if you want to create a bindable service, you must know which services are bindable. Bindable services are services that the applications can consume easily because they expose their binding data such as credentials, connection details, volume mounts, secrets, and other binding data in a standard way. The Developer perspective helps you discover and identify such bindable services.

Procedure

  • To discover and identify Operator-backed bindable services, consider the following alternative approaches:

    • Click +AddDeveloper CatalogOperator Backed to see the Operator-backed tiles. Operator-backed services that support service binding features have a Bindable badge on the tiles.

    • On the left pane of the Operator Backed page, select the Bindable checkbox.

      Click the help icon next to Service binding to see more information about bindable services.

    • Click +AddAdd and search for Operator-backed services. When you click the bindable service, you can view the Bindable badge in the side panel to the right.

Creating a visual connection between components

You can depict an intent to connect application components by using the visual connector.

This procedure walks you through an example of creating a visual connection between a PostgreSQL Database service and a Spring PetClinic sample application.

Prerequisites

  • You have created and deployed a Spring PetClinic sample application by using the Developer perspective.

  • You have created and deployed a Crunchy PostgreSQL database instance by using the Developer perspective. This instance has the following components: hippo-backup, hippo-instance, hippo-repo-host, and hippo-pgbouncer.

Procedure

  1. Hover over the Spring PetClinic sample application to see a dangling arrow on the node.

    odc connector

    Figure 1. Visual connector

  2. Click and drag the arrow towards the hippo-pgbouncer deployment to connect the Spring PetClinic sample application with it.

  3. Click the spring-petclinic deployment to see the Overview panel. Under the Details tab, click the edit icon in the Annotations section to see the Key = app.openshift.io/connects-to and Value = [{"apiVersion":"apps/v1","kind":"Deployment","name":"hippo-pgbouncer"}] annotation added to the deployment.

  4. Optional: You can repeat these steps to establish visual connections between other applications and components you create.

    odc connecting multiple applications

    Figure 2. Connecting multiple applications

Creating a binding connection between components

You can create a binding connection with Operator-backed components, as demonstrated in the following example, which uses a PostgreSQL Database service and a Spring PetClinic sample application. To create a binding connection with a service that the PostgreSQL Database Operator backs, you must first add the Red Hat-provided PostgreSQL Database Operator to the OperatorHub, and then install the Operator. The PostreSQL Database Operator then creates and manages the Database resource, which exposes the binding data in secrets, config maps, status, and spec attributes.

Prerequisites

  • You created and deployed a Spring PetClinic sample application in the Developer perspective.

  • You installed Service Binding Operator from the OperatorHub.

  • You installed the Crunchy Postgres for Kubernetes Operator from the OperatorHub in the v5 Update channel.

  • You created a PostgresCluster resource in the Developer perspective, which resulted in a Crunchy PostgreSQL database instance with the following components: hippo-backup, hippo-instance, hippo-repo-host, and hippo-pgbouncer.

Procedure

  1. In the Developer perspective, switch to the relevant project, for example, my-petclinic.

  2. In the Topology view, hover over the Spring PetClinic sample application to see a dangling arrow on the node.

  3. Drag and drop the arrow onto the hippo database icon in the Postgres Cluster to make a binding connection with the Spring PetClinic sample application.

  4. In the Create Service Binding dialog, keep the default name or add a different name for the service binding, and then click Create.

    odc sbc modal

    Figure 3. Service Binding dialog

  5. Optional: If there is difficulty in making a binding connection using the Topology view, go to +AddYAMLImport YAML.

  6. Optional: In the YAML editor, add the ServiceBinding resource:

    1. apiVersion: binding.operators.coreos.com/v1alpha1
    2. kind: ServiceBinding
    3. metadata:
    4. name: spring-petclinic-pgcluster
    5. namespace: my-petclinic
    6. spec:
    7. services:
    8. - group: postgres-operator.crunchydata.com
    9. version: v1beta1
    10. kind: PostgresCluster
    11. name: hippo
    12. application:
    13. name: spring-petclinic
    14. group: apps
    15. version: v1
    16. resource: deployments

    A service binding request is created and a binding connection is created through a ServiceBinding resource. When the database service connection request succeeds, the application is redeployed and the connection is established.

    odc binding connector

    Figure 4. Binding connector

    You can also use the context menu by dragging the dangling arrow to add and create a binding connection to an operator-backed service.

    odc context operator
    Figure 5. Context menu to create binding connection
  7. In the navigation menu, click Topology. The spring-petclinic deployment in the Topology view includes an Open URL link to view its web page.

  8. Click the Open URL link.

You can now view the Spring PetClinic sample application remotely to confirm that the application is now connected to the database service and that the data has been successfully projected to the application from the Crunchy PostgreSQL database service.

The Service Binding Operator has successfully created a working connection between the application and the database service.

Verifying the status of your service binding from the Topology view

The Developer perspective helps you verify the status of your service binding through the Topology view.

Procedure

  1. If a service binding was successful, click the binding connector. A side panel appears displaying the Connected status under the Details tab.

    Optionally, you can view the Connected status on the following pages from the Developer perspective:

    • The ServiceBindings page.

    • The ServiceBinding details page. In addition, the page title displays a Connected badge.

  2. If a service binding was unsuccessful, the binding connector shows a red arrowhead and a red cross in the middle of the connection. Click this connector to view the Error status in the side panel under the Details tab. Optionally, click the Error status to view specific information about the underlying problem.

    You can also view the Error status and a tooltip on the following pages from the Developer perspective:

    • The ServiceBindings page.

    • The ServiceBinding details page. In addition, the page title displays an Error badge.

In the ServiceBindings page, use the Filter dropdown to list the service bindings based on their status.

Additional resources