kfp.kubernetes¶
Functions:
|
Add a generic ephemeral volume. |
|
Add a constraint to the task Pod's nodeSelector. |
|
Add an annotation to the task Pod's metadata. |
|
Add a label to the task Pod's metadata. |
|
Add a `toleration<https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/>`_. |
|
Create a PersistentVolumeClaim, which can be used by downstream tasks. |
|
Delete a PersistentVolumeClaim. |
|
Mount a PersistentVolumeClaim to the task's container. |
|
Set image pull policy for the container. |
|
Use a Kubernetes Field Path as an environment variable as described in https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information |
|
Set image pull secrets for a Kubernetes task. |
|
Add timeout to the task Pod's active_deadline_seconds. |
|
Use a Kubernetes ConfigMap as an environment variable as described by the Kubernetes documentation https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data _. |
|
Use a Kubernetes ConfigMap by mounting its data to the task's container as described by the Kubernetes documentation. |
|
Use a Kubernetes Secret as an environment variable as described by the `Kubernetes documentation https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables `_. |
|
Use a Kubernetes Secret by mounting its data to the task's container as described by the Kubernetes documentation. |
-
kfp.kubernetes.add_ephemeral_volume(task: PipelineTask, volume_name: str, mount_path: str, access_modes: list[str], size: str, storage_class_name: str | None =
None
, labels: dict[str, str] | None =None
, annotations: dict[str, str] | None =None
)[source]¶ Add a generic ephemeral volume. to a task.
- Parameters¶
- task: PipelineTask¶
Pipeline task.
- volume_name: str¶
name to be given to the created ephemeral volume. Corresponds to Pod.spec.volumes[*].name
- mount_path: str¶
local path in the main container where the PVC should be mounted as a volume
- access_modes: list[str]¶
AccessModes to request for the provisioned PVC. May be one or more of
'ReadWriteOnce'
,'ReadOnlyMany'
,'ReadWriteMany'
, or``’ReadWriteOncePod’``. Corresponds to Pod.spec.volumes[*].ephemeral.volumeClaimTemplate.spec.accessModes.- size: str¶
The size of storage requested by the PVC that will be provisioned. For example,
'5Gi'
. Corresponds to Pod.spec.volumes[*].ephemeral.volumeClaimTemplate.spec.resources.requests.storage.- storage_class_name: str | None =
None
¶ Name of StorageClass from which to provision the PV to back the PVC.
None
indicates to use the cluster’s default storage_class_name.- labels: dict[str, str] | None =
None
¶ The labels to attach to the created PVC. Corresponds to `Pod.spec.volumes[*].ephemeral.volumeClaimTemplate.metadata.labels
- annotations: dict[str, str] | None =
None
¶ The annotation to attach to the created PVC. Corresponds to `Pod.spec.volumes[*].ephemeral.volumeClaimTemplate.metadata.annotations
- Returns¶
Task object with added toleration.
- kfp.kubernetes.add_node_selector(task: PipelineTask, label_key: str, label_value: str) PipelineTask [source]¶
Add a constraint to the task Pod’s nodeSelector.
Each constraint is a key-value pair, corresponding to the PodSpec’s nodeSelector field.
For the task’s Pod to be eligible to run on a node, the node’s labels must satisfy the constraint.
- kfp.kubernetes.add_pod_annotation(task: PipelineTask, annotation_key: str, annotation_value: str) PipelineTask [source]¶
Add an annotation to the task Pod’s metadata.
Each annotation is a key-value pair, corresponding to the metadata’s `ObjectMeta <https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta`_ field.
- kfp.kubernetes.add_pod_label(task: PipelineTask, label_key: str, label_value: str) PipelineTask [source]¶
Add a label to the task Pod’s metadata.
Each label is a key-value pair, corresponding to the metadata’s `ObjectMeta <https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/object-meta/#ObjectMeta`_ field.
-
kfp.kubernetes.add_toleration(task: PipelineTask, key: str | None =
None
, operator: 'Equal' | 'Exists' | None =None
, value: str | None =None
, effect: 'NoExecute' | 'NoSchedule' | 'PreferNoSchedule' | None =None
, toleration_seconds: int | None =None
)[source]¶ Add a `toleration<https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/>`_. to a task.
- Parameters¶
- task: PipelineTask¶
Pipeline task.
- key: str | None =
None
¶ key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys.
- operator: 'Equal' | 'Exists' | None =
None
¶ operator represents a key’s relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category.
- value: str | None =
None
¶ value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string.
- effect: 'NoExecute' | 'NoSchedule' | 'PreferNoSchedule' | None =
None
¶ effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
- toleration_seconds: int | None =
None
¶ toleration_seconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system.
- Returns¶
Task object with added toleration.
- kfp.kubernetes.CreatePVC(name: <kfp.dsl.types.type_annotations.OutputPath object at 0x7efdbd255df0>, access_modes: ~typing.List[str], size: str, pvc_name: ~typing.Optional[str] = None, pvc_name_suffix: ~typing.Optional[str] = None, storage_class_name: ~typing.Optional[str] = '', volume_name: ~typing.Optional[str] = None, annotations: ~typing.Optional[~typing.Dict[str, str]] = None)[source]¶
Create a PersistentVolumeClaim, which can be used by downstream tasks. See PersistentVolume and PersistentVolumeClaim documentation for more information about the component input parameters.
- Parameters¶
- access_modes
AccessModes to request for the provisioned PVC. May be one or more of
'ReadWriteOnce'
,'ReadOnlyMany'
,'ReadWriteMany'
, or'ReadWriteOncePod'
. Corresponds to PersistentVolumeClaim.spec.accessModes.- size
The size of storage requested by the PVC that will be provisioned. For example,
'5Gi'
. Corresponds to PersistentVolumeClaim.spec.resources.requests.storage.- pvc_name
Name of the PVC. Corresponds to PersistentVolumeClaim.metadata.name. Only one of
pvc_name
andpvc_name_suffix
can be provided.- pvc_name_suffix
Prefix to use for a dynamically generated name, which will take the form
<argo-workflow-name>-<pvc_name_suffix>
. Only one ofpvc_name
andpvc_name_suffix
can be provided.- storage_class_name
Name of StorageClass from which to provision the PV to back the PVC.
None
indicates to use the cluster’s default storage_class_name. Set to''
for a statically specified PVC.- volume_name
Pre-existing PersistentVolume that should back the provisioned PersistentVolumeClaim. Used for statically specified PV only. Corresponds to PersistentVolumeClaim.spec.volumeName.
- annotations
Annotations for the PVC’s metadata. Corresponds to PersistentVolumeClaim.metadata.annotations.
- Returns¶
name: str
Name of the generated PVC.
- kfp.kubernetes.mount_pvc(task: PipelineTask, pvc_name: str | PipelineChannel, mount_path: str) PipelineTask [source]¶
Mount a PersistentVolumeClaim to the task’s container.
- kfp.kubernetes.set_image_pull_policy(task: PipelineTask, policy: str) PipelineTask [source]¶
Set image pull policy for the container.
- kfp.kubernetes.use_field_path_as_env(task: PipelineTask, env_name: str, field_path: str) PipelineTask [source]¶
Use a Kubernetes Field Path as an environment variable as described in https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information
- kfp.kubernetes.set_image_pull_secrets(task: PipelineTask, secret_names: list[str]) PipelineTask [source]¶
Set image pull secrets for a Kubernetes task.
- kfp.kubernetes.set_timeout(task: PipelineTask, seconds: int) PipelineTask [source]¶
Add timeout to the task Pod’s active_deadline_seconds.
Timeout an integer greater than 0, corresponding to the podspec active_deadline_seconds <https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#podspec-v1-core`_ field. Integer 0 means removing the timeout fields from previous functions.
- kfp.kubernetes.use_config_map_as_env(task: PipelineTask, config_map_name: str, config_map_key_to_env: dict[str, str]) PipelineTask [source]¶
Use a Kubernetes ConfigMap as an environment variable as described by the Kubernetes documentation https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data _.
-
kfp.kubernetes.use_config_map_as_volume(task: PipelineTask, config_map_name: str, mount_path: str, optional: bool =
False
) PipelineTask [source]¶ Use a Kubernetes ConfigMap by mounting its data to the task’s container as described by the Kubernetes documentation.
- kfp.kubernetes.use_secret_as_env(task: PipelineTask, secret_name: str, secret_key_to_env: dict[str, str]) PipelineTask [source]¶
Use a Kubernetes Secret as an environment variable as described by the `Kubernetes documentation https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables `_.
-
kfp.kubernetes.use_secret_as_volume(task: PipelineTask, secret_name: str, mount_path: str, optional: bool =
False
) PipelineTask [source]¶ Use a Kubernetes Secret by mounting its data to the task’s container as described by the Kubernetes documentation.