This is a cache of https://docs.okd.io/4.13/applications/connecting_applications_to_services/odc-connecting-an-application-to-a-service-using-the-developer-perspective.html. It is a snapshot of the page at 2024-11-27T00:26:11.078+0000.
Connecting an application to a service using the Developer perspective - Connecting applications to services | Building applications | OKD 4.13
×

Use the Topology view for the following purposes:

  • Grouping multiple components within an application.

  • Connecting components with each other.

  • Connecting multiple resources to services with labels.

You can either use a binding or a visual connector 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 Bindable.

      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.

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. In the Developer perspective, switch to the relevant project, for example, my-petclinic.

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

    odc connector
    Figure 1. Visual connector
  3. Click and drag the arrow towards the hippo-pgbouncer deployment to connect the Spring PetClinic sample application with it.

  4. 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.

  5. 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:

    apiVersion: binding.operators.coreos.com/v1alpha1
    kind: ServiceBinding
    metadata:
        name: spring-petclinic-pgcluster
        namespace: my-petclinic
    spec:
        services:
        - group: postgres-operator.crunchydata.com
          version: v1beta1
          kind: PostgresCluster
          name: hippo
        application:
          name: spring-petclinic
          group: apps
          version: v1
          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.

Visualizing the binding connections to resources

As a user, use Label Selector in the Topology view to visualize a service binding and simplify the process of binding applications to backing services. When creating ServiceBinding resources, specify labels by using Label Selector to find and connect applications instead of using the name of the application. The Service Binding Operator then consumes these ServiceBinding resources and specified labels to find the applications to create a service binding with.

To navigate to a list of all connected resources, click the label selector associated with the ServiceBinding resource.

To view the Label Selector, consider the following approaches:

  • After you import a ServiceBinding resource, view the Label Selector associated with the service binding on the ServiceBinding details page.

    odc label selector sb details
    Figure 6. ServiceBinding details page

To use Label Selector and to create one or more connections at once, you must import the YAML file of the ServiceBinding resource.

  • After the connection is established and when you click the binding connector, the service binding connector Details side panel appears. You can view the Label Selector associated with the service binding on this panel.

    odc label selector topology side panel
    Figure 7. Topology label selector side panel

    When you delete a binding connector (a single connection within Topology along with a service binding), the action removes all connections that are tied to the deleted service binding. While deleting a binding connector, a confirmation dialog appears, which informs that all connectors will be deleted.

    odc delete service binding
    Figure 8. Delete ServiceBinding confirmation dialog