Using the a9s Elasticsearch for PCF

This topic describes how developers use a9s Elasticsearch for Pivotal Cloud Foundry (PCF) after it has been successfully installed. For information about installation, see Installing and Configuring Elasticsearch for PCF.

Use a9s Elasticsearch for PCF with an App

To use the a9s Elasticsearch for PCF with with an app, follow the procedures below to create a service instance and bind the service instance to your app. For more information about managing service instances, see Managing Service Instances with the CLI.

View the Service

After the tile is installed, a9s-elasticsearch and its service plans appear in your Marketplace.

  1. To check the availability of the service and its plans, enter the following command:

    $ cf marketplace
    

    For example,

    $ cf marketplace
    Getting services from marketplace in org test / space test as admin...
    OK
    service plans description a9s-elasticsearch elasticsearch-single-small, elasticsearch-cluster-small, elasticsearch-single-big, elasticsearch-cluster-big This is the anynines Elasticsearch 5 service.
  2. See Create a Service Instance to create Elasticsearch service instances based on the plans you listed in Step 1 above.

The plans that contain single in their names, provision single VM Elasticsearch servers. Plans with cluster, provision Elasticsearch clusters consisting of three VMs.

Create a Service Instance and Bind It to an App

You can provision a database with the cf create-service.

  1. To create a service instance, enter the following command:

    $ cf create-service a9a-elasticsearch PLAN-NAME SERVICE-INSTANCE-NAME
    

    For example, the following command creates an elasticsearch-single-small service that provisions a single VM Elasticsearch server:

    $ cf create-service a9s-elasticsearch elasticsearch-single-small my-elasticsearch-service
    

    Depending on your infrastructure and service broker usage, it may take several minutes to create the service instance.

  2. To check the creation status, do one of the following:

    • To list all the service instances, enter:

      $ cf services
      
    • To display the status of one service instance, enter:

      $ cf service SERVICE-INSTANCE-NAME
      
  3. After you create your database, bind the service instance to the app with the following command:

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

    For example, the following command binds the my-elasticsearch-service service instance to the a9s-elasticsearch-app app:

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

  4. Restage or restart the app so that it can access the service instance by doing one of the following:

    • To restage the app, enter:

      $ cf restage APP-NAME
      
    • To restart the app, enter:

      $ cf restart APP-NAME
      

Obtain Service Instance Access Credentials

After you bind the service instance to the app, you can find the credentials of your Elasticsearch database in the environment variables of the app. Because service instances are protected by HTTP Basic Auth, apps connected to it need to add authentication details to all requests.

You can use the host, username, and password values with a Elasticsearch client to connect to the database.

  1. To list the environment variables, including the credentials for the Elasticsearch database, enter the following command: $ cf env APP-NAME For example,

    $ cf env a9s-elasticsearch-app
    Getting env variables for app a9s-elasticsearch-app in org test / space test as admin...
    OK
    System-Provided: { "VCAP_SERVICES": { "a9s-elasticsearch": [ { "credentials": { "host": [ "EXAMPLE_HOST" ], "password": "EXAMPLE_USER", "username": "EXAMPLE_PASSWORD" }, "label": "a9s-elasticsearch", "name": "my-elasticsearch-service", "plan": "elasticsearch-cluster-small", "tags": [ "searchengine" ] } ] } } ...

  2. Record the credentials that are listed under the VCAP_SERVICES key.

Delete a a9s Elasticsearch for PCF Service Instance

Follow the instructions below to unbind your service instance from all apps and delete it.

  1. Back up the data stored in your database.

    Note: The delete operation cannot be undone and all data is lost when the service is deleted.

  2. List available services by entering the following command:

    $ cf services
    

    For example, the following shows that my-elasticsearch-service is bound to the a9s-elasticsearch-app app.

    $ cf services
    Getting services in org test / space test as admin... OK
    name service plan bound apps last operation my-elasticsearch-service a9s-elasticsearch elasticsearch-single-small a9s-elasticsearch-app create succeeded

Unbind a Service Instance

  • To unbind a service instance from your app, enter the following command:

    $ cf unbind-service APP-NAME SERVICE-INSTANCE-NAME
    

    For example,

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

Delete a Service Instance

Deleting a service deprovisions the corresponding infrastructure resources.

  1. To delete a service instance, enter the following command:

    $ cf delete-service SERVICE-INSTANCE-NAME
    
    $ cf delete-service my-elasticsearch-service
    

    It might take several minutes to delete the service.

  2. To check the deletion status, enter the following command:

    $ cf services
    
Create a pull request or raise an issue on the source for this page in GitHub