Create, bind, and unbind services

This topic tells you how create, bind, and unbind services on Tanzu Platform for Kubernetes.

Services are integral to the application development life cycle. This topic describes how to provision new services and bind them to your application so it can consume those services.

You can use the Tanzu services CLI plug-in or Tanzu Platform hub to create and bind based on your requirements. You can also choose the types of services to use within your Space:

  • Bitnami services:

    These provide a quick and easy way to add backing services in Spaces using dynamic provisioning. However, the Bitnami services are limited to single Availability Targets and replica sets. Bitnami services are more suitable for development environments, to allow easy self-service and quick iteration.

  • Pre-provisioned services:

    These require additional configuration. You can use them to make services from the provider of your choice available across multiple Availability Targets. Pre-provisioned services are more suitable for staging and production environments, to provide higher availability and resiliency.

After you create your services, you can bind and unbind them to your application or delete them.

For more information about binding services, see What are services and service bindings.

Create a dynamically provisioned Bitnami service

The Bitnami-based backing services use services from the Bitnami Catalog, which are deployed to the Space. Backing services from Bitnami are deployed in each Availability Target and replica.

If you have multiple Availability Targets or replicas, you will have multiple instances of the Bitnami services deployed. Because these currently do not replicate to each other, deployed applications are functional, but data is split-brained between replicas and Availability Targets.

Important

If using an Amazon EKS cluster that’s running Kubernetes v1.30 or later, you must mark a storage class as default using the storageclass.kubernetes.io/is-default-class annotation. In v1.30 and later, EKS does not include the default annotation on the gp2 StorageClass resource applied to newly created clusters. For more information, see the Amazon EKS documentation. If you do not do this, persistent volume claims will not acquire a volume. For more information about the default storage class, see the Kubernetes documentation.

Tanzu Platform hub
To create dynamically provisioned a Bitnami backing service using Tanzu Platform hub:
  1. Log in to Tanzu Platform hub.

  2. Navigate to Application Spaces > Spaces.

  3. Select the Space in which you want to create the service.

  4. Navigate to the Services tab.

  5. Click Create Service at the top right of the Services summary view.

  6. In the dialog box, click Create Service.

  7. Select the service you want from the table that lists the services available for dynamic provisioning.

  8. Click Next.

  9. Enter a Service Name.

  10. Enter service parameters, for example, for a RabbitmqCluster service you can set the Storage GB and Replicas parameters.

  11. (Optional) Bind the service to a ContainerApp or Deployment. If you don’t want to bind the application now you can do so later.

  12. Click Create Service to finish creating your dynamically provisioned service.

Tanzu CLI
To create a dynamically provisioned Bitnami backing service using the Tanzu CLI:
  1. View the services in the Space by running:

    tanzu services list
    

    There are likely no services.

  2. List the available service types by running:

    tanzu services type list
    

    Example output:

    NAME
    RabbitmqCluster
    KafkaInstance
    RedisCluster
    ValkeyCluster
    MongoDBInstance
    PostgreSQLInstance
    MySQLInstance
    CassandraCluster
    Neo4jInstance
    
  3. Create a Bitnami service by running:

    tanzu services create SERVICE-TYPE/SERVICE-NAME
    

    Where:

    • SERVICE-TYPE is the type of service you want to create.
    • SERVICE-NAME is the name you want for your service.

    For example:

    $ tanzu services create MySQLInstance/where-for-dinner-mysql
    $ tanzu services create RabbitmqCluster/where-for-dinner-rabbitmq
    
  4. Verify that the services are now available in the Space by running:

    tanzu services list
    

    You will see the service you just provisioned running in your space.

  5. To find out more information about your service, run:

    tanzu services get SERVICE-TYPE/SERVICE-NAME
    

    Where:

    • SERVICE-TYPE is the type of service.
    • SERVICE-NAME is the name of the service.

    For example:

    $ tanzu services get MySQLInstance/where-for-dinner-mysql
    $ tanzu services get RabbitmqCluster/where-for-dinner-rabbitmq
    

Edit the parameters of a dynamically provisioned Bitnami service

To edit the parameters of a dynamically provisioned Bitnami backing service using Tanzu Platform hub:

  1. Log in to Tanzu Platform hub.

  2. Navigate to Application Spaces > Spaces.

  3. Select the Space in which you want to create the service.

  4. Navigate to the Services tab.

  5. Click a dynamically provisioned Bitnami backing service to go to its Service Details page.

  6. In the Service Parameters section click Edit. A new page with the editable parameters of the service appears.

  7. Edit the values for the parameters as required.

  8. Save your changes by clicking Edit, or click Cancel to cancel.

Attach a backing service using pre-provisioned services

You can also attach existing services. This is usually used to consume production-level services such as cloud-based services.

Tanzu Platform hub
To create a pre-provisioned service in Tanzu Platform hub:
  1. Log in to Tanzu Platform hub.

  2. Navigate to Application Spaces > Spaces.

  3. Select the Space in which you want to create the service.

  4. Navigate to the Services tab.

  5. Click Create Service at the top right of the Services summary view.

  6. In the dialog box, click Attach Service.

  7. Enter the service details including Service Name, Description, and Contact Information.

  8. Enter the binding connector details. Binding connectors are the available slots on the service side to which an application can connect. You can a configure Binding connector per Availability Target or choose to use one configuration for all Availability Targets into which the space is scheduled. For the list of binding connector types and their available configuration details, see Spring Cloud Bindings.

    1. Enter a Connector Name. This can be any string. The name distinguishes the connector from others.

    2. Enter the Binding Type. This can be any of the supported service types as defined in Spring Boot Configuration. For example, postgresql.

    3. Choose if you want the same configuration for the connector for all Availability Targets.

      • If you want the same configuration for all Availability Targets: Click Add Binding Detail to enter the connection details for the connector.

      • If you want different configuration for each Availability Target: Select the Availability Targets that you want to configure, and then, for each Availability Target, click Add Binding Detail to enter the connection details for the connector.

      Connection details must have keys that correspond to the connector type in PostgreSQL relational database management system (RDBMS). For example, for type postgresql, if you populate the host, port, and database keys, the spring.r2dbc.url configuration in your application is set to 2dbc:postgresql://{host}:{port}/{database}.

      When adding a key in the Binding Details section, a drop-down menu might appear that suggests connection details keys based on the binding type.

    4. Click Add Binding Connector to configure another connector, or click Next to proceed to the next step.

  9. (Optional) Enter the application binding details. This section allows you to bind to an a application after the service is attached.

    1. Select the application you want to bind to the service.

    2. Select the application binding alias. This is the binding slot on the application side that will be connected to the binding connector on the service side.

    3. Select the defined binding connectors you want to bind this application to.

    4. Click Add Service Binding to configure another application.

  10. Click Create Service to finish creating the pre-provisioned service. You will be taken back to the Services Details page for your pre-provisioned service.

Tanzu CLI
To create a pre-provisioned service using the Tanzu CLI:
  1. In a Space, create a pre-provisioned service using the Tanzu Services CLI plug-in by running:

    tanzu services create PreProvisionedService/SERVICE-NAME
    

    Where SERVICE-NAME is the name you want for your service.

    For example:

    $ tanzu services create PreProvisionedService/prod-mysql
    

    This command configures a PreProvisionedService resource with a binding connector of the selected type. For the available types, see Spring Cloud Bindings.

  2. List the services that are available in the Space and to verify the PreProvisionedService was created by running:

    tanzu services list
    

Edit binding connectors

After you create a pre-provisioned service, you can edit the details for the binding connectors as follows:

  1. Log in to Tanzu Platform hub.

  2. Navigate to Application Spaces > Spaces.

  3. Select the Space in which the service is located.

  4. Navigate to the Services tab.

  5. Click a pre-provisioned service to go to its Service Details page.

  6. In the Binding Connectors section, where the UI lists the binding connectors for the service, click Edit.

  7. A new page opens where you can edit the details of existing binding connectors, such as the Description, Binding Details, and Egress Configutation. You cannot edit Connector Name and Binding Type.

  8. To add a new binding connector click Add Binding Connector and fill in the form as described in Attach a backing service using pre-provisioned services earlier.

  9. To remove an binding connector, click the trash icon at the upper right of the binding connector form.

    Note

    Removing a binding connector is not possible when there is only one binding connector because a pre-provisioned service must have at least one connector.

  10. Save your changes by clicking Edit, or click Cancel to cancel.

You will be navigated back to the Service Details page.

Bind or unbind a service

After you create a service in your Space, you can bind or unbind your services using either Tanzu Platform hub or the Tanzu CLI.

Tanzu Platform hub
To bind a service using Tanzu Platform hub:
  1. On the Service Details page, Click Bind at the top right of the screen.

  2. Select the ContainerApp or Deployment you want to bind to within your Space.

  3. Select the application binding alias. This alias is the binding slot on the application side that connects to the binding connector on the service side.

  4. Select the defined binding connectors that you want to bind the application to.

  5. Click Add Service Binding to add a binding to another application or click Bind Service to Application to finish binding your application.

To unbind a service using Tanzu Platform hub:

  1. Navigate to the Services Details page.

  2. In the Bound Applications widget under the actions column, click Unbind.

  3. Click the pop up box which confirms you want to remove the binding to the application.

Tanzu CLI
To bind a service using the Tanzu CLI, run:
tanzu service bind SERVICE-TYPE/SERVICE-NAME ContainerApp/CONTAINERAPP-NAME --as BINDING-NAME

Where:

  • SERVICE-TYPE is the type of service you want to bind to.
  • SERVICE-NAME is the name of the service you want to bind to.
  • CONTAINERAPP-NAME is the name of the ContainerApp you want to bind to the service.
  • BINDING-NAME is the name of the service binding.

For example:

$ tanzu service bind MySQLInstance/my-sql-service-1 ContainerApp/container-app-1 --as mysql-db

To unbind a service using the Tanzu CLI, run:

tanzu service unbind SERVICE-TYPE/SERVICE-NAME ContainerApp/CONTAINERAPP-NAME --alias BINDING-NAME

Where:

  • SERVICE-TYPE is the type of service you want to unbind from the app.
  • SERVICE-NAME is the name of the service you want to unbind from the app.
  • CONTAINERAPP-NAME is the name of the ContainerApp you want to unbind from the service.
  • BINDING-NAME is the name of the service binding to be removed.

For example:

$ tanzu service unbind MySQLInstance/my-sql-service-1 ContainerApp/container-app-1 --alias mysql-db
Note

Most tanzu service sub-commands support an interactive flow when they are executed without any parameters. For example, if you run $ tanzu service bind, you trigger the interactive flow where the Tanzu CLI prompts you to populate the service and the ContainerApp.

Delete a service

You can also delete a service using either Tanzu Platform hub or the Tanzu CLI.

Tanzu Platform hub
To delete a service using Tanzu Platform hub:
  1. Navigate to the Services Details page.

  2. Click Delete Service at the top right of the Service Details page.

  3. In the pop up box, confirm the name of the service to delete the service from your Space.

Tanzu CLI
To delete a service using the Tanzu CLI:
tanzu service delete SERVICE-TYPE/SERVICE-NAME ContainerApp/CONTAINERAPP-NAME

Where:

  • SERVICE-TYPE is the type of service you want to delete.
  • SERVICE-NAME is the name of the service you want to delete.
  • CONTAINERAPP-NAME is the name of your ContainerApp.

For example:

$ tanzu service delete MySQLInstance/my-sql-service-1 ContainerApp/container-app-1
check-circle-line exclamation-circle-line close-line
Scroll to top icon