os-partition-gcp is a [Spring Boot](https://spring.io/projects/spring-boot) service that is responsible for creating and retrieving partition specific properties on behalf of other services whether they are secret values or not.
## Features of implementation
This is a universal solution created using EPAM OSM mapper technology. It allows you to work with various
implementations of KV stores.
## Limitations of the current version
In the current version, the mappers have been equipped with several drivers to the stores:
OSM (mapper for KV-data): Google Datastore; Postgres
## Extensibility
To use any other store or message broker, implement a driver for it. With an extensible set of drivers, the solution is
unrestrictedly universal and portable without modification to the main code.
Mappers support "multitenancy" with flexibility in how it is implemented. They switch between datasources of different
tenants due to the work of a bunch of classes that implement the following interfaces:
* Destination - takes a description of the current context, e.g., "data-partition-id = opendes";
* DestinationResolver – accepts Destination, finds the resource, connects, and returns Resolution;
* DestinationResolution – contains a ready-made connection, the mapper uses it to get the data.
## Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
...
...
@@ -12,6 +33,34 @@ Pre-requisites
* Lombok 1.16 or later
* Maven
## Mapper tuning mechanisms
This service uses specific implementations of DestinationResolvers. A total of 2 resolvers have been implemented, which are divided into two groups:
### for universal technologies:
- for Postgres: osm/config/resolver/OsmPostgresDestinationResolver.java
#### Their algorithms are as follows:
- incoming Destination carries data-partition-id
- resolver accesses the Partition service and gets PartitionInfo
- from PartitionInfo resolver retrieves properties for the connection: URL, username, password etc.
- resolver creates a data source, connects to the resource, remembers the datasource
- resolver gives the datasource to the mapper in the Resolution object
### for native Google Cloud technologies:
- for Datastore: osm/config/resolver/OsmDatastoreDestinationResolver.java
#### Their algorithms are similar,
Except that they do not receive special properties from the Partition service for connection, because the location of
the resources is unambiguously known - they are in the GCP project. And credentials are also not needed - access to data
is made on behalf of the Google Identity SA under which the service itself is launched. Therefore, resolver takes only
the value of the **projectId** property from PartitionInfo and uses it to connect to a resource in the corresponding GCP
project.
### Installation
In order to run the service locally or remotely, you will need to have the following environment variables defined.
...
...
@@ -26,7 +75,61 @@ In order to run the service locally or remotely, you will need to have the follo
| `GOOGLE_APPLICATION_CREDENTIALS` | ex `/path/to/directory/service-key.json` | Service account credentials, you only need this if running locally | yes | https://console.cloud.google.com/iam-admin/serviceaccounts |
| `KEY_RING` | ex `csqp` | A key ring holds keys in a specific Google Cloud location and permit us to manage access control on groups of keys | yes | https://cloud.google.com/kms/docs/resource-hierarchy#key_rings |
| `KMS_KEY` | ex `partitionService` | A key exists on one key ring linked to a specific location. | yes | https://cloud.google.com/kms/docs/resource-hierarchy#key_rings |
| `PARTITION_PROPERTY_KIND` | ex `PartitionProperty` | Kind name to store the properties. | no | - |
| `PARTITION_NAMESPACE` | ex `partition` | Namespace for database. | no | - |
| `osmDriver` | ex `postgres` or `datastore` | Osm driver mode that defines which storage will be used | no | - |
| `osm.postgres.url` | ex `jdbc:postgresql://127.0.0.1:5432/postgres` | Postgres server URL | no | - |
| `osm.postgres.username` | ex `postgres` | Postgres admin username | no | - |