Skip to content

Create a service instance

In this document we want to take a look on how you can create a service instance. With those services you can enrich your cloud experience with a persistence layer, a message queue or other useful tools. The Cloud Foundry makes this process especially easy with its integrated marketplace and service brokers. Here you will learn how to use them.

This is a First Steps Overview on the topic of services within the Cloud Foundry. You can get more detailed information in the service overview of the Cloud Foundry docs.

In this tab you will learn how to use the Cloud Foundry CLI to:

You can create and bind data services to your application on the Cloud Foundry with the integrated Cloud Foundry Marketplace. For this you have to login via the Cloud Foundry Command Line Interface to your organization and space (see “Interact with Cloud Foundry”). Afterwards you can navigate to the marketplace via the command:

Terminal window
cf marketplace
Getting all service offerings from marketplace in org <ORG_NAME> / space <SPACE_NAME> as <USER_NAME>...
offering plans description broker
appcloud-redis40 redis-cluster-medium, redis-cluster-small, redis-single-small, redis-cluster-big, redis-single-medium This is a service creating and managing dedicated Redis service instances, powered by the anynines Service Framework a9s-redis
Cloud Foundry-logme logme-cluster-big, logme-cluster-medium, logme-cluster-small, logme-single-small, logme-single-medium Dedicated ELK stacks to monitor applications and service instances powered by the anynines Service Framework a9s-logme
...

You can get more details about the individual services and their service plans by adding the flag -e and the service name you want to know more about. For example:

Terminal window
cf marketplace -e appcloud-mysql101
Getting service plan information for service offering Cloud Foundry-mysql101 in org Cloud Foundry Demo / space dev as admin...
broker: a9s-mysql
plan description free or paid costs available
mysql-cluster-medium a medium replica set paid yes
mysql-cluster-small a small replica set paid yes
mysql-single-medium a medium single instance paid yes
mysql-single-small a small single instance free yes
mysql-cluster-big a large replica set paid yes

Here you can see the different service plans available for the data service. You can find the detailed information about sizes and numbers behind a service plan in the Service Descriptions of the individual service.

You can easily create a new service instance of a service through the Cloud Foundry CLI as well by just using the following command:

Terminal window
cf create-service SERVICE_NAME SERVICE_PLAN SERVICE_INSTANCE_NAME [-c PARAMETERS_AS_JSON] [-t TAGS]

Here you can select the type and plan of your service, as listed in the marketplace above and can name your service instance. The name of your service instance is the unique identifier of that instance within your space and therefore has to be unique in your space. All service instances you create over the cf CLI have to be assigned to a space, which you have to select earlier with the cf target command.

The instance creation is done asynchronously. After you have triggered the process you can get the state of your data service via the cf services command like in the following example:

Terminal window
cf services
Getting the services in organization MyFirstOrg / space dev as <USERNAME>...
Name Service Plan Bound Apps Last operation Broker upgrade available
mydb Cloud Foundry-postgresql11 postgresql-single-small create in progress a9s-postgresql

You can also get more details about a specific service by using the following command:

Terminal window
cf service <INSTANCE_NAME>

The output will give you more useful information like the description, dashboard URL, start and update dates and more.

After the asynchronous operation of the instance creation is done and it is in state create succeeded you can start working with the data service.

You can delete your service instances again if you no longer need them. You can do a deletion with the following command:

Terminal window
cf delete-service SERVICE_INSTANCE_NAME