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

  • Ensure that you have created and deployed a Spring PetClinic sample application using the Developer perspective.

  • Ensure that you have created and deployed a Crunchy PostgreSQL database instance using the Developer perspective. This instance has the following three components: hippo-backup, hippo-instance, 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 on the spring-petclinic-rest 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

  • Ensure that you have created and deployed a Spring PetClinic sample application using the Developer perspective.

  • Ensure that you have installed the Service Binding Operator from the OperatorHub.

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

  • Ensure that you have created and deployed a Crunchy PostgreSQL database instance using the Developer perspective. This instance has the following three components: hippo-backup, hippo-instance, and hippo-pgbouncer.

Procedure

  1. Switch to the Developer perspective and ensure that you are in the appropriate project, for example, my-postgresql. 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:

    1. apiVersion: binding.operators.coreos.com/v1alpha1
    2. kind: ServiceBinding
    3. metadata:
    4. name: spring-petclinic-rest
    5. namespace: my-postgresql
    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-rest
    14. group: apps
    15. version: v1
    16. 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

Additional resources