SureInk Cloud Service Manager (sureink-cloud-service-manager)
Overview
The sureink-cloud-service-manager is a Spring Boot microservice responsible for managing and interacting with various cloud services, particularly those on the Google Cloud Platform (GCP), within the SureInk ecosystem. It provides internal APIs to facilitate operations related to cloud resources and exposes metrics for monitoring.
Technology Stack
- Core Framework: Java, Spring Boot
- Spring Web (for REST APIs)
- Spring Data JPA (for database interaction)
- Spring Security
- Spring Cloud:
- Spring Cloud Netflix Eureka Client (for service discovery)
- Spring Cloud Feign (for declarative REST client communication)
- Database:
- PostgreSQL
- Liquibase (for database schema migrations)
- Security:
- Keycloak (integrated via
keycloak-spring-boot-starter)
- Keycloak (integrated via
- Google Cloud Platform SDKs:
- Google Cloud Source Repositories API
- Google Cloud Artifact Registry API
- Google Sheets API
- Google HTTP Client, OAuth Client, Auth Libraries
- Monitoring & Metrics:
- Spring Boot Actuator
- JavaMelody
- Prometheus (custom integration for metrics exposure)
- Utilities:
- Project Lombok
- Jackson (for JSON processing)
- Gson
- Internal Libraries:
sureink-commonsureink-common-modelsureink-platform-utils
Key Functionalities
- Google Cloud Platform Integration:
- Artifact Registry Management: Interacts with Google Cloud Artifact Registry (e.g., browsing artifacts via
GoogleArtifactBrowser.java). - Source Repository Interaction (Potential): Dependencies suggest capabilities to interact with Google Cloud Source Repositories.
- Google Sheets Interaction (Potential): Dependencies suggest capabilities to read from or write to Google Sheets, possibly for configuration, reporting, or data exchange.
- Handles authentication with GCP services.
- Artifact Registry Management: Interacts with Google Cloud Artifact Registry (e.g., browsing artifacts via
- API Endpoints: Exposes RESTful APIs through
CloudServicesControllerService.javato manage or query cloud service-related operations. - Service Discovery: Registers with Eureka for discovery by other services in the SureInk platform.
- Security: Secured using Keycloak, ensuring that only authenticated and authorized clients can access its APIs.
- Database Operations: Utilizes a PostgreSQL database for persisting its own operational data if needed.
- Monitoring & Metrics:
- Provides application health and metrics via Spring Boot Actuator.
- Integrates with JavaMelody for detailed monitoring.
- Exposes custom metrics to Prometheus for broader operational visibility.
Project Structure
The service is organized into several key packages under com.sureink.cloud.service:
controller/: Contains Spring MVC controllers (CloudServicesControllerService.java) that define the REST API endpoints.google/: Houses the logic for interacting with Google Cloud Platform services.auth/: Manages authentication with GCP.repo/: Contains specific implementations for GCP services (e.g.,GoogleArtifactBrowser.java).utils/: Provides utility classes for GCP interactions.
prometheus/: Includes DTOs and services related to collecting and exposing metrics to Prometheus.- Configuration Classes:
CloudServiceManagerApplication.java: The main Spring Boot application class.KeycloakSecurityConfig.java: Configures Keycloak integration.PersistenceConfiguration.java: Configures JPA and database settings.
API Endpoints
The primary API endpoints are defined in CloudServicesControllerService.java. These endpoints likely cover operations such as:
- Listing or browsing artifacts in Google Artifact Registry.
- Other operations related to managed Google Cloud services.
(For specific endpoint details, refer to the CloudServicesControllerService.java source code or API documentation if available.)
Configuration
The service is configured through standard Spring Boot mechanisms, primarily application.properties or application.yml. Key configuration areas include:
- Database Connection: PostgreSQL connection details (host, port, username, password).
- Eureka Client: Eureka server address for service registration.
- Keycloak: Keycloak server URL, realm, client ID, and credentials.
- Google Cloud Platform: Credentials and project details for accessing GCP APIs (typically via service account keys or environment variables).
- Prometheus: Configuration for metrics exposure if needed.
Prerequisites
- JDK 11 or later (as per parent POM, verify specific version if needed)
- Apache Maven
- Access to a running PostgreSQL instance
- Access to a running Keycloak instance
- Access to a running Eureka server
- Configured Google Cloud Platform project with necessary APIs enabled (Artifact Registry, Source Repositories, Sheets) and appropriate credentials.
Build Instructions
- Navigate to the module directory:
cd path/to/sureink-cloud-service-manager - Build the project using Maven:
This will compile the code, run tests, and package the application (typically as a JAR file).
mvn clean install
Running the Application
- Ensure all prerequisites are met and external services (PostgreSQL, Keycloak, Eureka, GCP) are configured and accessible.
- Run the application:
(Adjust the JAR file name if necessary based on the build output.) The application will start and register with Eureka. API endpoints will become available on the configured port.
java -jar target/sureink-cloud-service-manager-1.0-SNAPSHOT.jar
Monitoring
- Actuator Endpoints: Access health, metrics, and other info via
/actuator/*. - JavaMelody: Access the JavaMelody monitoring dashboard at
/monitoring(default path). - Prometheus: Metrics will be available at the configured Prometheus scrape endpoint (e.g.,
/actuator/prometheus).