https://github.com/dropwizard/dropwizard-kubernetes
A convenience library for the integration of the Fabric8 Kubernetes client in a Dropwizard service.
https://github.com/dropwizard/dropwizard-kubernetes
dropwizard-kubernetes k8s kubernetes kubernetes-client
Last synced: about 1 year ago
JSON representation
A convenience library for the integration of the Fabric8 Kubernetes client in a Dropwizard service.
- Host: GitHub
- URL: https://github.com/dropwizard/dropwizard-kubernetes
- Owner: dropwizard
- License: apache-2.0
- Created: 2019-07-23T19:56:13.000Z (almost 7 years ago)
- Default Branch: release/4.0.x
- Last Pushed: 2025-02-17T11:03:18.000Z (about 1 year ago)
- Last Synced: 2025-03-20T15:12:24.414Z (about 1 year ago)
- Topics: dropwizard-kubernetes, k8s, kubernetes, kubernetes-client
- Language: Java
- Homepage:
- Size: 439 KB
- Stars: 7
- Watchers: 6
- Forks: 2
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dropwizard-kubernetes
[](https://travis-ci.org/dropwizard/dropwizard-kubernetes)
[](https://coveralls.io/r/dropwizard/dropwizard-kubernetes)
[](http://mvnrepository.com/artifact/io.dropwizard.modules/dropwizard-kubernetes)
Provides easy integration for Dropwizard applications with [the Fabric8 Kubernetes API client](https://github.com/fabric8io/kubernetes-client).
This bundle comes with out-of-the-box support for:
* Configuration (providing YAML as an option [on top of the existing ways to configure the fabric8 client](https://github.com/fabric8io/kubernetes-client#configuring-the-client))
* Kubernetes client connection lifecycle management
* Kubernetes API health checks
* Metrics instrumentation for the OKHttpClient underpinning the kubernetes-client.
* Distributed tracing integration using [Brave](https://github.com/openzipkin/brave)
For more information on the Kubernetes API, take a look at the official documentation here: https://kubernetes.io/docs/reference/#api-reference
## Dropwizard Version Support Matrix
| dropwizard-kubernetes | Dropwizard v1.3.x | Dropwizard v2.0.x | Dropwizard v2.1.x | Dropwizard v3.0.x | Dropwizard v4.0.x |
|-----------------------|--------------------|--------------------|--------------------|--------------------|--------------------|
| v1.3.x | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: |
| v1.4.x | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: |
| v1.5.x | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: |
| v3.0.x | :x: | :x: | :x: | :white_check_mark: | :x: |
| v4.0.x | :x: | :x: | :x: | :x: | :white_check_mark: |
## Usage
Add dependency on library.
Maven:
```xml
io.dropwizard.modules
dropwizard-kubernetes
${dropwizard-kubernetes.version}
```
Gradle:
```groovy
compile "io.dropwizard.modules:dropwizard-kubernetes:$dropwizardKubernetesVersion"
```
## Usage
In your application's `Configuration` class, add a `KubernetesClientFactory` object:
```java
public class ExampleConfiguration extends Configuration {
...
@Valid
@NotNull
@JsonProperty("kubernetes-client")
private KubernetesClientFactory kubernetesClientFactory;
public KubernetesClientFactory getKubernetesClientFactory() {
return kubernetesClientFactory;
}
public void setKubernetesClientFactory(final KubernetesClientFactory kubernetesClientFactory) {
this.kubernetesClientFactory = kubernetesClientFactory;
}
}
```
Add a `KubernetesClientBundle` to the `Boostrap` object in your `initialize` method:
```java
private final KubernetesClientBundle kubernetesClient = new KubernetesClientBundle() {
@Override
public KubernetesClientFactory getKubernetesClientFactory(ExampleConfiguration configuration) {
return configuration.getKubernetesClientFactory();
}
};
@Override
public void initialize(Bootstrap bootstrap) {
bootstrap.addBundle(kubernetesClient);
}
@Override
public void run(ExampleConfiguration config, Environment environment) {
final KubernetesAPIThing kubernetesAPIThing = new KubernetesAPIThing(kubernetesClient.getKubernetesClient());
environment.jersey().register(new KubernetesAPIThingResource(kubernetesAPIThing));
}
```
Configure your factory in your `config.yml` file:
```yaml
kubernetes-client:
name: my-k8s-usecase
config:
masterUrl: https://localhost:443
apiVersion: v1
namespace: default
currentContext: my-context
userAgent: generic-crud-app
requestConfig:
watchReconnectInterval: 3s
watchReconnectLimit: 25
connectionTimeout: 10s
requestTimeout: 4s
rollingTimeout: 5s
scaleTimeout: 6s
webSocketTimeout: 3s
webSocketPingInterval: 10s
loggingInterval: 20s
httpClient:
followRedirects: false
followSslRedirects: false
proxy:
url: "https://127.0.0.1:6379"
username: admin
password: hunter2
security:
trustCerts: true
caCert:
type: string
caCert: abc123def456
trustStore: src/test/resources/truststore.p12
trustStorePassword: changeit
interceptors:
- type: backwards-compatibility
- type: oauth
oAuthToken:
type: string
token: 123abc456def
```
## Support
Please file bug reports and feature requests in [GitHub issues](https://github.com/dropwizard/dropwizard-kubernetes/issues).