From 85ce9ccb246f518b683033e8be901313fc051c93 Mon Sep 17 00:00:00 2001 From: Levi Ramsey Date: Wed, 25 Sep 2024 17:03:38 -0400 Subject: [PATCH 1/2] Only request running pods from Kubernetes API --- .../azureapi/rbac/aks/AzureRbacAksServiceDiscovery.scala | 4 ++-- .../discovery/kubernetes/KubernetesApiServiceDiscovery.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/discovery-azure-api/src/main/scala/akka/discovery/azureapi/rbac/aks/AzureRbacAksServiceDiscovery.scala b/discovery-azure-api/src/main/scala/akka/discovery/azureapi/rbac/aks/AzureRbacAksServiceDiscovery.scala index c4a9ab8e..97a284e6 100644 --- a/discovery-azure-api/src/main/scala/akka/discovery/azureapi/rbac/aks/AzureRbacAksServiceDiscovery.scala +++ b/discovery-azure-api/src/main/scala/akka/discovery/azureapi/rbac/aks/AzureRbacAksServiceDiscovery.scala @@ -185,7 +185,7 @@ final class AzureRbacAksServiceDiscovery(implicit system: ExtendedActorSystem) e for { ks <- kubernetesSetup token <- fetchAccessToken.map(_.getToken) - request <- podRequest(token, ks.namespace, selector) + request <- podRequest(token, ks.namespace, selector, true) pods <- pods(ks.ctx, request, resolveTimeout) } yield { val addresses = @@ -209,7 +209,7 @@ final class AzureRbacAksServiceDiscovery(implicit system: ExtendedActorSystem) e val host = settings.apiServiceHost val port = settings.apiServicePort val path = Uri.Path.Empty / "api" / "v1" / "namespaces" / namespace / "pods" - val query = Uri.Query("labelSelector" -> labelSelector) + val query = Uri.Query("labelSelector" -> labelSelector, "fieldSelector" -> "status.phase==Running") val uri = Uri.from(scheme = "https", host = host, port = port).withPath(path).withQuery(query) Future(HttpRequest(uri = uri, headers = List(Authorization(OAuth2BearerToken(token))))) diff --git a/discovery-kubernetes-api/src/main/scala/akka/discovery/kubernetes/KubernetesApiServiceDiscovery.scala b/discovery-kubernetes-api/src/main/scala/akka/discovery/kubernetes/KubernetesApiServiceDiscovery.scala index f56da4f5..69ee2061 100644 --- a/discovery-kubernetes-api/src/main/scala/akka/discovery/kubernetes/KubernetesApiServiceDiscovery.scala +++ b/discovery-kubernetes-api/src/main/scala/akka/discovery/kubernetes/KubernetesApiServiceDiscovery.scala @@ -221,7 +221,7 @@ class KubernetesApiServiceDiscovery(implicit system: ActorSystem) extends Servic port <- Try(portStr.toInt).toOption } yield { val path = Uri.Path.Empty / "api" / "v1" / "namespaces" / namespace / "pods" - val query = Uri.Query("labelSelector" -> labelSelector) + val query = Uri.Query("labelSelector" -> labelSelector, "fieldSelection" -> "status.phase==Running") val uri = Uri.from(scheme = "https", host = host, port = port).withPath(path).withQuery(query) HttpRequest(uri = uri, headers = List(Authorization(OAuth2BearerToken(token)))) From 21ff642a985e56b903705eb4fb79610c2d21e34a Mon Sep 17 00:00:00 2001 From: Levi Ramsey Date: Thu, 26 Sep 2024 09:08:43 -0400 Subject: [PATCH 2/2] azure fix --- .../azureapi/rbac/aks/AzureRbacAksServiceDiscovery.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discovery-azure-api/src/main/scala/akka/discovery/azureapi/rbac/aks/AzureRbacAksServiceDiscovery.scala b/discovery-azure-api/src/main/scala/akka/discovery/azureapi/rbac/aks/AzureRbacAksServiceDiscovery.scala index 97a284e6..f9a9fe47 100644 --- a/discovery-azure-api/src/main/scala/akka/discovery/azureapi/rbac/aks/AzureRbacAksServiceDiscovery.scala +++ b/discovery-azure-api/src/main/scala/akka/discovery/azureapi/rbac/aks/AzureRbacAksServiceDiscovery.scala @@ -185,7 +185,7 @@ final class AzureRbacAksServiceDiscovery(implicit system: ExtendedActorSystem) e for { ks <- kubernetesSetup token <- fetchAccessToken.map(_.getToken) - request <- podRequest(token, ks.namespace, selector, true) + request <- podRequest(token, ks.namespace, selector) pods <- pods(ks.ctx, request, resolveTimeout) } yield { val addresses =