Volume services are available in the market place which can provide non-ephemeral storage as a service which apps can bind and store data into those external nfs mount.
How to do this:
Check your market place for Volume services.
user-service $cf marketplace
Getting services from marketplace in org pcfdev-org / space pcfdev-space as admin...
OK
service plans description
local-volume free-local-disk Local service docs: https://github.com/cloudfoundry-incubator/local-volume-release/
p-mysql 512mb, 1gb MySQL databases on demand
p-rabbitmq standard RabbitMQ is a robust and scalable high-performance multi-protocol messaging broker.
p-redis shared-vm Redis service to provide a key-value store
user-service $cf create-service local-volume free-local-disk usernfs -c '{"share": "10.10.10.10/export/myshare"}'
Creating service instance usernfs in org pcfdev-org / space pcfdev-space as admin...
OK
The share attribute forwards this information to the broker about the nfs server and share required for this service.
user-service $cf bind-service userservice usernfs -c '{"uid":"1000", "gid":"1000", "mount":"var/volume1"}'
Binding service usernfs to app userservice in org pcfdev-org / space pcfdev-space as admin...
OK
Mount - mount volume to a particular path than the default path.
Cf env will show you the following:
"VCAP_SERVICES": {
"local-volume": [
{
"credentials": {},
"label": "local-volume",
"name": "usernfs",
"plan": "free-local-disk",
"provider": null,
"syslog_drain_url": null,
"tags": [
"local"
],
"volume_mounts": [
{
"container_dir": "var/volume1",
"device_type": "shared",
"mode": "rw"
}
]
}
]
Mode is read or read and write.
Device type supported is shared only, which can be used by multiple instances.
You can ssh into the instance to check if the path has been mounted.
user-service $cf ssh userservice
vcap@860ceeb4-08be-4611-4f73-7dd8bb405901:~$ l
vcap@860ceeb4-08be-4611-4f73-7dd8bb405901:/$ cd /var/volume1
vcap@860ceeb4-08be-4611-4f73-7dd8bb405901:/var/volume1$
Now you can write content to this mount path in your application.
No comments:
Post a Comment