References:
- CPS-1005Getting issue details... STATUS
Overview:
This POC is for finding ways to create a resource (NCMP for this instance).
Few possibilities were discussed during the Grooming session which are listed as below.
- init-container
- k8s hooks
- Events in Spring.
- ....(explore others if any)
Issues and decisions
# | Questions/Open Issues | Notes | Decision/Answer |
---|---|---|---|
Analysis
- init-container
- k8s hooks
Events in Spring
We can use the ApplicationReadyEvent which is published when the application is ready to service requests.
We can listen to this event , which is thrown by the SpringApplication itself and then execute some code (which is creating a dataspace in our scenario)
ExampleApplicationReadyEvent@EventListener(ApplicationReadyEvent.class) public void initializeNcmp() { log.info("Initializing NCMP when the ApplicationReadyEvent is received"); try { cpsAdminService.createDataspace("NCMP-CmHandle-Operational-Data"); } catch (final AlreadyDefinedException ex) { log.info("Already defined : {} ", ex.getMessage()); } catch (final Exception ex) { log.warn("Failed to create dataspace, cause : {}", ex.getMessage()); } }
References