Skip to content

Commit

Permalink
Only request running pods from Kubernetes API
Browse files Browse the repository at this point in the history
  • Loading branch information
leviramsey committed Sep 25, 2024
1 parent 555ed88 commit 85ce9cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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)))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down

0 comments on commit 85ce9cc

Please sign in to comment.