A Spring Cloud Connector for Kubernetes Service Catalog.
What it does behind the scenes is that it retrieves the service bindings of a managed instance and through that it obtains the connection information (which is stored as as a secret).
To use this connector just follow these steps:
-add the connector to classpath -create an instance of cloud -get the service info from the cloud.
For example using maven:
<dependency>
<groupId>me.snowdrop</groupId>
<artifactId>servicecatalog-connector</artifactId>
<version>0.0.1</version>
</dependency>
To create an instance of Cloud
and retrieve info about a service instance:
Cloud cloud = new CloudFactory().getCloud();
ServiceInfo info = cloud.getServiceInfo(serviceInstanceName);
Here's a full example of a program that prints service info in the console: service info printer.
Spring cloud already supports connectors and it makes it very easy to consume services supported by the connector.
The user just needs to use a ServiceConnectionfactory
and create the connections by referencing the service instance by name.
The easiest way to do so, is by extending AbstractCloudConfig
.
@Configuration
public class CloudConfig extends AbstractCloudConfig {
@Bean
public DataSource dataSource() {
return this.connectionFactory().service("dh-postgresql-apb", DataSource.class);
}
}
For a full example check: simple database.
At the moment the following services are supported:
All of the services above are mapped using the following property names: