Using a9s Redis for PCF

This topic describes how to use a9s Redis for Pivotal Cloud Foundry (PCF) after it has been successfully installed.

Use a9s Redis for PCF with an App

To use a9s Redis for PCF with an app, create a service instance and bind the service instance to your app. For more information on managing service instances, see Managing Service Instances with the cf CLI.

View the Service

After the tile is installed, run cf marketplace to see a9s-redis32 and its service plans:

$ cf marketplace
Getting services from marketplace in org test / space test as admin...
OK
service      plans                                           description
a9s-redis32  redis-single-non-persistent-small, redis-single-non-persistent-big            This is the anynines Redis 32 service.

For more information on available service plans, see Configure Service Plans.

Create a Service Instance

To provision a Redis database, run cf create-service SERVICE-NAME PLAN-NAME INSTANCE-NAME where INSTANCE-NAME is any name you want to give the instance you create.

$ cf create-service a9s-redis32 redis-single-non-persistent-small my-redis-service

Note: This may take several minutes.

Run the cf services command to list all your service instances. To view the status of a specific service instance, run cf service INSTANCE-NAME.

Bind an App to a Service Instance

After you create your database, run cf bind-service APP-NAME INSTANCE-NAME to bind the service to your app:

$ cf bind-service a9s-redis-app my-redis-service

Restage or Restart Your App

To enable your app to access the service instance, run cf restage APP-NAME or cf restart APP-NAME.

Obtain Credentials for Accessing Your Service Instance

After you bind a service instance to an app, PCF stores the credentials of your Redis database in the environment variables of the app. Run cf env APP-NAME to display the environment variables.

You can find the credentials in the VCAP_SERVICES key.

$ cf env a9s-redis-app
Getting env variables for app a9s-redis-app in org test / space test as admin...
OK

System-Provided:
{
 "VCAP_SERVICES": {
  "a9s-redis": [
   {
    "credentials": {
     "host": "EXAMPLE-HOST",
     "password": "EXAMPLE-PWD",
     "port": 6379
    },
    "label": "a9s-redis",
    "name": "my-redis-service",
    "plan": "redis-single-non-persistent-small",
   }
  ]
 }
}
...

You can use the host and password values to connect to your database with a Redis client.

Delete a Service Instance

Warning: This operation cannot be undone, and the data is lost when the service instance is deleted. If you want to keep your data, you must back up your database before deleting the service instance.

Follow the steps below to unbind the service instance from all apps and then delete it.

List Available Services

Run cf services to list available service instances and get the name of the service instance you want to delete.

$ cf services

Getting services in org test / space test as admin...
OK

name                 service       plan                                  bound apps        last operation
my-redis-service     a9s-redis     redis-single-non-persistent-small     a9s-redis-app     create succeeded

This example shows that my-redis-service is bound to the a9s-redis-app app.

Unbind a Service Instance

Run cf unbind-service APP-NAME INSTANCE-NAME to unbind the service from your app:

$ cf unbind-service a9s-redis-app my-redis-service

Delete a Service Instance

Run cf delete-service INSTANCE-NAME to delete the service instance:

$ cf delete-service my-redis-service

Note: This may take several minutes.

Deleting a service deprovisions the corresponding infrastructure resources. Run the cf services command to view the deletion status.

Change Service Plan

Run cf update-service INSTANCE-NAME -p PLAN-NAME to modify your service instance to use a different service plan. You may want to use a larger service plan that provides more CPU, RAM, and storage. For more information, see Update a Service Instance.

$ cf update-service my-redis-service -p a-bigger-plan

You may choose to upgrade your service plan from redis-single-non-persistent-small to redis-single-non-persistent-big.

Add a Graphite Endpoint

If you want to monitor your service instance with Graphite, you can specify an endpoint to send data to with the cf update-service command. This command expects the -c flag and a JSON string containing the graphite and metrics_prefix keys.

$ cf update-service my-redis-service -c '{ "graphite": ["yourspace.your-graphite-endpoint.com:12345"], "metrics_prefix": "your-api-key.my-redis" }'

Add a Syslog Endpoint

You can stream your syslog to a third-party service using the cf update-service command and the -c flag. In this case, the command expects a JSON string containing the syslog key.

$ cf update-service my-redis-service -c '{ "syslog": ["logs4.your-syslog-endpoint.com:54321"] }'
Create a pull request or raise an issue on the source for this page in GitHub