Skip to content

Commit ca79788

Browse files
committed
feat: make it possible to change the httpclient implementation (#1793)
Also document how to use a different implementation instead of the okhttp one which is the default one and currently, the one we recommend to use. Vert.X implementation is also coming along nicely. JDK implementation should work if you're using Java 17 and up, and will work with 11 when some bug fixes land in 11.
1 parent 824cb59 commit ca79788

File tree

6 files changed

+69
-9
lines changed

6 files changed

+69
-9
lines changed

caffeine-bounded-cache-support/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
<type>test-jar</type>
5555
<scope>test</scope>
5656
</dependency>
57+
<dependency>
58+
<groupId>io.fabric8</groupId>
59+
<artifactId>kubernetes-httpclient-okhttp</artifactId>
60+
<scope>test</scope>
61+
</dependency>
5762
</dependencies>
5863

5964
<build>

docs/documentation/v4-3-migration.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ permalink: /docs/v4-3-migration
99

1010
## Condition API Change
1111

12-
In Workflows the target of the condition was the managed resource itself, not the target dependent resource.
12+
In Workflows the target of the condition was the managed resource itself, not the target dependent resource.
1313
This changed, now the API contains the dependent resource.
1414

1515
New API:
1616

1717
```java
1818
public interface Condition<R, P extends HasMetadata> {
19-
20-
boolean isMet(DependentResource<R, P> dependentResource, P primary, Context<P> context);
21-
19+
20+
boolean isMet(DependentResource<R, P> dependentResource, P primary, Context<P> context);
21+
2222
}
2323
```
2424

@@ -27,10 +27,24 @@ Former API:
2727
```java
2828
public interface Condition<R, P extends HasMetadata> {
2929

30-
boolean isMet(P primary, R secondary, Context<P> context);
31-
30+
boolean isMet(P primary, R secondary, Context<P> context);
31+
3232
}
3333
```
3434

35-
Migration is trivial. Since the secondary resource can be accessed from the dependent resource. So to access the secondary
35+
Migration is trivial. Since the secondary resource can be accessed from the dependent resource. So to access the
36+
secondary
3637
resource just use `dependentResource.getSecondaryResource(primary,context)`.
38+
39+
## HTTP client choice
40+
41+
It is now possible to change the HTTP client used by the Fabric8 client to communicate with the Kubernetes API server.
42+
By default, the SDK uses the historical default HTTP client which relies on Okhttp and there shouldn't be anything
43+
needed to keep using this implementation. The `tomcat-operator` sample has been migrated to use the Vert.X based
44+
implementation. You can see how to change the client by looking at
45+
that [sample POM file](https://github.com/java-operator-sdk/java-operator-sdk/blob/d259fcd084f7e22032dfd0df3c7e64fe68850c1b/sample-operators/tomcat-operator/pom.xml#L37-L50):
46+
47+
- You need to exclude the default implementation (in this case okhttp) from the `operator-framework` dependency
48+
- You need to add the appropriate implementation dependency, `kubernetes-httpclient-vertx` in this case, HTTP client
49+
implementations provided as part of the Fabric8 client all following the `kubernetes-httpclient-<implementation name>`
50+
pattern for their artifact identifier.

operator-framework-core/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@
6868
<dependency>
6969
<groupId>io.fabric8</groupId>
7070
<artifactId>kubernetes-client</artifactId>
71+
<exclusions>
72+
<exclusion>
73+
<groupId>io.fabric8</groupId>
74+
<artifactId>kubernetes-httpclient-okhttp</artifactId>
75+
</exclusion>
76+
</exclusions>
7177
</dependency>
7278
<dependency>
7379
<groupId>org.slf4j</groupId>

operator-framework/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
<groupId>io.javaoperatorsdk</groupId>
1818
<artifactId>operator-framework-core</artifactId>
1919
</dependency>
20-
20+
<dependency>
21+
<groupId>io.fabric8</groupId>
22+
<artifactId>kubernetes-httpclient-okhttp</artifactId>
23+
</dependency>
2124
<dependency>
2225
<groupId>org.apache.commons</groupId>
2326
<artifactId>commons-lang3</artifactId>

pom.xml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
</dependency>
111111
<dependency>
112112
<groupId>io.fabric8</groupId>
113-
<artifactId>kubernetes-client</artifactId>
113+
<artifactId>kubernetes-client-api</artifactId>
114114
<version>${fabric8-client.version}</version>
115115
</dependency>
116116
<dependency>
@@ -200,6 +200,28 @@
200200
<artifactId>caffeine</artifactId>
201201
<version>${caffeine.version}</version>
202202
</dependency>
203+
<!-- Kubernetes client HTTP client implementations -->
204+
<dependency>
205+
<groupId>io.fabric8</groupId>
206+
<artifactId>kubernetes-httpclient-okhttp</artifactId>
207+
<version>${fabric8-client.version}</version>
208+
</dependency>
209+
<dependency>
210+
<groupId>io.fabric8</groupId>
211+
<artifactId>kubernetes-httpclient-vertx</artifactId>
212+
<version>${fabric8-client.version}</version>
213+
</dependency>
214+
<!-- We currently only recommend using the legacy okhttp client and the vert.x-based implementation -->
215+
<!-- <dependency>-->
216+
<!-- <groupId>io.fabric8</groupId>-->
217+
<!-- <artifactId>kubernetes-httpclient-jdk</artifactId>-->
218+
<!-- <version>${fabric8-client.version}</version>-->
219+
<!-- </dependency>-->
220+
<!-- <dependency>-->
221+
<!-- <groupId>io.fabric8</groupId>-->
222+
<!-- <artifactId>kubernetes-httpclient-jetty</artifactId>-->
223+
<!-- <version>${fabric8-client.version}</version>-->
224+
<!-- </dependency>-->
203225
</dependencies>
204226
</dependencyManagement>
205227

sample-operators/tomcat-operator/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@
3737
<dependency>
3838
<groupId>io.javaoperatorsdk</groupId>
3939
<artifactId>operator-framework</artifactId>
40+
<exclusions>
41+
<exclusion>
42+
<groupId>io.fabric8</groupId>
43+
<artifactId>kubernetes-httpclient-okhttp</artifactId>
44+
</exclusion>
45+
</exclusions>
46+
</dependency>
47+
<dependency>
48+
<groupId>io.fabric8</groupId>
49+
<artifactId>kubernetes-httpclient-vertx</artifactId>
4050
</dependency>
4151
<dependency>
4252
<groupId>io.fabric8</groupId>

0 commit comments

Comments
 (0)