You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2022/10/26 13:52:52 UTC
[camel-karavan] branch main updated: Watcher labels based on kubernetes distribution
This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push:
new 1341e27 Watcher labels based on kubernetes distribution
1341e27 is described below
commit 1341e27d92356dd12ae7a36ec0aaf42a18d4ae34
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Wed Oct 26 09:52:41 2022 -0400
Watcher labels based on kubernetes distribution
---
.../org/apache/camel/karavan/service/KubernetesService.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java b/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java
index a16fb36..d150261 100644
--- a/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java
+++ b/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java
@@ -108,14 +108,15 @@ public class KubernetesService {
Optional<KaravanConfiguration.Environment> env = config.environments().stream()
.filter(environment -> environment.name().equals("dev")).findFirst();
if (env.isPresent()) {
+ String labelName = isOpenshift() ? "app.openshift.io/runtime" : "app.kubernetes.io/runtime";
try {
- watches.add(kubernetesClient().apps().deployments().inNamespace(currentNamespace).withLabel("app.openshift.io/runtime", "camel")
+ watches.add(kubernetesClient().apps().deployments().inNamespace(currentNamespace).withLabel(labelName, "camel")
.watch(new DeploymentWatcher(infinispanService, this)));
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
try {
- watches.add(kubernetesClient().pods().inNamespace(currentNamespace).withLabel("app.openshift.io/runtime", "camel")
+ watches.add(kubernetesClient().pods().inNamespace(currentNamespace).withLabel(labelName, "camel")
.watch(new PodWatcher(infinispanService, this)));
} catch (Exception e){
LOGGER.error(e.getMessage());
@@ -354,7 +355,7 @@ public class KubernetesService {
public List<String> getProjectImageTags(String projectId, String namespace) {
List<String> result = new ArrayList<>();
try {
- if (kubernetesClient().isAdaptable(OpenShiftClient.class)) {
+ if (isOpenshift()) {
ImageStream is = openshiftClient().imageStreams().inNamespace(namespace).withName(projectId).get();
if (is != null) {
result.addAll(is.getSpec().getTags().stream().map(t -> t.getName()).sorted(Comparator.reverseOrder()).collect(Collectors.toList()));
@@ -372,6 +373,10 @@ public class KubernetesService {
return kubernetesClient().secrets().inNamespace(currentNamespace).withName("karavan").get();
}
+ public boolean isOpenshift() {
+ return kubernetesClient().isAdaptable(OpenShiftClient.class);
+ }
+
public boolean inKubernetes() {
return !Objects.equals(currentNamespace, "localhost");
}