I read an article https://developers.redhat.com/articles/2021/07/16/whats-new-fabric8-kubernetes-client-version-550#new_features_in_fabric8_kubernetes_client_5_5_0, it mentioned in 5.5 release it adds "Certification management", however, seem I could not find any source codes related to it in fabric8 repo.
when I run a simple code like this
try (CertManagerClient certManagerClient = new DefaultCertManagerClient()) {
CertificateRequest certificateRequest = new CertificateRequestBuilder()
.withNewMetadata().withName("barry_coding_test").endMetadata()
.withNewSpec()
.withRequest(request)
.withIsCA(false)
.addToUsages("signing", "digital signature", "server auth")
.withDuration(Duration.parse("2160h"))
.withIssuerRef(new ObjectReferenceBuilder()
.withName("barry-dlc-cert-issuer")
.withKind("Issuer")
.withGroup("cert-manager.io")
.build())
.endSpec()
.build();
certManagerClient.v1().certificateRequests().inNamespace("barry").create(certificateRequest);
} catch (Exception e) {
e.printStackTrace();
}
It throws error
Exception in thread "main" java.lang.NoSuchMethodError: io/fabric8/kubernetes/client/dsl/base/HasMetadataOperation.<init>(Lio/fabric8/kubernetes/client/dsl/base/OperationContext;)V (loaded from file:/Users/zhBarry@ca.ibm.com/osprey/mvnexample/java-app/dlc-management-service/libs/kubernetes-client-5.8.0.jar by jdk.internal.loader.ClassLoaders$AppClassLoader@40575da4) called from class io.fabric8.certmanager.client.api.v1.internal.CertificateRequestOperationsImpl (loaded from file:/Users/zhBarry@ca.ibm.com/osprey/mvnexample/java-app/dlc-management-service/libs/certmanager-client-5.5.0.jar by jdk.internal.loader.ClassLoaders$AppClassLoader@40575da4).
at io.fabric8.certmanager.client.api.v1.internal.CertificateRequestOperationsImpl.<init>(CertificateRequestOperationsImpl.java:32)
at io.fabric8.certmanager.client.api.v1.internal.CertificateRequestOperationsImpl.<init>(CertificateRequestOperationsImpl.java:28)
at io.fabric8.certmanager.client.V1APIGroupClient.certificateRequests(V1APIGroupClient.java:51)
at com.ibm.si.osprey.App.main(App.java:67)
I could not find source code CertificateRequestOperationsImpl.java at all in the repo.
Any ideas for it? Where can I certmanager implementation in the fabric8 repo?
You wouldn't find CertManager related features in kubernetes-client
jar itself. All Fabric8 Kubernetes Client Extensions are available via their own individual jars. For CertManager, you need to add this dependency:
Maven:
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>certmanager-client</artifactId>
<version>5.9.0</version>
</dependency>
Gradle:
implementation 'io.fabric8:certmanager-client:5.9.0'
There is an example placed in https://github.com/fabric8io/kubernetes-client/tree/master/extensions/certmanager/examples/src/main/java/io/fabric8/certmanager/examples/v1 . Maybe this section needs improvement; you're welcome to contribute some more examples if you have some time :-) .
I've tested your sample on a demo project with certmanager-client
dependency with certmanager installed on minikube. You can find demo project here: https://github.com/rohankanojia-forks/cert-manager-java-extension-demo