diff --git a/dist-material/release-docs/LICENSE b/dist-material/release-docs/LICENSE
index 91f887319..6175b968d 100755
--- a/dist-material/release-docs/LICENSE
+++ b/dist-material/release-docs/LICENSE
@@ -267,7 +267,8 @@ The text of each license is the standard Apache 2.0 license.
Apache: commons-collections 3.2.2: https://github.com/apache/commons-collections, Apache 2.0
Apache: commons-configuration 1.8: https://github.com/apache/commons-configuration, Apache 2.0
Apache: commons-io 2.4: https://github.com/apache/commons-io, Apache 2.0
- Apache: commons-compress 1.18: https://github.com/apache/commons-compress, Apache 2.0
+ Apache: commons-compress 1.19: https://github.com/apache/commons-compress, Apache 2.0
+ Apache: commons-collections4 4.1: https://mvnrepository.com/artifact/org.apache.commons/commons-collections4, Apache 2.0
Apache: tomcat 8.5.27: https://github.com/apache/tomcat/tree/trunk, Apache 2.0
Apache: freemarker 2.3.28: https://github.com/apache/freemarker, Apache 2.0
netty 5.5.0: https://github.com/netty/netty/blob/4.1/LICENSE.txt, Apache 2.0
@@ -304,7 +305,7 @@ The text of each license is the standard Apache 2.0 license.
HikariCP 3.1.0: https://github.com/brettwooldridge/HikariCP, Apache 2.0
zipkin 2.9.1: https://github.com/openzipkin/zipkin, Apache 2.0
sharding-jdbc-core 2.0.3: https://github.com/sharding-sphere/sharding-sphere, Apache 2.0
- kubernetes-client 4.0.0: https://github.com/kubernetes-client/java, Apache 2.0
+ kubernetes-client 8.0.0: https://github.com/kubernetes-client/java, Apache 2.0
proto files from istio/istio: https://github.com/istio/istio Apache 2.0
proto files from istio/api: https://github.com/istio/api Apache 2.0
consul-client 1.2.6: https://github.com/rickfast/consul-client, Apache 2.0
@@ -327,6 +328,12 @@ The text of each license is the standard Apache 2.0 license.
moshi 1.5.0: https://github.com/square/moshi, Apache 2.0
logging-interceptor 3.13.1: https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor, Apache 2.0
msgpack-core 0.8.16: https://github.com/msgpack/msgpack-java, Apache 2.0
+ sundr-codegen 0.2.10: https://mvnrepository.com/artifact/io.sundr/sundr-codegen, Apache 2.0
+ sundr-core 0.2.10: https://mvnrepository.com/artifact/io.sundr/sundr-core, Apache 2.0
+ swagger-annotations 1.5.22: https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-annotations, Apache 2.0
+ resourcecify-annotations 0.21.0: https://mvnrepository.com/artifact/io.sundr/resourcecify-annotations, Apache 2.0
+ jose4j 0.7.0: https://mvnrepository.com/artifact/org.bitbucket.b_c/jose4j, Apache 2.0
+ converter-moshi 2.5.0: https://mvnrepository.com/artifact/com.squareup.retrofit2/converter-moshi, Apache 2.0
vavr 0.10.3: https://github.com/vavr-io/vavr, Apache 2.0
========================================================================
@@ -341,8 +348,9 @@ The text of each license is also included at licenses/LICENSE-[project].txt.
GraphQL java 6.0: https://github.com/graphql-java/graphql-java , MIT
GraphQL Java Tools 4.3.0: https://github.com/graphql-java/graphql-java-tools , MIT
jopt-simple 5.0.2: https://github.com/jopt-simple/jopt-simple , MIT
- bcpkix-jdk15on 1.55: http://www.bouncycastle.org/licence.html , MIT
- bcprov-jdk15on 1.55: http://www.bouncycastle.org/licence.html , MIT
+ bcpkix-jdk15on 1.61: http://www.bouncycastle.org/licence.html , MIT
+ bcprov-jdk15on 1.61: http://www.bouncycastle.org/licence.html , MIT
+ bcprov-ext-jdk15on 1.61: http://www.bouncycastle.org/licence.html , MIT
minimal-json 0.9.5: https://github.com/ralfstx/minimal-json, MIT
checker-qual 2.8.1: https://github.com/typetools/checker-framework, MIT
influxdb-java 2.15: https://github.com/influxdata/influxdb-java, MIT
@@ -429,6 +437,7 @@ popper.js 1.14.7: https://github.com/FezVrasta/popper.js MIT
vue-datepicker-local 1.0.19: https://github.com/weifeiyue/vue-datepicker-local MIT
vue-js-modal 1.3.31: https://github.com/euvl/vue-js-modal MIT
lodash 4.17.15: https://github.com/lodash/lodash MIT
+gson-fire 1.8.3: https://mvnrepository.com/artifact/io.gsonfire/gson-fire MIT
========================================
Apache 2.0 licenses
diff --git a/oap-server/pom.xml b/oap-server/pom.xml
index 3c6faf9f0..f7fbf6a1b 100755
--- a/oap-server/pom.xml
+++ b/oap-server/pom.xml
@@ -65,7 +65,7 @@
2.6
6.3.2
2.10.5
- 4.0.0
+ 8.0.0
3.1.0
2.9.1
2.6.2
diff --git a/oap-server/server-bootstrap/src/main/resources/application.yml b/oap-server/server-bootstrap/src/main/resources/application.yml
index 3761bef03..cf91f6124 100755
--- a/oap-server/server-bootstrap/src/main/resources/application.yml
+++ b/oap-server/server-bootstrap/src/main/resources/application.yml
@@ -29,7 +29,6 @@ cluster:
schema: ${SW_ZK_SCHEMA:digest} # only support digest schema
expression: ${SW_ZK_EXPRESSION:skywalking:skywalking}
kubernetes:
- watchTimeoutSeconds: ${SW_CLUSTER_K8S_WATCH_TIMEOUT:60}
namespace: ${SW_CLUSTER_K8S_NAMESPACE:default}
labelSelector: ${SW_CLUSTER_K8S_LABEL:app=collector,release=skywalking}
uidEnvName: ${SW_CLUSTER_K8S_UID:SKYWALKING_COLLECTOR_UID}
diff --git a/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/ClusterModuleKubernetesConfig.java b/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/ClusterModuleKubernetesConfig.java
index 986f3c185..739bb6978 100644
--- a/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/ClusterModuleKubernetesConfig.java
+++ b/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/ClusterModuleKubernetesConfig.java
@@ -18,46 +18,17 @@
package org.apache.skywalking.oap.server.cluster.plugin.kubernetes;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.skywalking.oap.server.library.module.ModuleConfig;
/**
* The configuration of the module of cluster.kubernetes
*/
+@Getter
+@Setter
public class ClusterModuleKubernetesConfig extends ModuleConfig {
- private int watchTimeoutSeconds;
private String namespace;
private String labelSelector;
private String uidEnvName;
-
- public int getWatchTimeoutSeconds() {
- return watchTimeoutSeconds;
- }
-
- public void setWatchTimeoutSeconds(int watchTimeoutSeconds) {
- this.watchTimeoutSeconds = watchTimeoutSeconds;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- public void setNamespace(String namespace) {
- this.namespace = namespace;
- }
-
- public String getLabelSelector() {
- return labelSelector;
- }
-
- public void setLabelSelector(String labelSelector) {
- this.labelSelector = labelSelector;
- }
-
- public String getUidEnvName() {
- return uidEnvName;
- }
-
- public void setUidEnvName(String uidEnvName) {
- this.uidEnvName = uidEnvName;
- }
}
diff --git a/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/ClusterModuleKubernetesProvider.java b/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/ClusterModuleKubernetesProvider.java
index bb49ccd8b..0c8807f95 100644
--- a/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/ClusterModuleKubernetesProvider.java
+++ b/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/ClusterModuleKubernetesProvider.java
@@ -18,8 +18,7 @@
package org.apache.skywalking.oap.server.cluster.plugin.kubernetes;
-import org.apache.skywalking.oap.server.cluster.plugin.kubernetes.dependencies.NamespacedPodListWatch;
-import org.apache.skywalking.oap.server.cluster.plugin.kubernetes.dependencies.UidEnvSupplier;
+import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.cluster.ClusterModule;
import org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery;
import org.apache.skywalking.oap.server.core.cluster.ClusterRegister;
@@ -58,24 +57,23 @@ public class ClusterModuleKubernetesProvider extends ModuleProvider {
@Override
public void prepare() throws ServiceNotProvidedException {
- coordinator = new KubernetesCoordinator(getManager(), new NamespacedPodListWatch(config.getNamespace(), config.getLabelSelector(), config
- .getWatchTimeoutSeconds()), new UidEnvSupplier(config.getUidEnvName()));
+
+ coordinator = new KubernetesCoordinator(getManager(), config);
this.registerServiceImplementation(ClusterRegister.class, coordinator);
this.registerServiceImplementation(ClusterNodesQuery.class, coordinator);
}
@Override
public void start() {
-
+ NamespacedPodListInformer.INFORMER.init(config);
}
@Override
public void notifyAfterCompleted() {
- coordinator.start();
}
@Override
public String[] requiredModules() {
- return new String[0];
+ return new String[] {CoreModule.NAME};
}
}
diff --git a/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/Event.java b/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/Event.java
deleted file mode 100644
index 103c826a6..000000000
--- a/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/Event.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.skywalking.oap.server.cluster.plugin.kubernetes;
-
-/**
- * The event of watch.
- */
-public class Event {
- private final String type;
- private final String uid;
- private final String host;
-
- public Event(final String type, final String uid, final String host) {
- this.type = type;
- this.uid = uid;
- this.host = host;
- }
-
- String getType() {
- return type;
- }
-
- String getUid() {
- return uid;
- }
-
- String getHost() {
- return host;
- }
-}
diff --git a/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/KubernetesCoordinator.java b/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/KubernetesCoordinator.java
index 9f3a8779b..7e2e425fb 100644
--- a/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/KubernetesCoordinator.java
+++ b/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/KubernetesCoordinator.java
@@ -18,21 +18,13 @@
package org.apache.skywalking.oap.server.cluster.plugin.kubernetes;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import java.util.ArrayList;
+import io.kubernetes.client.openapi.models.V1ObjectMeta;
+import io.kubernetes.client.openapi.models.V1Pod;
+import io.kubernetes.client.openapi.models.V1PodStatus;
+import java.util.Collections;
import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.function.Supplier;
-import javax.annotation.Nullable;
+import java.util.stream.Collectors;
+import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery;
import org.apache.skywalking.oap.server.core.cluster.ClusterRegister;
@@ -42,108 +34,64 @@ import org.apache.skywalking.oap.server.core.config.ConfigService;
import org.apache.skywalking.oap.server.core.remote.client.Address;
import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder;
import org.apache.skywalking.oap.server.telemetry.api.TelemetryRelatedContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Read collector pod info from api-server of kubernetes, then using all containerIp list to construct the list of
* {@link RemoteInstance}.
*/
+@Slf4j
public class KubernetesCoordinator implements ClusterRegister, ClusterNodesQuery {
- private static final Logger logger = LoggerFactory.getLogger(KubernetesCoordinator.class);
-
private final ModuleDefineHolder manager;
- private final String uid;
-
- private final Map cache = new ConcurrentHashMap<>();
-
- private final ReusableWatch watch;
-
private volatile int port = -1;
- KubernetesCoordinator(ModuleDefineHolder manager, final ReusableWatch watch,
- final Supplier uidSupplier) {
+ private final String uid;
+
+ public KubernetesCoordinator(final ModuleDefineHolder manager,
+ final ClusterModuleKubernetesConfig config) {
+ this.uid = new UidEnvSupplier(config.getUidEnvName()).get();
this.manager = manager;
- this.watch = watch;
- this.uid = uidSupplier.get();
- TelemetryRelatedContext.INSTANCE.setId(uid);
- }
-
- public void start() {
- ExecutorService executorService = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setDaemon(true)
- .setNameFormat("Kubernetes-ApiServer-%s")
- .build());
- submitTask(MoreExecutors.listeningDecorator(executorService), executorService);
- }
-
- @Override
- public void registerRemote(RemoteInstance remoteInstance) throws ServiceRegisterException {
- this.port = remoteInstance.getAddress().getPort();
- }
-
- private void submitTask(final ListeningExecutorService service, final ExecutorService executorService) {
- watch.initOrReset();
-
- ListenableFuture> watchFuture = service.submit(newWatch());
- Futures.addCallback(watchFuture, new FutureCallback