|
| 1 | +--- |
| 2 | +title: Migrating to Fabric8 8 and Jackson 3 |
| 3 | +description: Updating operators for Fabric8 Kubernetes Client 8 and Jackson 3 |
| 4 | +--- |
| 5 | + |
| 6 | +## Fabric8 Kubernetes Client 8 |
| 7 | + |
| 8 | +The SDK now uses Fabric8 Kubernetes Client `8.0.0`, which requires Java 17 or newer, matching the |
| 9 | +SDK's existing Java baseline. Align any explicit Fabric8 dependencies and the |
| 10 | +`crd-generator-maven-plugin` with this version. |
| 11 | + |
| 12 | +See the [Fabric8 8 migration guide](https://github.com/fabric8io/kubernetes-client/blob/v8.0.0/doc/MIGRATION-v8.md) |
| 13 | +for the complete list of client and CRD generator changes. |
| 14 | + |
| 15 | +## Jackson 3 |
| 16 | + |
| 17 | +The Kubernetes client, resource matchers, and YAML configuration provider now use Jackson 3. |
| 18 | +Code that uses the client's Jackson types must migrate from `com.fasterxml.jackson.core`, |
| 19 | +`com.fasterxml.jackson.databind`, and `com.fasterxml.jackson.dataformat` to the corresponding |
| 20 | +`tools.jackson` packages. Maven dependencies use `tools.jackson.core:jackson-core`, |
| 21 | +`tools.jackson.core:jackson-databind`, and `tools.jackson.dataformat:jackson-dataformat-yaml`. |
| 22 | +Jackson annotations such as `@JsonProperty` remain in `com.fasterxml.jackson.annotation`, |
| 23 | +provided by `com.fasterxml.jackson.core:jackson-annotations`. |
| 24 | + |
| 25 | +Custom serializers, deserializers, and databind annotations must use Jackson 3 types: |
| 26 | +`ValueSerializer`, `ValueDeserializer`, and `tools.jackson.databind.annotation`. Jackson 2 |
| 27 | +databind annotations are not used by the client, even when Jackson 2 is also on the classpath. |
| 28 | +Java time support is built in, so remove `JavaTimeModule` registrations. |
| 29 | + |
| 30 | +Jackson 3 mappers are immutable. Use builders instead of `registerModule` or `configure`. |
| 31 | +When supplying a custom mapper to the Kubernetes client, preserve the Fabric8 compatibility |
| 32 | +defaults: |
| 33 | + |
| 34 | +```java |
| 35 | +import io.fabric8.kubernetes.client.KubernetesClientBuilder; |
| 36 | +import io.fabric8.kubernetes.client.utils.KubernetesSerialization; |
| 37 | +import io.fabric8.kubernetes.model.jackson.Jackson2JdkTypesModule; |
| 38 | +import tools.jackson.databind.json.JsonMapper; |
| 39 | + |
| 40 | +var mapper = JsonMapper.builderWithJackson2Defaults() |
| 41 | + .addModule(new Jackson2JdkTypesModule()) |
| 42 | + .build(); |
| 43 | +var client = new KubernetesClientBuilder() |
| 44 | + .withKubernetesSerialization(new KubernetesSerialization(mapper, true)) |
| 45 | + .build(); |
| 46 | +``` |
| 47 | + |
| 48 | +The default client already applies these compatibility settings. Supplying a mapper configures |
| 49 | +a copy; the original mapper is not modified. See the Fabric8 migration guide for wire-format |
| 50 | +differences that cannot be restored, and review regenerated CRDs before applying them. |
| 51 | + |
| 52 | +## HTTP client selection |
| 53 | + |
| 54 | +The `operator-framework` module continues to use the JDK HTTP client by default. Fabric8's |
| 55 | +default HTTP client is now `kubernetes-httpclient-vertx-5`, which the core module excludes so |
| 56 | +that it does not bring a second HTTP implementation into operators. |
| 57 | + |
| 58 | +If you select Vert.x through `fabric8-httpclient-impl.name`, use `vertx-5` instead of `vertx`. |
| 59 | +Explicit Vert.x dependencies should use `io.fabric8:kubernetes-httpclient-vertx-5` and compatible |
| 60 | +Vert.x 5 dependencies. Applications depending only on `operator-framework-core` must provide |
| 61 | +their chosen Fabric8 HTTP client implementation. |
| 62 | + |
| 63 | +## CRD generation |
| 64 | + |
| 65 | +Fabric8 removed the `crd-generator-apt` annotation processor. Use the |
| 66 | +[`crd-generator-maven-plugin`](../../documentation/features/#automatic-crd-generation) instead. |
| 67 | +Only `apiextensions.k8s.io/v1` CRDs are generated. |
0 commit comments