-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace kubernetes_asyncio with kr8s in cluster discovery (#784)
* Replace kubernetes_asyncio with kr8s in cluster discovery * Ensure DaskCluster kr8s resource is registered * Allow more reruns * Nudge GitHub Actions
- Loading branch information
1 parent
bf24d20
commit 1592f89
Showing
2 changed files
with
6 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
from typing import Callable, AsyncIterator, Tuple | ||
|
||
import kubernetes_asyncio as kubernetes | ||
import kr8s | ||
|
||
from dask_kubernetes.operator.kubecluster import KubeCluster | ||
from dask_kubernetes.common.auth import ClusterAuth | ||
from dask_kubernetes.common.utils import get_current_namespace | ||
from dask_kubernetes.operator._objects import DaskCluster # noqa | ||
|
||
|
||
async def discover() -> AsyncIterator[Tuple[str, Callable]]: | ||
|
||
await ClusterAuth.load_first() | ||
|
||
try: | ||
async with kubernetes.client.api_client.ApiClient() as api_client: | ||
custom_objects_api = kubernetes.client.CustomObjectsApi(api_client) | ||
clusters = await custom_objects_api.list_namespaced_custom_object( | ||
group="kubernetes.dask.org", | ||
version="v1", | ||
plural="daskclusters", | ||
namespace=get_current_namespace(), | ||
) | ||
for cluster in clusters["items"]: | ||
yield (cluster["metadata"]["name"], KubeCluster) | ||
clusters = await kr8s.asyncio.get("daskclusters", namespace=kr8s.ALL) | ||
for cluster in clusters: | ||
yield (cluster.name, KubeCluster) | ||
except Exception: | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters