This is a cache of https://docs.openshift.com/container-platform/4.9/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-22T18:37:46.640+0000.
Connecting an application to a service using the Developer perspective - Connecting applications to services | Building applications | OpenShift Container Platform 4.9
×

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

Creating a visual connection between components

You can depict an intent to connect application components 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 using the Developer perspective.

  • You have created and deployed a Crunchy PostgreSQL database instance using the Developer perspective. This instance has the following four 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.

Similarly you can create other applications and components and establish visual connections between them.

odc connecting multiple applications
Figure 2. Connecting multiple applications

Creating a binding connection between components

You can establish a binding connection with Operator-backed components.

This procedure walks through an example of creating a binding connection between a PostgreSQL Database service and a Spring PetClinic sample application. To create a binding connection with a service that is backed by the PostgreSQL Database Operator, 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 information in secrets, config maps, status, and spec attributes.

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

  • You have installed the Service Binding Operator from the OperatorHub.

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

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

Procedure
  1. Switch to the Developer perspective and ensure that you are in the appropriate project, for example, my-petclinic. In the Topology view, hover over the Spring PetClinic sample application to see a dangling arrow on the node.

  2. Click and drag the arrow towards the hippo database Postgres Cluster to make a binding connection with the Spring PetClinic sample application.

    Alternatively, in the +Add view, click the YAML option to see the Import YAML screen. Use the YAML editor and 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 the Service Binding Operator controller projects the database service connection information into the application deployment as files using a volume mount. After the request is successful, the application is redeployed and the connection is established.

odc binding connector
Figure 3. 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 4. Context menu to create binding connection