From 734d001836fad228cca809093feec3d07cd634a6 Mon Sep 17 00:00:00 2001 From: Jacob Tomlinson Date: Fri, 5 Jul 2024 16:06:06 +0100 Subject: [PATCH] Bump kr8s to 0.17 and Kubernetes supported versions (#897) * Bump kr8s to 0.17 and use new_class for Dask resource classes * Remove unecessary class attributes * Bump supported Kubernetes versions * Bump README badges --- .github/workflows/operator.yaml | 8 ++-- README.rst | 2 +- dask_kubernetes/operator/_objects.py | 57 ++++++---------------------- docs/source/index.rst | 2 +- pyproject.toml | 2 +- 5 files changed, 18 insertions(+), 53 deletions(-) diff --git a/.github/workflows/operator.yaml b/.github/workflows/operator.yaml index 8e3967c6..85e8648e 100644 --- a/.github/workflows/operator.yaml +++ b/.github/workflows/operator.yaml @@ -26,14 +26,12 @@ jobs: fail-fast: false matrix: python-version: ["3.9", "3.10", "3.11", "3.12"] - kubernetes-version: ["1.29.2"] + kubernetes-version: ["1.30.2"] include: - python-version: '3.10' - kubernetes-version: 1.28.7 + kubernetes-version: 1.29.4 - python-version: '3.10' - kubernetes-version: 1.27.11 - - python-version: '3.10' - kubernetes-version: 1.26.14 + kubernetes-version: 1.28.9 env: KUBECONFIG: .pytest-kind/pytest-kind/kubeconfig diff --git a/README.rst b/README.rst index 6e3fd751..6bc21803 100644 --- a/README.rst +++ b/README.rst @@ -34,7 +34,7 @@ Dask Kubernetes :target: https://kubernetes.dask.org/en/latest/installing.html#supported-versions :alt: Python Support -.. image:: https://img.shields.io/badge/Kubernetes%20support-1.26%7C1.27%7C1.28%7C1.29-blue +.. image:: https://img.shields.io/badge/Kubernetes%20support-1.28%7C1.29%7C1.30-blue :target: https://kubernetes.dask.org/en/latest/installing.html#supported-versions :alt: Kubernetes Support diff --git a/dask_kubernetes/operator/_objects.py b/dask_kubernetes/operator/_objects.py index da34a44a..d9613cda 100644 --- a/dask_kubernetes/operator/_objects.py +++ b/dask_kubernetes/operator/_objects.py @@ -2,22 +2,15 @@ from typing import List -from kr8s.asyncio.objects import APIObject, Deployment, Pod, Service +from kr8s.asyncio.objects import Deployment, Pod, Service, new_class -class DaskCluster(APIObject): - version = "kubernetes.dask.org/v1" - endpoint = "daskclusters" - kind = "DaskCluster" - plural = "daskclusters" - singular = "daskcluster" - namespaced = True +class DaskCluster(new_class("DaskCluster", "kubernetes.dask.org/v1")): scalable = True scalable_spec = "worker.replicas" async def worker_groups(self) -> List[DaskWorkerGroup]: - return await self.api.get( - DaskWorkerGroup.endpoint, + return await DaskWorkerGroup.list( label_selector=f"dask.org/cluster-name={self.name}", namespace=self.namespace, ) @@ -25,8 +18,7 @@ async def worker_groups(self) -> List[DaskWorkerGroup]: async def scheduler_pod(self) -> Pod: pods = [] while not pods: - pods = await self.api.get( - Pod.endpoint, + pods = await Pod.list( label_selector=",".join( [ f"dask.org/cluster-name={self.name}", @@ -41,8 +33,7 @@ async def scheduler_pod(self) -> Pod: async def scheduler_deployment(self) -> Deployment: deployments = [] while not deployments: - deployments = await self.api.get( - Deployment.endpoint, + deployments = await Deployment.list( label_selector=",".join( [ f"dask.org/cluster-name={self.name}", @@ -57,8 +48,7 @@ async def scheduler_deployment(self) -> Deployment: async def scheduler_service(self) -> Service: services = [] while not services: - services = await self.api.get( - Service.endpoint, + services = await Service.list( label_selector=",".join( [ f"dask.org/cluster-name={self.name}", @@ -79,19 +69,12 @@ async def ready(self) -> bool: ) -class DaskWorkerGroup(APIObject): - version = "kubernetes.dask.org/v1" - endpoint = "daskworkergroups" - kind = "DaskWorkerGroup" - plural = "daskworkergroups" - singular = "daskworkergroup" - namespaced = True +class DaskWorkerGroup(new_class("DaskWorkerGroup", "kubernetes.dask.org/v1")): scalable = True scalable_spec = "worker.replicas" async def pods(self) -> List[Pod]: - return await self.api.get( - Pod.endpoint, + return await Pod.list( label_selector=",".join( [ f"dask.org/cluster-name={self.spec.cluster}", @@ -103,8 +86,7 @@ async def pods(self) -> List[Pod]: ) async def deployments(self) -> List[Deployment]: - return await self.api.get( - Deployment.endpoint, + return await Deployment.list( label_selector=",".join( [ f"dask.org/cluster-name={self.spec.cluster}", @@ -119,34 +101,19 @@ async def cluster(self) -> DaskCluster: return await DaskCluster.get(self.spec.cluster, namespace=self.namespace) -class DaskAutoscaler(APIObject): - version = "kubernetes.dask.org/v1" - endpoint = "daskautoscalers" - kind = "DaskAutoscaler" - plural = "daskautoscalers" - singular = "daskautoscaler" - namespaced = True - +class DaskAutoscaler(new_class("DaskAutoscaler", "kubernetes.dask.org/v1")): async def cluster(self) -> DaskCluster: return await DaskCluster.get(self.spec.cluster, namespace=self.namespace) -class DaskJob(APIObject): - version = "kubernetes.dask.org/v1" - endpoint = "daskjobs" - kind = "DaskJob" - plural = "daskjobs" - singular = "daskjob" - namespaced = True - +class DaskJob(new_class("DaskJob", "kubernetes.dask.org/v1")): async def cluster(self) -> DaskCluster: return await DaskCluster.get(self.name, namespace=self.namespace) async def pod(self) -> Pod: pods = [] while not pods: - pods = await self.api.get( - Pod.endpoint, + pods = await Pod.list( label_selector=",".join( [ f"dask.org/cluster-name={self.name}", diff --git a/docs/source/index.rst b/docs/source/index.rst index de90cca2..8f749aef 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -13,7 +13,7 @@ Dask Kubernetes Operator :target: https://kubernetes.dask.org/en/latest/installing.html#supported-versions :alt: Python Support -.. image:: https://img.shields.io/badge/Kubernetes%20support-1.26%7C1.27%7C1.28%7C1.29-blue +.. image:: https://img.shields.io/badge/Kubernetes%20support-1.28%7C1.29%7C1.30-blue :target: https://kubernetes.dask.org/en/latest/installing.html#supported-versions :alt: Kubernetes Support diff --git a/pyproject.toml b/pyproject.toml index afd139e8..65bdcff4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ dependencies = [ "dask>=2022.08.1", "distributed>=2022.08.1", "kopf>=1.35.3", - "kr8s==0.14.*", + "kr8s==0.17.*", "kubernetes-asyncio>=12.0.1", "kubernetes>=12.0.1", "pykube-ng>=22.9.0",