Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
httpclient-tests:
strategy:
matrix:
httpclient: [ 'vertx', 'jdk', 'jetty' ]
httpclient: [ 'vertx-5', 'jdk', 'jetty' ]
uses: ./.github/workflows/integration-tests.yml
with:
java-version: 25
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
http-client:
type: string
required: false
default: 'vertx'
default: 'vertx-5'
experimental:
type: boolean
required: false
Expand Down
2 changes: 1 addition & 1 deletion bootstrapper-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>java-operator-sdk</artifactId>
<version>5.6.4-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
</parent>

<artifactId>bootstrapper</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion caffeine-bounded-cache-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>java-operator-sdk</artifactId>
<version>5.6.4-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
</parent>

<artifactId>caffeine-bounded-cache-support</artifactId>
Expand Down
32 changes: 23 additions & 9 deletions docs/content/en/docs/documentation/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,35 @@ public class DeploymentReconciler

**Note:** This feature is provided by the [Fabric8 Kubernetes Client](https://github.com/fabric8io/kubernetes-client), not JOSDK itself.

To automatically generate CRD manifests from your annotated Custom Resource classes, add this dependency to your project:
To automatically generate CRD manifests from your annotated Custom Resource classes, configure the
Fabric8 CRD generator Maven plugin. Use the same Fabric8 version as the SDK:

```xml

<dependency>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>crd-generator-apt</artifactId>
<scope>provided</scope>
</dependency>
<artifactId>crd-generator-maven-plugin</artifactId>
<version>${fabric8-client.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
```

The CRD will be generated in `target/classes/META-INF/fabric8` (or `target/test-classes/META-INF/fabric8` for test scope) with the CRD name suffixed by the generated spec version.
Add the plugin under `build/plugins` and set `fabric8-client.version` to `8.0.0`.
The old `crd-generator-apt` annotation processor was removed in Fabric8 8.

The CRD will be generated in `target/classes/META-INF/fabric8` with the filename suffixed by the
generated spec version. For test resources, configure `classesToScan` to
`${project.build.testOutputDirectory}` and `classpath` to `WITH_ALL_DEPENDENCIES_AND_TESTS`, and
bind the plugin execution to `process-test-classes`.

For example, a CR using the `java-operator-sdk.io` group with a `mycrs` plural form will result in these files:
For example, a CR using the `java-operator-sdk.io` group with a `mycrs` plural form will result in:
- `mycrs.java-operator-sdk.io-v1.yml`
- `mycrs.java-operator-sdk.io-v1beta1.yml`

Only `apiextensions.k8s.io/v1` CRDs are generated.

**Note for Quarkus users:** If you're using the `quarkus-operator-sdk` extension, you don't need to add any extra dependency for CRD generation - the extension handles this automatically.
82 changes: 82 additions & 0 deletions docs/content/en/docs/migration/fabric8-8-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
title: Migrating from SDK 5 to SDK 6
description: Updating operators for SDK 6, Fabric8 Kubernetes Client 8, and Jackson 3
---

## Breaking changes in SDK 6

Java Operator SDK 6 introduces source and binary incompatibilities through its upgrade to
Fabric8 8 and Jackson 3. Upgrade the SDK dependencies and `operator-framework-bom` together,
migrate custom Jackson integrations, and recompile your operator. This is not a drop-in
replacement for SDK 5.

## Fabric8 Kubernetes Client 8

The SDK now uses Fabric8 Kubernetes Client `8.0.0`, which requires Java 17 or newer, matching the
SDK's existing Java baseline. Align any explicit Fabric8 dependencies and the
`crd-generator-maven-plugin` with this version.

See the [Fabric8 8 migration guide](https://github.com/fabric8io/kubernetes-client/blob/v8.0.0/doc/MIGRATION-v8.md)
for the complete list of client and CRD generator changes.

## Jackson 3

The Kubernetes client, resource matchers, and YAML configuration provider now use Jackson 3.
Code that uses the client's Jackson types must migrate from `com.fasterxml.jackson.core`,
`com.fasterxml.jackson.databind`, and `com.fasterxml.jackson.dataformat` to the corresponding
`tools.jackson` packages. Maven dependencies use `tools.jackson.core:jackson-core`,
`tools.jackson.core:jackson-databind`, and `tools.jackson.dataformat:jackson-dataformat-yaml`.
Jackson annotations such as `@JsonProperty` remain in `com.fasterxml.jackson.annotation`,
provided by `com.fasterxml.jackson.core:jackson-annotations`.

Custom serializers, deserializers, and databind annotations must use Jackson 3 types:
`ValueSerializer`, `ValueDeserializer`, and `tools.jackson.databind.annotation`. Jackson 2
databind annotations are not used by the client, even when Jackson 2 is also on the classpath.
Java time support is built in, so remove `JavaTimeModule` registrations.

Jackson 3 mappers are immutable. Use builders instead of `registerModule` or `configure`.
When supplying a custom mapper to the Kubernetes client, preserve the Fabric8 compatibility
defaults:

```java
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.utils.KubernetesSerialization;
import io.fabric8.kubernetes.model.jackson.Jackson2JdkTypesModule;
import tools.jackson.databind.json.JsonMapper;

var mapper = JsonMapper.builderWithJackson2Defaults()
.addModule(new Jackson2JdkTypesModule())
.build();
var client = new KubernetesClientBuilder()
.withKubernetesSerialization(new KubernetesSerialization(mapper, true))
.build();
```

The default client already applies these compatibility settings. Supplying a mapper configures
a copy; the original mapper is not modified. See the Fabric8 migration guide for wire-format
differences that cannot be restored, and review regenerated CRDs before applying them.

## HTTP client selection

The `operator-framework` module continues to use the JDK HTTP client by default. Fabric8's
default HTTP client is now `kubernetes-httpclient-vertx-5`, which the core module excludes so
that it does not bring a second HTTP implementation into operators.

If you select Vert.x through `fabric8-httpclient-impl.name`, use `vertx-5` instead of `vertx`.
Explicit Vert.x dependencies should use `io.fabric8:kubernetes-httpclient-vertx-5` and compatible
Vert.x 5 dependencies. Applications depending only on `operator-framework-core` must provide
their chosen Fabric8 HTTP client implementation.

Vert.x 5 requires Netty 4.2. Check application and platform BOMs for dependencies pinned to
Vert.x 4 or Netty 4.1 before selecting this client; incompatible versions can prevent client
startup. See the Fabric8 migration guide if you need to remain on Vert.x 4.

The Jetty HTTP client now uses Jetty 12.1 and cannot share a classpath with Jetty 9, 10, or 11.
Upgrade any application dependencies using older Jetty versions or choose a different
Fabric8 HTTP client implementation.

## CRD generation

Fabric8 removed the `crd-generator-apt` annotation processor. Use the
[`crd-generator-maven-plugin`](../../documentation/features/#automatic-crd-generation) instead.
Only `apiextensions.k8s.io/v1` CRDs are generated.
4 changes: 2 additions & 2 deletions micrometer-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>java-operator-sdk</artifactId>
<version>5.6.4-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
</parent>

<artifactId>micrometer-support</artifactId>
Expand Down Expand Up @@ -64,7 +64,7 @@
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-vertx</artifactId>
<artifactId>kubernetes-httpclient-vertx-5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion migration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>java-operator-sdk</artifactId>
<version>5.6.4-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
</parent>

<artifactId>migration</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion operator-framework-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-bom</artifactId>
<version>5.6.4-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Operator SDK - Bill of Materials</name>
<description>Java SDK for implementing Kubernetes operators</description>
Expand Down
9 changes: 7 additions & 2 deletions operator-framework-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>java-operator-sdk</artifactId>
<version>5.6.4-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -46,10 +46,15 @@
<exclusions>
<exclusion>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-okhttp</artifactId>
<artifactId>kubernetes-httpclient-vertx-5</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-${fabric8-httpclient-impl.name}</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import io.javaoperatorsdk.operator.processing.event.source.informer.pool.DefaultInformerPool;
import io.javaoperatorsdk.operator.processing.event.source.informer.pool.InformerPool;

import tools.jackson.databind.ObjectMapper;

/** An interface from which to retrieve configuration information. */
public interface ConfigurationService {

Expand Down Expand Up @@ -145,11 +147,11 @@ public <R extends HasMetadata> R clone(R object) {
* you do not need to worry about setting the namespace information in most cases).
*
* <p>Previous versions of this class provided direct access to the serialization mechanism (via
* {@link com.fasterxml.jackson.databind.ObjectMapper}) or the client's configuration. This was
* somewhat confusing, in particular with respect to changes made in the Fabric8 client
* serialization architecture made in 6.7. The proper way to configure these aspects is now to
* configure the Kubernetes client accordingly and the SDK will extract the information it needs
* from this instance. The recommended way to do so is to create your operator with {@link
* {@link ObjectMapper}) or the client's configuration. This was somewhat confusing, in particular
* with respect to changes made in the Fabric8 client serialization architecture made in 6.7. The
* proper way to configure these aspects is now to configure the Kubernetes client accordingly and
* the SDK will extract the information it needs from this instance. The recommended way to do so
* is to create your operator with {@link
* io.javaoperatorsdk.operator.Operator#Operator(Consumer)}, passing your custom instance with
* {@link ConfigurationServiceOverrider#withKubernetesClient(KubernetesClient)}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io.javaoperatorsdk.operator.api.reconciler.Context;
import io.javaoperatorsdk.operator.processing.dependent.Matcher;

import com.fasterxml.jackson.databind.JsonNode;
import tools.jackson.databind.JsonNode;

public class GenericKubernetesResourceMatcher<R extends HasMetadata, P extends HasMetadata> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import io.javaoperatorsdk.operator.api.reconciler.Context;
import io.javaoperatorsdk.operator.api.reconciler.matcher.Matcher;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.node.JsonNodeFactory;
import tools.jackson.databind.node.NullNode;
import tools.jackson.databind.node.ObjectNode;

/** Shared helpers for the client-side patch based {@link Matcher} implementations. */
final class MatcherUtils {
Expand Down Expand Up @@ -66,9 +66,7 @@ private static JsonNode applyMergePatch(JsonNode target, JsonNode patch) {
}
var targetObject =
target.isObject() ? (ObjectNode) target : JsonNodeFactory.instance.objectNode();
var fields = patch.fields();
while (fields.hasNext()) {
var entry = fields.next();
for (var entry : patch.properties()) {
if (entry.getValue().isNull()) {
targetObject.remove(entry.getKey());
} else {
Expand Down
Loading