1

I am learning dask-kubernetes on GKE.

I stumbled across an asyncio error (ERROR:asyncio:Task exception was never retrieved).

See steps below for the issue.

However, additional guidance on using deploying dask-kubernetes with a remote Kubernetes cluster is appreciated (note I used helm with good experience here but want to try the native approach as I can't scale the helm approach).

Create the cluster:

$ gcloud container clusters create --machine-type n1-standard-2 --num-nodes 2 --zone us-central1-b --cluster-version latest k8scluster

Create a new python environment:

$ conda create -n daskk8s python=3.8
$ conda activate daskk8s

Install the package:

$ conda install -c conda-forge dask-kubernetes

Authenticate the project by putting this in my .bash_profile:

$ export GOOGLE_APPLICATION_CREDENTIALS="/Users/Ray/Downloads/daskk8s-f92d8191517a.json"

Start a notebook:

$ jupyter notebook

Run commands and use the example here

from dask_kubernetes import KubeCluster, make_pod_spec

pod_spec = make_pod_spec(image='daskdev/dask:latest',
                         memory_limit='4G', memory_request='4G',
                         cpu_limit=1, cpu_request=1,
                         env={'EXTRA_PIP_PACKAGES': 'fastparquet git+https://github.com/dask/distributed'})

cluster = KubeCluster(pod_spec)

cluster.scale(1)
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-8' coro=<_wrap_awaitable() done, defined at /opt/anaconda3/envs/daskk8s/lib/python3.8/asyncio/tasks.py:677> exception=ApiException()>
Traceback (most recent call last):
  File "/opt/anaconda3/envs/daskk8s/lib/python3.8/asyncio/tasks.py", line 684, in _wrap_awaitable
    return (yield from awaitable.__await__())
  File "/opt/anaconda3/envs/daskk8s/lib/python3.8/site-packages/distributed/deploy/spec.py", line 50, in _
    await self.start()
  File "/opt/anaconda3/envs/daskk8s/lib/python3.8/site-packages/dask_kubernetes/core.py", line 78, in start
    raise e
  File "/opt/anaconda3/envs/daskk8s/lib/python3.8/site-packages/dask_kubernetes/core.py", line 68, in start
    self._pod = await self.core_api.create_namespaced_pod(
  File "/opt/anaconda3/envs/daskk8s/lib/python3.8/site-packages/kubernetes_asyncio/client/api_client.py", line 162, in __call_api
    response_data = await self.request(
  File "/opt/anaconda3/envs/daskk8s/lib/python3.8/site-packages/kubernetes_asyncio/client/rest.py", line 224, in POST
    return (await self.request("POST", url,
  File "/opt/anaconda3/envs/daskk8s/lib/python3.8/site-packages/kubernetes_asyncio/client/rest.py", line 181, in request
    raise ApiException(http_resp=r)
kubernetes_asyncio.client.rest.ApiException: (422)
Reason: Unprocessable Entity
HTTP response headers: <CIMultiDictProxy('Audit-Id': '89b614f5-2e9c-46bd-8d7d-b834e1a18f1a', 'Content-Type': 'application/json', 'Date': 'Fri, 13 Mar 2020 01:21:14 GMT', 'Content-Length': '1607')>
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Pod \"dask-Ray-ece943dc-8lj4mj\" is invalid: [metadata.generateName: Invalid value: \"dask-Ray-ece943dc-8\": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'), metadata.name: Invalid value: \"dask-Ray-ece943dc-8lj4mj\": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')]","reason":"Invalid","details":{"name":"dask-Ray-ece943dc-8lj4mj","kind":"Pod","causes":[{"reason":"FieldValueInvalid","message":"Invalid value: \"dask-Ray-ece943dc-8\": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')","field":"metadata.generateName"},{"reason":"FieldValueInvalid","message":"Invalid value: \"dask-Ray-ece943dc-8lj4mj\": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')","field":"metadata.name"}]},"code":422}
4

1 回答 1

1

为 指定一个小写名称KubeCluster

KubeCluster(pod_spec, name='ray')

于 2020-03-13T02:23:55.803 回答