Accessing a Service Instance
This page describes how to access an a9s Service Instance.
Make a Service Instance Locally Available
It is possible to access any of the a9s Data Services locally. This means that a local client can connect to the Service Instance for any purpose such as debugging.
Cloud Foundry provides a smart way to create SSH forward tunnels via a pushed application. For more information about this feature, see the Accessing Apps with SSH section of the Cloud Foundry documentation.
First of all an application must be bound to the Service Instance. For more information, see Bind an application to a Service Instance.
cf ssh
support must be enabled in the platform. Ask the Platform Operator for further details.
Get The Service URL and Credentials
Following the instructions in Obtain Credentials for Accessing a Service Instance will provide the hostname of the Service Instance and the user credentials.
cf env a9s-dataservice-app
Output
Getting env variables for app a9s-dataservice-app in org test / space test as admin...
OK
System-Provided:
{
"VCAP_SERVICES": {
"a9s-mariadb106": [
{
"binding_name": null,
"credentials": {
"host": "d15575b.service.dc1.consul",
"name": "d15575b",
"password": "a9s-password",
"port": 3306,
"uri": "mysql://a9s-brk-usr:a9s-password@d15575b.service.dc1.a9s-dataservice-consul:3306/d15575b",
"username": "a9s-brk-usr"
},
"label": "a9s-mariadb106",
"plan": "dataservice-cluster-small",
"tags": [
"sql",
"database",
"object-relational",
"consistent"
],
"volume_mounts": []
}
]
}
}
...
Notice the host d67901c.service.dc1.a9svs
, the username a9s-brk-usr
and the password a9s-password
. They will be
needed in the next step.
Create a Tunnel to The Service
With the cf ssh
, as mentioned before, a ssh forward tunnel to the management dashboard can be created. Use port 27017
to connect to the a9s Data Service Instance.
cf ssh a9s-dataservice-app -L 27017:d67901c.service.dc1.a9svs:27017
vcap@956aaf4e-6da9-4f69-4b1d-8e631a403312:~
When the ssh tunnel is open the instance can be accessed over the address localhost:27017
.
Don't forget to close the session with exit
.
Service Keys
To gain access to the Service Instance manually, rather than binding apps to it, service keys can be used.
Creating a Service Key
To create a key to the Service Instance my-dataservice-service-instance
call mykey
run:
cf create-service-key my-dataservice-service-instance mykey
Listing Service Keys
To list all the keys for the my-dataservice-service-instance
Service Instance run this:
cf service-keys my-dataservice-service-instance
Accessing Service Keys
To obtain the key mykey
from the my-dataservice-service-instance
Service Instance run:
cf service-key my-dataservice-service-instance mykey
Deleting Service Keys
To delete a service key mykey
from the Service Instance my-dataservice-service-instance
run:
cf delete-service-key my-dataservice-service-instance mykey