LATEST VERSION: 1.9 - CHANGELOG
Redis for PCF v1.9

Using Redis for PCF

Redis for PCF can be used both via Pivotal Apps Manager and the CLI, both methods are outlined below. An example application has also been created to help application developers get started with Redis for PCF, and can be downloaded here.

See Redis for PCF Recommended Usage for recommendations regarding Redis for PCF service plans, and memory allocation.

Creating a Redis Service Instance

The following procedure describes how to create a Redis service instance in the Pivotal Cloud Foundry Elastic Runtime environment.

Available Plans

Before creating a Redis instance, it is worth being aware of the three available plans:

Plan Name Suitable for Tenancy Model per Instance Highly Available Backup Functionality
On-Demand Cache uses (small, medium and large) Dedicated VM No No
Shared-VM Lighter workloads that do not require dedicated resources Shared VM No Yes
Dedicated-VM Increased workloads that require dedicated resources Dedicated VM No Yes

Using Pivotal Apps Manager

  1. From within Pivotal Apps Manager, select Marketplace from the left navigation menu under Spaces. The Services Marketplace displays.
  2. Select Redis from the displayed tiles and click to view the available plans.
  3. Click on the appropriate Select this plan button to select the required Redis Service Plan.
  4. In the Instance Name field, enter a name that will identify this specific Redis service instance.
  5. From the Add to Space drop-down list, select the space where you or other users will deploy the applications that will bind to the service.
  6. Click the Add button.

Using the CLI

  1. Run cf marketplace to view the available service plans. This example shows the p-redis service which offers the dedicated-VM and shared-VM plan. The On-Demand service plan introduced in 1.8 is reffered to as p.redis in the marketplace:

    $ cf marketplace
    
    Getting services from marketplace in org system / space apps-manager as admin...
    OK
    
    service          plans                     description
    p-redis          shared-vm, dedicated-vm   Redis service to provide a key-value store
    
    TIP:  Use 'cf marketplace -s SERVICE' to view descriptions of individual plans of a given service.
    
  2. Run cf create service to create the service plan. Include the service plan name as listed in the Services Markeplace and a descriptive name you want to use for the service:

    $ cf create-service p-redis SERVICE-PLAN-NAME SERVICE-INSTANCE-NAME
    


    For example:

    $ cf create-service p-redis shared-vm redis
    

Binding an Application to the Redis Service

The following procedures describe how to bind a Redis service instance to your Pivotal Cloud Foundry application. This can be done via the Pivotal Apps Manager or Using the Pivotal Cloud Foundry CLI.

Using Pivotal Apps Manager

  1. Select the application that you wish to bind to the service. A page displays showing the already bound services and instances for this application.
  2. Click Bind. A list of available services displays.
  3. Click the Bind button for the Redis service you want to bind to this application.
  4. Start or restage your app from the command line:

    $ cf restage APPLICATION-NAME
    

Using the CLI

  1. Run cf services to view running service instances.

    $ cf services
    
    Getting services in org system / space apps-manager as admin...
    OK
    
    name                service         plan        bound apps    last operation
    my-redis-instance   p-redis         shared-vm                 create succeeded
    
  2. Run cf bind-service to bind the application to the service instance.

    $ cf bind-service APPLICATION-NAME SERVICE-INSTANCE-NAME
    

    For example:

    $ cf bind-service my-application redis
    
  3. Run cf restage to restage your application.

    $ cf restage APPLICATION-NAME
    

    Entries in the VCAP_SERVICES Environment Variable

Applications running in Cloud Foundry gain access to the bound service instances via an environment variable credentials hash called VCAP_SERVICES. An example hash is show below:

  
    {
      "p-redis": [{
        "credentials": {
             "host": "10.0.0.11",
             "password": "<redacted>",
             "port": 6379
        },
        "label": "p-redis",
        "name": "redis",
        "plan": "dedicated-vm",
        "provider": null,
        "syslogdrainurl": null,
        "tags": [
         "pivotal",
         "redis"
        ],
        "volume_mounts": []
      }]
    }
  

You can search for your service by its name, given when creating the service instance, or dynamically via the tags or label properties.

Deleting a Redis Instance

When you delete a Redis service instance, all applications that are bound to that service are automatically unbound and any data in the service instance is cleared.

Using Pivotal Apps Manager

  1. Locate the row under Services that contains the service instance you want to delete and click Delete.
  2. If you had applications that were bound to this service, you may need to restage or re-push your application for the application changes to take effect.

    $ cf restage APPLICATION-NAME
    

Using the CLI

  1. Run cf delete-service and include the service instance name that you would like to delete. Enter y when prompted to confirm.

    $ cf delete-service SERVICE-INSTANCE-NAME
    


    For example:

    $ cf delete-service my-redis-instance
    
    Really delete the service my-redis-instance?> y
    Deleting service my-redis-instance in org system / space apps-manager as admin...
    OK
    
  2. If you had applications that were bound to this service, you may need to restage or re-push your application for the application changes to take effect.

    $ cf restage APPLICATION-NAME
    
Create a pull request or raise an issue on the source for this page in GitHub