1111import java .io .InputStream ;
1212import java .io .InputStreamReader ;
1313import java .math .BigInteger ;
14+ import java .net .InetAddress ;
1415import java .security .KeyFactory ;
1516import java .security .KeyStore ;
1617import java .security .KeyStoreException ;
6667import io .github .kubesys .client .utils .URLUtil ;
6768
6869/**
69- * This class is used for creating a connection between users' application and Kubernetes server.
70- * It provides an easy-to-use way to Create, Update, Delete, Get, List and Watch all Kubernetes resources.
70+ * Kubernetes的客户端,根据https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/的
71+ * URL规则生产URL
72+ *
73+ * 对于JSON参数,可参见https://kubernetes.io/docs/reference/kubernetes-api/
7174 *
7275 * @author wuheng@iscas.ac.cn
7376 * @since 2.0.0
@@ -676,6 +679,7 @@ public Thread watchResources(String kind, String namespace, KubernetesWatcher wa
676679 + (namespace == null || "" .equals (namespace ) ? "all-namespaces" : namespace );
677680 return watchResources (watchName , kind , namespace , watcher );
678681 }
682+
679683
680684 /**
681685 * watch a Kubernetes resources using kind, namespace, and WebSocketListener
@@ -694,6 +698,23 @@ public Thread watchResources(String watchName, String kind, String namespace, Ku
694698 thread .start ();
695699 return thread ;
696700 }
701+
702+ /**
703+ * watch a Kubernetes resources using kind, namespace, and WebSocketListener
704+ *
705+ * @param watcher watcher
706+ * @return thread thread
707+ * @throws Exception Kubernetes cannot parsing this jsonStr
708+ */
709+ public Thread watchPodsOnLocalNode (KubernetesWatcher watcher )
710+ throws Exception {
711+ String hostname = InetAddress .getLocalHost ().getHostName ().toLowerCase ();
712+ watcher .setRequest (ReqUtil .get (requester , analyzer .getConvertor ()
713+ .watchAllUrlWithFieldSelector ("Pod" , "" , "spec.nodeName=" + hostname )));
714+ Thread thread = new Thread (watcher , "watch-pods-by-hostname" );
715+ thread .start ();
716+ return thread ;
717+ }
697718
698719 /**
699720 * for Scheduler
0 commit comments