diff --git a/CHANGELOG.md b/CHANGELOG.md index 2640f535694..ed224f79d4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Fix #4365: The Watch retry logic will handle more cases, as well as perform an exceptional close for events that are not properly handled. Informers can directly provide those exceptional outcomes via the SharedIndexInformer.stopped CompletableFuture. * Fix #4396: Provide more error context when @Group/@Version annotations are missing * Fix #4384: The Java generator now supports the generation of specific annotations (min, max, pattern, etc.), as defined by #4348 +* Fix #3864: Change ManagedOpenShiftClient OSGi ConfigurationPolicy to REQUIRE #### Dependency Upgrade * Fix #4243: Update Tekton pipeline model to v0.39.0 @@ -26,6 +27,7 @@ * Fix #4350: SchemaSwap's fieldName parameter now expects a field name only, not a method or a constructor. * Module `io.fabric8:tekton-model-triggers` which contained Tekton triggers v1alpha1 model has been removed. We have introduced separate modules `io.fabric8:tekton-model-v1alpha1` and `io.fabric8:tekton-model-v1beta1` for Tekton triggers v1alpha1 and v1beta1 apigroups respectively. Users who are using `io.fabric8:tekton-client` dependency directly should be unaffected by this change. * Fix #4384: javax.validation.* annotations are no longer added by the Java generator. +* Fix #3864: Now it's compulsory to provide `etc/io.fabric8.openshift.client.cfg` file in order to load ManagedOpenShiftClient in OSGi environment. ### 6.1.1 (2022-09-01) diff --git a/doc/FAQ.md b/doc/FAQ.md index c07031e0770..4dc341ce43b 100644 --- a/doc/FAQ.md +++ b/doc/FAQ.md @@ -49,3 +49,37 @@ Finally the fabric8 client will use 1 thread per PortForward and an additional t Like many java application the Fabric8 Client utilizes [slf4j](https://www.slf4j.org/). You may configure support for whatever underlying logging framework suits your needs. The logging contexts for the Fabric8 Client follow the standard convention of the package structure - everything from within the client will be rooted at the io.fabric8 context. Third-party dependencies, including the chosen HTTP client implementation, will have different root contexts. If you are using pod exec, which can occur indirectly via pod operations like copying files, and not seeing the expected behavior - please enable debug logging for the io.fabric8.kubernetes.client.dsl.internal context. That will provide the stdErr and stdOut as debug logs to further diagnose what is occurring. + +### How to use KubernetesClient in OSGi? + +Fabric8 Kubernetes Client provides ManagedKubernetesClient and ManagedOpenShiftClient as [OSGi Declarative Service](https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html). In order to use it, you must have [Service Component Runtime (SCR)](https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html#service.component-service.component.runtime) feature enabled in your OSGi runtime. In [Apache Karaf](https://karaf.apache.org/), you can add this to Karaf Maven Plugin configuration: +```xml + + org.apache.karaf.tooling + karaf-maven-plugin + ${karaf.version} + + + scr + + + +``` + +You would need to provide component configuration files for the client you're using. For example, in case of [Apache Karaf](https://karaf.apache.org/), place configuration files in this directory: +``` +src/ +└── main + └── resources + ├── assembly + │ └── etc + │ ├── io.fabric8.kubernetes.client.cfg + │ ├── io.fabric8.openshift.client.cfg +``` + +Once added KubernetesClient declarative services would be exposed automatically on startup. Then you can inject it in your project. Here is an example using Apache camel's `@BeanInject` annotation: + +```java + @BeanInject + private KubernetesClient kubernetesClient +``` diff --git a/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java b/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java index 263eeac6c4d..7668af45111 100644 --- a/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java +++ b/openshift-client/src/main/java/io/fabric8/openshift/client/osgi/ManagedOpenShiftClient.java @@ -183,7 +183,7 @@ import static io.fabric8.openshift.client.OpenShiftConfig.OPENSHIFT_BUILD_TIMEOUT_SYSTEM_PROPERTY; import static io.fabric8.openshift.client.OpenShiftConfig.OPENSHIFT_URL_SYSTEM_PROPERTY; -@Component(configurationPid = "io.fabric8.openshift.client", policy = ConfigurationPolicy.OPTIONAL) +@Component(configurationPid = "io.fabric8.openshift.client", policy = ConfigurationPolicy.REQUIRE) @Service({ OpenShiftClient.class, NamespacedOpenShiftClient.class }) public class ManagedOpenShiftClient extends NamespacedKubernetesClientAdapter implements NamespacedOpenShiftClient { diff --git a/platforms/karaf/itests/src/test/java/io/fabric8/kubernetes/karaf/itests/TestBase.java b/platforms/karaf/itests/src/test/java/io/fabric8/kubernetes/karaf/itests/TestBase.java index 8b821cea628..366e45f9ecb 100644 --- a/platforms/karaf/itests/src/test/java/io/fabric8/kubernetes/karaf/itests/TestBase.java +++ b/platforms/karaf/itests/src/test/java/io/fabric8/kubernetes/karaf/itests/TestBase.java @@ -55,6 +55,8 @@ Option[] baseConfiguration(Option features, List