-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[KOGITO-9145] Create an implementation of the Service Discovery catal… #3166
Changes from 3 commits
455b2a3
c409a15
045b847
fe2978d
f4a0473
bfe03c7
f94e0ea
623dab7
459e5a7
70b8e9d
ffe57f6
46bb068
5619273
70e5115
ecc5e52
ef27a2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.kie.kogito</groupId> | ||
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog-parent</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog-deployment</artifactId> | ||
<name>Kogito Add-On MicroProfile Config Service Catalog - Deployment</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.kie.kogito</groupId> | ||
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-reactive-deployment</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${version.io.quarkus}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.kie.kogito</groupId> | ||
<artifactId>kogito-addons-quarkus-parent</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog-parent</artifactId> | ||
<name>Kogito Add-On MicroProfile Config Service Catalog - Parent</name> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>deployment</module> | ||
<module>runtime</module> | ||
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to register these modules in the kogito-bom. Take a look at https://github.com/kiegroup/kogito-runtimes/blob/e37b961eb5fec25b4545a7937b5f067fee331ade/kogito-bom/pom.xml#L318 to use the Fabric8 implementation as a reference. |
||
</modules> | ||
</project> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,82 @@ | ||||||
<?xml version="1.0" encoding="UTF-8"?> | ||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||||
<modelVersion>4.0.0</modelVersion> | ||||||
<parent> | ||||||
<groupId>org.kie.kogito</groupId> | ||||||
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog-parent</artifactId> | ||||||
<version>2.0.0-SNAPSHOT</version> | ||||||
</parent> | ||||||
|
||||||
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog</artifactId> | ||||||
<name>Kogito Add-On MicroProfile Config Service Catalog</name> | ||||||
<dependencies> | ||||||
<dependency> | ||||||
<groupId>org.kie.kogito</groupId> | ||||||
<artifactId>kogito-addons-kubernetes-service-catalog</artifactId> | ||||||
</dependency> | ||||||
<dependency> | ||||||
<groupId>io.quarkus</groupId> | ||||||
<artifactId>quarkus-resteasy-reactive</artifactId> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we only need CDI here, we can replace it with Arc.
Suggested change
|
||||||
</dependency> | ||||||
<dependency> | ||||||
<groupId>io.quarkus</groupId> | ||||||
<artifactId>quarkus-junit5</artifactId> | ||||||
<scope>test</scope> | ||||||
</dependency> | ||||||
<dependency> | ||||||
<groupId>org.assertj</groupId> | ||||||
<artifactId>assertj-core</artifactId> | ||||||
<scope>test</scope> | ||||||
</dependency> | ||||||
<dependency> | ||||||
<groupId>org.eclipse.microprofile.config</groupId> | ||||||
<artifactId>microprofile-config-api</artifactId> | ||||||
</dependency> | ||||||
<dependency> | ||||||
<groupId>org.kie.kogito</groupId> | ||||||
<artifactId>kogito-addons-kubernetes-service-catalog</artifactId> | ||||||
<version>${project.version}</version> | ||||||
<type>test-jar</type> | ||||||
<scope>test</scope> | ||||||
</dependency> | ||||||
</dependencies> | ||||||
|
||||||
<build> | ||||||
<plugins> | ||||||
<plugin> | ||||||
<groupId>io.quarkus</groupId> | ||||||
<artifactId>quarkus-bootstrap-maven-plugin</artifactId> | ||||||
<version>${version.io.quarkus}</version> | ||||||
<executions> | ||||||
<execution> | ||||||
<phase>compile</phase> | ||||||
<goals> | ||||||
<goal>extension-descriptor</goal> | ||||||
</goals> | ||||||
<configuration> | ||||||
<deployment>${project.groupId}:${project.artifactId}-deployment:${project.version} | ||||||
</deployment> | ||||||
<capabilities> | ||||||
<provides>org.kie.kogito.addons.quarkus.microprofile.config.service.catalog</provides> | ||||||
</capabilities> | ||||||
</configuration> | ||||||
</execution> | ||||||
</executions> | ||||||
</plugin> | ||||||
<plugin> | ||||||
<artifactId>maven-compiler-plugin</artifactId> | ||||||
<configuration> | ||||||
<annotationProcessorPaths> | ||||||
<path> | ||||||
<groupId>io.quarkus</groupId> | ||||||
<artifactId>quarkus-extension-processor</artifactId> | ||||||
<version>${version.io.quarkus}</version> | ||||||
</path> | ||||||
</annotationProcessorPaths> | ||||||
</configuration> | ||||||
</plugin> | ||||||
</plugins> | ||||||
</build> | ||||||
</project> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||||||||||||||
/* | ||||||||||||||||||
* Copyright 2023 Red Hat, Inc. and/or its affiliates. | ||||||||||||||||||
* | ||||||||||||||||||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||
* you may not use this file except in compliance with the License. | ||||||||||||||||||
* You may obtain a copy of the License at | ||||||||||||||||||
* | ||||||||||||||||||
* http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||
* | ||||||||||||||||||
* Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||
* distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||
* See the License for the specific language governing permissions and | ||||||||||||||||||
* limitations under the License. | ||||||||||||||||||
*/ | ||||||||||||||||||
package org.kie.kogito.addons.quarkus.microprofile.config.service.catalog; | ||||||||||||||||||
|
||||||||||||||||||
import java.net.URI; | ||||||||||||||||||
import java.net.URISyntaxException; | ||||||||||||||||||
import java.util.Optional; | ||||||||||||||||||
|
||||||||||||||||||
import javax.enterprise.context.ApplicationScoped; | ||||||||||||||||||
import javax.inject.Inject; | ||||||||||||||||||
|
||||||||||||||||||
import org.eclipse.microprofile.config.Config; | ||||||||||||||||||
import org.kie.kogito.addons.k8s.resource.catalog.KubernetesServiceCatalog; | ||||||||||||||||||
import org.kie.kogito.addons.k8s.resource.catalog.KubernetesServiceCatalogKey; | ||||||||||||||||||
|
||||||||||||||||||
@ApplicationScoped | ||||||||||||||||||
public class MicroProfileConfigServiceCatalog implements KubernetesServiceCatalog { | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I would rewrite this class as: @ApplicationScoped
public class MicroProfileConfigServiceCatalog implements KubernetesServiceCatalog {
@Inject
Config config;
@Override
public Optional<URI> getServiceAddress(KubernetesServiceCatalogKey key) {
return config.getOptionalValue(key.getProtocol().getValue() + ":" + key.getCoordinates(), String.class)
.map(value -> {
try {
return new URI(value);
} catch (URISyntaxException e) {
// TODO: handle
throw new RuntimeException(e);
}
});
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hbelmiro Thank you for the suggestions. I will test it after making necessary changes. |
||||||||||||||||||
|
||||||||||||||||||
@Inject | ||||||||||||||||||
Config config; | ||||||||||||||||||
|
||||||||||||||||||
@Override | ||||||||||||||||||
public Optional<URI> getServiceAddress(KubernetesServiceCatalogKey key) { | ||||||||||||||||||
String configValue = config.getValue(key.getProtocol().getValue() + ":" + key.getCoordinates(), String.class); | ||||||||||||||||||
try { | ||||||||||||||||||
return Optional.of(new URI(configValue)); | ||||||||||||||||||
} catch (URISyntaxException e) { | ||||||||||||||||||
throw new RuntimeException(e); | ||||||||||||||||||
} | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The property is optional (this method must return
Suggested change
|
||||||||||||||||||
} | ||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2023 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.kie.kogito.addons.quarkus.microprofile.config.service.catalog; | ||
|
||
import org.kie.kogito.addons.k8s.resource.catalog.KubernetesServiceCatalog; | ||
import org.kie.kogito.addons.k8s.resource.catalog.KubernetesServiceCatalogProvider; | ||
|
||
public class MicroProfileConfigServiceCatalogProvider implements KubernetesServiceCatalogProvider { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget to create the ServiceLoader file. Like https://github.com/kiegroup/kogito-runtimes/blob/1c99c7bbe2ec21eba5ac79e4e053c02bd5345a88/quarkus/addons/fabric8-kubernetes-service-catalog/runtime/src/main/resources/META-INF/services/org.kie.kogito.addons.k8s.resource.catalog.KubernetesServiceCatalogProvider. |
||
|
||
@Override | ||
public KubernetesServiceCatalog create() { | ||
return new MicroProfileConfigServiceCatalog(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.kie.kogito.addons.quarkus.microprofile.config.service.catalog.MicroProfileConfigServiceCatalogProvider |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2023 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.kie.kogito.addons.quarkus.microprofile.config.service.catalog; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
import org.junit.jupiter.api.Test; | ||
import org.kie.kogito.addons.k8s.resource.catalog.KubernetesProtocol; | ||
import org.kie.kogito.addons.k8s.resource.catalog.KubernetesServiceCatalogKey; | ||
import org.kie.kogito.addons.k8s.resource.catalog.KubernetesServiceCatalogTest; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
@QuarkusTest | ||
public class MicroProfileConfigServiceCatalogTest extends KubernetesServiceCatalogTest { | ||
|
||
private static final String KUBERNETES_SERVICENAME = "serverless-workflow-greeting-quarkus-kubernetes"; | ||
|
||
private static final String NAMESPACE = "test"; | ||
|
||
private static final String NAMESPACE_KUBERNETES_SERVICENAME = NAMESPACE + '/' + KUBERNETES_SERVICENAME; | ||
|
||
@Inject | ||
MicroProfileConfigServiceCatalog configServiceCatalog; | ||
|
||
@Inject | ||
Config config; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This attribute can be removed. |
||
|
||
@Inject | ||
MicroProfileConfigServiceCatalogTest(MicroProfileConfigServiceCatalog configServiceCatalog) { | ||
super(configServiceCatalog); | ||
} | ||
|
||
@Test | ||
public void testGetServiceAddressWithInvalidURI() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both implementations (Fabric8 and MP Config) must have the same behavior. So, this test should be moved to |
||
KubernetesServiceCatalogKey key = new KubernetesServiceCatalogKey(KubernetesProtocol.KUBERNETES, NAMESPACE_KUBERNETES_SERVICENAME); | ||
|
||
assertThrows(RuntimeException.class, () -> configServiceCatalog.getServiceAddress(key)); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# Copyright 2023 Red Hat, Inc. and/or its affiliates. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
knative\:serverless-workflow-greeting-quarkus = http\:\/\/serverless-workflow-greeting-quarkus.test.10.99.154.147.sslip.io | ||
knative\:test\/serverless-workflow-greeting-quarkus = http\:\/\/serverless-workflow-greeting-quarkus.test.10.99.154.147.sslip.io | ||
knative\:services.v1.serving.knative.dev\/serverless-workflow-greeting-quarkus = http\:\/\/serverless-workflow-greeting-quarkus.test.10.99.154.147.sslip.io | ||
knative\:services.v1.serving.knative.dev\/test\/serverless-workflow-greeting-quarkus = http\:\/\/serverless-workflow-greeting-quarkus.test.10.99.154.147.sslip.io | ||
|
||
kubernetes\:services.v1.serving.knative.dev\/serverless-workflow-greeting-quarkus-kubernetes = http\:\/\/serverless-workflow-greeting-quarkus-kubernetes.test.10.99.154.147.sslip.io | ||
kubernetes\:services.v1.serving.knative.dev\/test\/serverless-workflow-greeting-quarkus-kubernetes = http\:\/\/serverless-workflow-greeting-quarkus-kubernetes.test.10.99.154.147.sslip.io | ||
kubernetes\:test\/serverless-workflow-greeting-quarkus-kubernetes = "invalid-uri" | ||
|
||
openshift\:services.v1.serving.knative.dev\/serverless-workflow-greeting-quarkus-openshift = http\:\/\/serverless-workflow-greeting-quarkus-openshift.test.10.99.154.147.sslip.io | ||
openshift\:services.v1.serving.knative.dev\/test\/serverless-workflow-greeting-quarkus-openshift = http\:\/\/serverless-workflow-greeting-quarkus-openshift.test.10.99.154.147.sslip.io |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is not necessary. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
apiVersion: serving.knative.dev/v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
serving.knative.dev/creator: minikube-user | ||
serving.knative.dev/lastModifier: minikube-user | ||
creationTimestamp: '2022-08-17T13:58:53Z' | ||
generation: 1 | ||
name: serverless-workflow-greeting-quarkus-https | ||
resourceVersion: '43817' | ||
uid: 98530cb6-3274-4d0c-b654-a82645cda058 | ||
spec: | ||
template: | ||
metadata: | ||
annotations: | ||
client.knative.dev/updateTimestamp: '2022-08-17T13:58:53Z' | ||
client.knative.dev/user-image: kiegroup/serverless-workflow-greeting-quarkus:1.0 | ||
creationTimestamp: | ||
spec: | ||
containerConcurrency: 0 | ||
containers: | ||
- image: kiegroup/serverless-workflow-greeting-quarkus:1.0 | ||
name: user-container | ||
readinessProbe: | ||
successThreshold: 1 | ||
tcpSocket: | ||
port: 0 | ||
resources: { } | ||
enableServiceLinks: false | ||
timeoutSeconds: 300 | ||
traffic: | ||
- latestRevision: true | ||
percent: 100 | ||
status: | ||
address: | ||
url: http://serverless-workflow-greeting-quarkus.test.svc.cluster.local | ||
conditions: | ||
- lastTransitionTime: '2022-08-17T13:59:00Z' | ||
status: 'True' | ||
type: ConfigurationsReady | ||
- lastTransitionTime: '2022-08-17T13:59:00Z' | ||
status: 'True' | ||
type: Ready | ||
- lastTransitionTime: '2022-08-17T13:59:00Z' | ||
status: 'True' | ||
type: RoutesReady | ||
latestCreatedRevisionName: serverless-workflow-greeting-quarkus-00001 | ||
latestReadyRevisionName: serverless-workflow-greeting-quarkus-00001 | ||
observedGeneration: 1 | ||
traffic: | ||
- latestRevision: true | ||
percent: 100 | ||
revisionName: serverless-workflow-greeting-quarkus-00001 | ||
url: https://serverless-workflow-greeting-quarkus.test.10.99.154.147.sslip.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we only need CDI here, we can replace it with Arc.