Cloud Foundry (4) -- service

Source: Internet
Author: User

Services: The cloud foundry service module is an independent plug-in module from the perspective of source code control, so that third parties can integrate their services into the cloudfoundry ecosystem. On GitHub, we can see that the service is a repository independent from the cloudfoundry core project vcap, Which is vcap-service. In the service module, the design principle is to facilitate third-party service providers to provide services. Cloudfoundry has been very successful in this regard. from GitHub, the following services are available: a) MongoDB; B) MySQL; c) neo4j; d) PostgreSQL; e) rabbitmq; f) redis; g) vblob. Base classes are all placed in the base folder.

If a third party needs to develop its own cloudfoundry service, it must inherit and rewrite the two basic classes in it: node and gateway. Some operations, such as provision, can be performed in the base's provisioner. add your own logic based on RB, including service_error and service_message. As for how to write your own service, the ELC blog will publish relevant articles in detail, not in the scope of this article. From the perspective of architecture, as long as you know the relationship between services, we know that a service and a base can be expanded horizontally through the inheritance relationship, and cloudfoundry and apps can call the service through the base to complete this simple architecture method.

The services provided by CF can be divided into service gateway and service node by module. The class hierarchy is divided into two layers: vcap-service-Base provides the base getway (vcap-service-base \ Lib \ gateway. RB starts the gateway and a thin server, vcap-services-base \ Lib \ base \ asynchronous_service_gateway.rb, which provides service processing methods) and node, for specific services, You need to reload or implement some methods of gateway and node.

Service Gateway

The Service Gateway provides the rest interface. Requests from the cloud controller are first processed by the Service Gateway, then the corresponding service node is searched, and the request is sent to the node of the specific service by sending a message.

Service Node

The service node is responsible for processing gateway messages, and managing services such as provision deletion (BIND) unbind and restore, and send the specific request to the service instance.

Important Concepts: service instance

Service instance, such as mysqld. It runs in service node and is managed by service node to provide services for apps in DEA.

Credentials creden,, service configuration and authentication information. When creating a service, the service node creates credentials. When binding an app, it is added to the app's environment variable. When the app obtains the modified information, it can access the specific service. Key workflow provision service creates a service instance and generates credentials. The Service creation solution varies with service types. For example, MySQL creates a database and a user without starting a new service instance. For redis, a new service instance is started. The process for creating MySQL is as follows:

Note that the communication between VMC and STS to Cloud Controller and Gateway is an HTTP rest request, and the gateway and node are Nat messages. Note: the services provided by CF are deployed (or may not be started), and the service nodes are ready when CF is initialized. No software package is downloaded, installed, and deployed. Bind Service

Bind a service to an application: Find the service instance, find the credentials, and return it to the Cloud Controller. The created service is unknown to the application. You must bind the credentials information of the Service to the environment variable of the application to access the application.

The process for binding a MySQL service is as follows:


Core code: Cloud Controller

1. cloud_controller-master \ cloud_controller \ config \ routes. RB: Cloud Controller URL to method ing

2. cloud_controller-master \ cloud_controller \ app \ controllers \ services_controller.rb: controller for service

Gateway

1. vcap-services-base-master \ Lib \ base \ asynchronous_service_gateway.rb: exposed interface Gateway

2. vcap-services-base-master \ Lib \ base \ provisioner. RB: Gateway Service Method

Service Node

1. vcap-services-base-master \ Lib \ base \ node. RB: node base class

2. CF-services-release-master \ SRC \ mysql_service \ Lib \ mysql_service \ node. RB: MySQL Node

Cloud Foundry (4) -- service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.