# Kubernetes Tasks


Tasks for interacting with various Kubernetes API objects.

Note that depending on how you choose to authenticate, tasks in this collection might require a Prefect Secret called "KUBERNETES_API_KEY" that stores your Kubernetes API Key; this Secret must be a string and in BearerToken format.

# CreateNamespacedDeployment

class

prefect.tasks.kubernetes.deployment.CreateNamespacedDeployment

(body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for creating a namespaced deployment on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • body (dict, optional): A dictionary representation of a Kubernetes ExtensionsV1beta1Deployment specification
  • namespace (str, optional): The Kubernetes namespace to create this deployment in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.deployment.CreateNamespacedDeployment.run

(body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • body (dict, optional): A dictionary representation of a Kubernetes ExtensionsV1beta1Deployment specification
  • namespace (str, optional): The Kubernetes namespace to create this deployment in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None



# DeleteNamespacedDeployment

class

prefect.tasks.kubernetes.deployment.DeleteNamespacedDeployment

(deployment_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for deleting a namespaced deployment on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • deployment_name (str, optional): The name of a deployment to delete
  • namespace (str, optional): The Kubernetes namespace to delete this deployment from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.deployment.DeleteNamespacedDeployment.run

(deployment_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", delete_option_kwargs=None)[source]

Task run method.

Args:

  • deployment_name (str, optional): The name of a deployment to delete
  • namespace (str, optional): The Kubernetes namespace to delete this deployment in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • delete_option_kwargs (dict, optional): Optional keyword arguments to pass to the V1DeleteOptions object (e.g. {"propagation_policy": "...", "grace_period_seconds": "..."}.
Raises:
  • ValueError: if deployment_name is None



# ListNamespacedDeployment

class

prefect.tasks.kubernetes.deployment.ListNamespacedDeployment

(namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for listing namespaced deployments on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • namespace (str, optional): The Kubernetes namespace to list deployments from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"field_selector": "...", "label_selector": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.deployment.ListNamespacedDeployment.run

(namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • namespace (str, optional): The Kubernetes namespace to list deployments from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"field_selector": "...", "label_selector": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Returns:
  • ExtensionsV1beta1DeploymentList: a Kubernetes ExtensionsV1beta1DeploymentList of the deployments which are found



# PatchNamespacedDeployment

class

prefect.tasks.kubernetes.deployment.PatchNamespacedDeployment

(deployment_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for patching a namespaced deployment on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • deployment_name (str, optional): The name of a deployment to patch
  • body (dict, optional): A dictionary representation of a Kubernetes ExtensionsV1beta1Deployment patch specification
  • namespace (str, optional): The Kubernetes namespace to patch this deployment in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.deployment.PatchNamespacedDeployment.run

(deployment_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • deployment_name (str, optional): The name of a deployment to patch
  • body (dict, optional): A dictionary representation of a Kubernetes ExtensionsV1beta1Deployment patch specification
  • namespace (str, optional): The Kubernetes namespace to patch this deployment in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None
  • ValueError: if deployment_name is None



# ReadNamespacedDeployment

class

prefect.tasks.kubernetes.deployment.ReadNamespacedDeployment

(deployment_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for reading a namespaced deployment on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • deployment_name (str, optional): The name of a deployment to read
  • namespace (str, optional): The Kubernetes namespace to read this deployment from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "exact": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.deployment.ReadNamespacedDeployment.run

(deployment_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • deployment_name (str, optional): The name of a deployment to read
  • namespace (str, optional): The Kubernetes namespace to read this deployment in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "exact": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Returns:
  • ExtensionsV1beta1Deployment: a Kubernetes ExtensionsV1beta1Deployment matching the deployment that was found
Raises:
  • ValueError: if deployment_name is None



# ReplaceNamespacedDeployment

class

prefect.tasks.kubernetes.deployment.ReplaceNamespacedDeployment

(deployment_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for replacing a namespaced deployment on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • deployment_name (str, optional): The name of a deployment to replace
  • body (dict, optional): A dictionary representation of a Kubernetes ExtensionsV1beta1Deployment specification
  • namespace (str, optional): The Kubernetes namespace to patch this deployment in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.deployment.ReplaceNamespacedDeployment.run

(deployment_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • deployment_name (str, optional): The name of a deployment to replace
  • body (dict, optional): A dictionary representation of a Kubernetes ExtensionsV1beta1Deployment specification
  • namespace (str, optional): The Kubernetes namespace to patch this deployment in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None
  • ValueError: if deployment_name is None



# CreateNamespacedJob

class

prefect.tasks.kubernetes.job.CreateNamespacedJob

(body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for creating a namespaced job on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • body (dict, optional): A dictionary representation of a Kubernetes V1Job specification
  • namespace (str, optional): The Kubernetes namespace to create this job in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.job.CreateNamespacedJob.run

(body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • body (dict, optional): A dictionary representation of a Kubernetes V1Job specification
  • namespace (str, optional): The Kubernetes namespace to create this job in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None



# DeleteNamespacedJob

class

prefect.tasks.kubernetes.job.DeleteNamespacedJob

(job_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for deleting a namespaced job on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • job_name (str, optional): The name of a job to delete
  • namespace (str, optional): The Kubernetes namespace to delete this job from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.job.DeleteNamespacedJob.run

(job_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", delete_option_kwargs=None)[source]

Task run method.

Args:

  • job_name (str, optional): The name of a job to delete
  • namespace (str, optional): The Kubernetes namespace to delete this job in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • delete_option_kwargs (dict, optional): Optional keyword arguments to pass to the V1DeleteOptions object (e.g. {"propagation_policy": "...", "grace_period_seconds": "..."}.
Raises:
  • ValueError: if job_name is None



# ListNamespacedJob

class

prefect.tasks.kubernetes.job.ListNamespacedJob

(namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for listing namespaced jobs on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • namespace (str, optional): The Kubernetes namespace to list jobs from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"field_selector": "...", "label_selector": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.job.ListNamespacedJob.run

(namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • namespace (str, optional): The Kubernetes namespace to list jobs from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"field_selector": "...", "label_selector": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Returns:
  • V1JobList: a Kubernetes V1JobList of the jobs which are found



# PatchNamespacedJob

class

prefect.tasks.kubernetes.job.PatchNamespacedJob

(job_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for patching a namespaced job on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • job_name (str, optional): The name of a job to patch
  • body (dict, optional): A dictionary representation of a Kubernetes V1Job patch specification
  • namespace (str, optional): The Kubernetes namespace to patch this job in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.job.PatchNamespacedJob.run

(job_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • job_name (str, optional): The name of a job to patch
  • body (dict, optional): A dictionary representation of a Kubernetes V1Job patch specification
  • namespace (str, optional): The Kubernetes namespace to patch this job in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None
  • ValueError: if job_name is None



# ReadNamespacedJob

class

prefect.tasks.kubernetes.job.ReadNamespacedJob

(job_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for reading a namespaced job on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • job_name (str, optional): The name of a job to read
  • namespace (str, optional): The Kubernetes namespace to read this job from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "exact": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.job.ReadNamespacedJob.run

(job_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • job_name (str, optional): The name of a job to read
  • namespace (str, optional): The Kubernetes namespace to read this job in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "exact": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Returns:
  • V1Job: a Kubernetes V1Job matching the job that was found
Raises:
  • ValueError: if job_name is None



# ReplaceNamespacedJob

class

prefect.tasks.kubernetes.job.ReplaceNamespacedJob

(job_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for replacing a namespaced job on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • job_name (str, optional): The name of a job to replace
  • body (dict, optional): A dictionary representation of a Kubernetes V1Job specification
  • namespace (str, optional): The Kubernetes namespace to patch this job in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.job.ReplaceNamespacedJob.run

(job_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • job_name (str, optional): The name of a job to replace
  • body (dict, optional): A dictionary representation of a Kubernetes V1Job specification
  • namespace (str, optional): The Kubernetes namespace to patch this job in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None
  • ValueError: if job_name is None



# RunNamespacedJob

class

prefect.tasks.kubernetes.job.RunNamespacedJob

(body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", job_status_poll_interval=5, log_level=None, delete_job_after_completion=True, **kwargs)[source]

Task for running a namespaced job on Kubernetes. This task first creates a job on a Kubernetes cluster according to the specification given in the body, and then by default regularly checks its status at 5-second intervals. After the job is successfully completed, all resources by default are deleted: job and the corresponding pods. If job is in the failed status, resources will not be removed from the cluster so that user can check the logs on the cluster.

Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • body (dict, optional): A dictionary representation of a Kubernetes V1Job specification
  • namespace (str, optional): The Kubernetes namespace to create this job in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • job_status_poll_interval (int, optional): The interval given in seconds indicating how often the Kubernetes API will be requested about the status of the job being performed, defaults to the 5 seconds
  • log_level (str, optional): Log level used when outputting logs from the job should be one of debug, info, warn, error, 'critical' or None to disable output completely. Defaults to None.
  • delete_job_after_completion (bool, optional): boolean value determining whether resources related to a given job will be removed from the Kubernetes cluster after completion, defaults to the True value
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.job.RunNamespacedJob.run

(body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", job_status_poll_interval=5, log_level=None, delete_job_after_completion=True)[source]

Task run method.

Args:

  • body (dict, optional): A dictionary representation of a Kubernetes V1Job specification
  • namespace (str, optional): The Kubernetes namespace to create this job in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • job_status_poll_interval (int, optional): The interval given in seconds indicating how often the Kubernetes API will be requested about the status of the job being performed, defaults to the 5 seconds.
  • log_level (str, optional): Log level used when outputting logs from the job should be one of debug, info, warn, error, 'critical' or None to disable output completely. Defaults to None.
  • delete_job_after_completion (bool, optional): boolean value determining whether resources related to a given job will be removed from the Kubernetes cluster after completion, defaults to the True value
Raises:
  • ValueError: if body is None
  • ValueError: if body["metadata"]["name"] isNone`



# ConnectGetNamespacedPodExec

class

prefect.tasks.kubernetes.pod.ConnectGetNamespacedPodExec

(pod_name=None, container_name=None, exec_command=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for running a command in a namespaced pod on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime. This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • pod_name (str, optional): The name of a pod in which the command is to be run
  • container_name (str, optional): The name of a container to use in the pod
  • exec_command (list, optional): the command to run in pod_name
  • namespace (str, optional): The Kubernetes namespace of the pod, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "exact": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.pod.ConnectGetNamespacedPodExec.run

(pod_name=None, container_name=None, exec_command=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • pod_name (str, optional): The name of a pod in which the command is to be run
  • container_name (str, optional): The name of a container to use in the pod
  • exec_command (list, optional): the command to run in pod_name
  • namespace (str, optional): The Kubernetes namespace of the pod, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "exact": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Returns:
  • api_response: If the method is called asynchronously, returns the request thread
Raises:
  • ValueError: if pod_name is None or container_name is None
  • TypeError: exec_command is not a list



# CreateNamespacedPod

class

prefect.tasks.kubernetes.pod.CreateNamespacedPod

(body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for creating a namespaced pod on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • body (dict, optional): A dictionary representation of a Kubernetes V1Pod specification
  • namespace (str, optional): The Kubernetes namespace to create this pod in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.pod.CreateNamespacedPod.run

(body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • body (dict, optional): A dictionary representation of a Kubernetes V1Pod specification
  • namespace (str, optional): The Kubernetes namespace to create this pod in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None



# DeleteNamespacedPod

class

prefect.tasks.kubernetes.pod.DeleteNamespacedPod

(pod_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for deleting a namespaced pod on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • pod_name (str, optional): The name of a pod to delete
  • namespace (str, optional): The Kubernetes namespace to delete this pod from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.pod.DeleteNamespacedPod.run

(pod_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", delete_option_kwargs=None)[source]

Task run method.

Args:

  • pod_name (str, optional): The name of a pod to delete
  • namespace (str, optional): The Kubernetes namespace to delete this pod in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • delete_option_kwargs (dict, optional): Optional keyword arguments to pass to the V1DeleteOptions object (e.g. {"propagation_policy": "...", "grace_period_seconds": "..."}.
Raises:
  • ValueError: if pod_name is None



# ListNamespacedPod

class

prefect.tasks.kubernetes.pod.ListNamespacedPod

(namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for listing namespaced pods on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • namespace (str, optional): The Kubernetes namespace to list pods from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"field_selector": "...", "label_selector": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.pod.ListNamespacedPod.run

(namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • namespace (str, optional): The Kubernetes namespace to list pods from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"field_selector": "...", "label_selector": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Returns:
  • V1PodList: a Kubernetes V1PodList of the pods which are found



# PatchNamespacedPod

class

prefect.tasks.kubernetes.pod.PatchNamespacedPod

(pod_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for patching a namespaced pod on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • pod_name (str, optional): The name of a pod to patch
  • body (dict, optional): A dictionary representation of a Kubernetes V1Pod patch specification
  • namespace (str, optional): The Kubernetes namespace to patch this pod in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.pod.PatchNamespacedPod.run

(pod_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • pod_name (str, optional): The name of a pod to patch
  • body (dict, optional): A dictionary representation of a Kubernetes V1Pod patch specification
  • namespace (str, optional): The Kubernetes namespace to patch this pod in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None
  • ValueError: if pod_name is None



# ReadNamespacedPod

class

prefect.tasks.kubernetes.pod.ReadNamespacedPod

(pod_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for reading a namespaced pod on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • pod_name (str, optional): The name of a pod to read
  • namespace (str, optional): The Kubernetes namespace to read this pod from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "exact": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.pod.ReadNamespacedPod.run

(pod_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • pod_name (str, optional): The name of a pod to read
  • namespace (str, optional): The Kubernetes namespace to read this pod in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "exact": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Returns:
  • V1Pod: a Kubernetes V1Pod matching the pod that was found
Raises:
  • ValueError: if pod_name is None



# ReadNamespacedPodLogs

class

prefect.tasks.kubernetes.pod.ReadNamespacedPodLogs

(pod_name=None, namespace="default", on_log_entry=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", container=None, **kwargs)[source]

Task for reading logs from a namespaced pod on Kubernetes. Logs can be streamed by providing a on_log_entry function which then will be called for each log line. If on_log_entry = None, the task returns all logs for the pod until that point.

Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

Args:

  • pod_name (str, optional): The name of a pod to replace
  • namespace (str, optional): The Kubernetes namespace to patch this pod in, defaults to the default namespace
  • on_log_entry (Callable, optional): If provided, will stream the pod logs calling the callback for every line (and the task returns None). If not provided, the current pod logs will be returned immediately from the task.
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • container (str, optional): The name of the container to read logs from
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.pod.ReadNamespacedPodLogs.run

(pod_name=None, namespace="default", on_log_entry=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", container=None)[source]

Task run method.

Args:

  • pod_name (str, optional): The name of a pod to replace
  • namespace (str, optional): The Kubernetes namespace to patch this pod in, defaults to the default namespace
  • on_log_entry (Callable, optional): If provided, will stream the pod logs calling the callback for every line (and the task returns None). If not provided, the current pod logs will be returned immediately from the task.
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • container (str, optional): The name of the container to read logs from
Raises:
  • ValueError: if pod_name is None



# ReplaceNamespacedPod

class

prefect.tasks.kubernetes.pod.ReplaceNamespacedPod

(pod_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for replacing a namespaced pod on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • pod_name (str, optional): The name of a pod to replace
  • body (dict, optional): A dictionary representation of a Kubernetes V1Pod specification
  • namespace (str, optional): The Kubernetes namespace to patch this pod in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.pod.ReplaceNamespacedPod.run

(pod_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • pod_name (str, optional): The name of a pod to replace
  • body (dict, optional): A dictionary representation of a Kubernetes V1Pod specification
  • namespace (str, optional): The Kubernetes namespace to patch this pod in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None
  • ValueError: if pod_name is None



# CreateNamespacedService

class

prefect.tasks.kubernetes.service.CreateNamespacedService

(body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for creating a namespaced service on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Service in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • body (dict, optional): A dictionary representation of a Kubernetes V1Service specification
  • namespace (str, optional): The Kubernetes namespace to create this service in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.service.CreateNamespacedService.run

(body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • body (dict, optional): A dictionary representation of a Kubernetes V1Service specification
  • namespace (str, optional): The Kubernetes namespace to create this service in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None



# DeleteNamespacedService

class

prefect.tasks.kubernetes.service.DeleteNamespacedService

(service_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for deleting a namespaced service on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Service in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • service_name (str, optional): The name of a service to delete
  • namespace (str, optional): The Kubernetes namespace to delete this service from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.service.DeleteNamespacedService.run

(service_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", delete_option_kwargs=None)[source]

Task run method.

Args:

  • service_name (str, optional): The name of a service to delete
  • namespace (str, optional): The Kubernetes namespace to delete this service in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • delete_option_kwargs (dict, optional): Optional keyword arguments to pass to the V1DeleteOptions object (e.g. {"propagation_policy": "...", "grace_period_seconds": "..."}.
Raises:
  • ValueError: if service_name is None



# ListNamespacedService

class

prefect.tasks.kubernetes.service.ListNamespacedService

(namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for listing namespaced services on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Service in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • namespace (str, optional): The Kubernetes namespace to list services from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"field_selector": "...", "label_selector": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.service.ListNamespacedService.run

(namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • namespace (str, optional): The Kubernetes namespace to list services from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"field_selector": "...", "label_selector": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Returns:
  • V1ServiceList: a Kubernetes V1ServiceList of the services which are found



# PatchNamespacedService

class

prefect.tasks.kubernetes.service.PatchNamespacedService

(service_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for patching a namespaced service on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Service in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • service_name (str, optional): The name of a service to patch
  • body (dict, optional): A dictionary representation of a Kubernetes V1Service patch specification
  • namespace (str, optional): The Kubernetes namespace to patch this service in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.service.PatchNamespacedService.run

(service_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • service_name (str, optional): The name of a service to patch
  • body (dict, optional): A dictionary representation of a Kubernetes V1Service patch specification
  • namespace (str, optional): The Kubernetes namespace to patch this service in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None
  • ValueError: if service_name is None



# ReadNamespacedService

class

prefect.tasks.kubernetes.service.ReadNamespacedService

(service_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for reading a namespaced service on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Service in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The argument kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide kube_kwargs = {"info": "here"} at instantiation and then provide kube_kwargs = {"more": "info"} at run time which will make kube_kwargs = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • service_name (str, optional): The name of a service to read
  • namespace (str, optional): The Kubernetes namespace to read this service from, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "exact": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.service.ReadNamespacedService.run

(service_name=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • service_name (str, optional): The name of a service to read
  • namespace (str, optional): The Kubernetes namespace to read this service in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "exact": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Returns:
  • V1Service: a Kubernetes V1Service matching the service that was found
Raises:
  • ValueError: if service_name is None



# ReplaceNamespacedService

class

prefect.tasks.kubernetes.service.ReplaceNamespacedService

(service_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", **kwargs)[source]

Task for replacing a namespaced service on Kubernetes. Note that all initialization arguments can optionally be provided or overwritten at runtime.

This task will attempt to connect to a Kubernetes cluster in three steps with the first successful connection attempt becoming the mode of communication with a cluster.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Service in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

The arguments body and kube_kwargs will perform an in-place update when the task is run. This means that it is possible to provide body = {"info": "here"} at instantiation and then provide body = {"more": "info"} at run time which will make body = {"info": "here", "more": "info"}. Note: Keys present in both instantiation and runtime will be replaced with the runtime value.

Args:

  • service_name (str, optional): The name of a service to replace
  • body (dict, optional): A dictionary representation of a Kubernetes V1Service specification
  • namespace (str, optional): The Kubernetes namespace to patch this service in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.service.ReplaceNamespacedService.run

(service_name=None, body=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Task run method.

Args:

  • service_name (str, optional): The name of a service to replace
  • body (dict, optional): A dictionary representation of a Kubernetes V1Service specification
  • namespace (str, optional): The Kubernetes namespace to patch this service in, defaults to the default namespace
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if body is None
  • ValueError: if service_name is None



# KubernetesSecret

class

prefect.tasks.kubernetes.secrets.KubernetesSecret

(secret_name=None, secret_key=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY", cast=None, raise_if_missing=False, **kwargs)[source]

Task for loading a Prefect secret from a kubernetes secret.

This task will read a secret from kubernetes, returning the decoded value associated with secret_key. All initialization arguments can optionally be provided or overwritten at runtime.

Note that depending on cluster configuration, you may need to ensure you have the proper RBAC permissions to read the secret.

  1. Attempt to use a Prefect Secret that contains a Kubernetes API Key. If kubernetes_api_key_secret = None then it will attempt the next two connection methods. By default the value is KUBERNETES_API_KEY so providing None acts as an override for the remote connection. 2. Attempt in-cluster connection (will only work when running on a Pod in a cluster) 3. Attempt out-of-cluster connection using the default location for a kube config file

Args:

  • secret_name (string, optional): The name of the kubernetes secret object
  • secret_key (string, optional): The key to look for in the kubernetes data
  • namespace (str, optional): The Kubernetes namespace to read the secret from, defaults to the default namespace.
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
  • cast (Callable[[Any], Any], optional): If provided, this will be called on the secret to transform it before returning. An example use might be passing in json.loads to load values from stored JSON.
  • raise_if_missing (bool): if True, an error will be raised if the secret is not found.
  • **kwargs (dict, optional): additional keyword arguments to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.kubernetes.secrets.KubernetesSecret.run

(secret_name=None, secret_key=None, namespace="default", kube_kwargs=None, kubernetes_api_key_secret="KUBERNETES_API_KEY")[source]

Returns the value of an kubenetes secret after applying an optional cast function.

Args:

  • secret_name (string, optional): The name of the kubernetes secret object
  • secret_key (string, optional): The key to look for in the kubernetes data
  • namespace (str, optional): The Kubernetes namespace to read the secret from, defaults to the default namespace.
  • kube_kwargs (dict, optional): Optional extra keyword arguments to pass to the Kubernetes API (e.g. {"pretty": "...", "dry_run": "..."})
  • kubernetes_api_key_secret (str, optional): the name of the Prefect Secret which stored your Kubernetes API Key; this Secret must be a string and in BearerToken format
Raises:
  • ValueError: if raise_is_missing is True and the kubernetes secret was not found. The value of secret_name and secret_key are mandatory as well



This documentation was auto-generated from commit bd9182e
on July 31, 2024 at 18:02 UTC