This document guides you through binding your App to a Redis instance not listed in the Kf marketplace (including Memorystore) with the Spring Cloud Foundry Connector. This results in the Redis credentials being injected into your App, just like binding to services provisioned through marketplace plans.
Before you begin
- Ensure you have Redis installed and accessible by your Kf cluster.
- Ensure Redis has already been set up for your App.
- Ensure you have targeted the Space running your App.
Create the user-provided instance
For Kf to successfully bind an App to your Redis instance, the minimum environment variable is the URI (for example redis://:password@host:port
). Additional key-value pairs may be included if desired. The following examples should be sufficient for basic deployments.
For Redis with no AUTH configured
kf cups service-instance-name -p '{"uri":"redis://redis-host:6379"}' -t "redis"
For Redis with AUTH configured
kf cups service-instance-name -p '{"uri":"redis://:password@redis-host:6379"}' -t "redis"
Bind your App
Now that the user-provided service has been created, you can bind your App to the instance name:
kf bind-service application-name service-instance-name
Restart your App to for the changes to take effect:
kf restart application-name
You can confirm the new environment variables being provided to your App:
kf vcap-services application-name
Update the user-provided instance
If there are changes to the environment (for example password or host update in the URI, or the addition of new key-value pairs) that need to be passed on to any App bound to it, you can update the user-provided instance.
kf uups service-instance-name -p '{"uri":"new-uri", "some-new-key": "some-new-value"}'
kf unbind-service application-name service-instance-name
kf bind-service application-name service-instance-name