# Kubernetes Agent


# KubernetesAgent

class

prefect.agent.kubernetes.agent.KubernetesAgent

(agent_config_id=None, namespace=None, service_account_name=None, image_pull_secrets=None, job_template_path=None, name=None, labels=None, env_vars=None, max_polls=None, agent_address=None, no_cloud_logs=None, volume_mounts=None, volumes=None, delete_finished_jobs=True)[source]

Agent which deploys flow runs as Kubernetes jobs. Currently this is required to either run on a k8s cluster or on a local machine where the kube_config is pointing at the desired cluster.

Args:

  • agent_config_id (str, optional): An optional agent configuration ID that can be used to set configuration based on an agent from a backend API. If set all configuration values will be pulled from backend agent configuration.
  • namespace (str, optional): A Kubernetes namespace to create jobs in. Defaults to the environment variable NAMESPACE or default.
  • service_account_name (str, optional): A kubernetes service account name to use by default for created jobs. May be overridden per-flow by specifying on a flow's KubernetesRun run config.
  • image_pull_secrets (list, optional): A list of image pull secrets to use by default for created jobs. May be overridden per-flow by specifying on a flow's KubernetesRun run config.
  • job_template_path (str, optional): A path to a job template file to use instead of the default.
  • name (str, optional): An optional name to give this agent. Can also be set through the environment variable PREFECT__CLOUD__AGENT__NAME. Defaults to "agent"
  • labels (List[str], optional): a list of labels, which are arbitrary string identifiers used by Prefect Agents when polling for work
  • env_vars (dict, optional): a dictionary of environment variables and values that will be set on each flow run that this agent submits for execution and in the agent's own environment
  • max_polls (int, optional): maximum number of times the agent will poll Prefect Cloud for flow runs; defaults to infinite
  • agent_address (str, optional): Address to serve internal API at. Currently this is just health checks for use by an orchestration layer. Leave blank for no API server (default).
  • no_cloud_logs (bool, optional): Disable logging to a Prefect backend for this agent and all deployed flow runs
  • volume_mounts (list, optional): A list of volumeMounts to mount when a job is run. The volumeMounts in the list should be specified as dicts i.e [{"name": "my-vol", "mountPath": "/mnt/my-mount"}]
  • volumes (list, optional): A list of volumes to make available to be mounted when a job is run. The volumes in the list should be specified as nested dicts. i.e [{"name": "my-vol", "csi": {"driver": "secrets-store.csi.k8s.io"}}]
  • delete_finished_jobs (bool, optional): A boolean to toggle if finished Prefect jobs in the agent's namespace should be deleted. Defaults to the environment variable DELETE_FINISHED_JOBS or True.

methods:                                                                                                                                                       

prefect.agent.agent.Agent.start

()[source]

The main entrypoint to the agent process. Sets up the agent then continuously polls for work to submit.

This is the only method that should need to be called externally.



This documentation was auto-generated from commit n/a
on February 23, 2022 at 19:26 UTC