本文整理汇总了Python中kubernetes.client.V1PersistentVolumeClaimVolumeSource方法的典型用法代码示例。如果您正苦于以下问题:Python client.V1PersistentVolumeClaimVolumeSource方法的具体用法?Python client.V1PersistentVolumeClaimVolumeSource怎么用?Python client.V1PersistentVolumeClaimVolumeSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kubernetes.client
的用法示例。
在下文中一共展示了client.V1PersistentVolumeClaimVolumeSource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mount_pvc
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1PersistentVolumeClaimVolumeSource [as 别名]
def mount_pvc(pvc_name='pipeline-claim', volume_name='pipeline', volume_mount_path='/mnt/pipeline'):
"""
Modifier function to apply to a Container Op to simplify volume, volume mount addition and
enable better reuse of volumes, volume claims across container ops.
Usage:
train = train_op(...)
train.apply(mount_pvc('claim-name', 'pipeline', '/mnt/pipeline'))
"""
def _mount_pvc(task):
from kubernetes import client as k8s_client
# there can be other ops in a pipeline (e.g. ResourceOp, VolumeOp)
# refer to #3906
if not hasattr(task, "add_volume") or not hasattr(task, "add_volume_mount"):
return task
local_pvc = k8s_client.V1PersistentVolumeClaimVolumeSource(claim_name=pvc_name)
return (
task
.add_volume(
k8s_client.V1Volume(name=volume_name, persistent_volume_claim=local_pvc)
)
.add_volume_mount(
k8s_client.V1VolumeMount(mount_path=volume_mount_path, name=volume_name)
)
)
return _mount_pvc
示例2: create_job_object
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1PersistentVolumeClaimVolumeSource [as 别名]
def create_job_object(runner_image, region, s3_path, pvc_name):
target_folder = get_target_folder(s3_path)
# Configureate Pod template container
container = k8s_client.V1Container(
name="copy-dataset-worker",
image=runner_image,
command=["aws"],
args=["s3", "sync", s3_path, "/mnt/" + target_folder],
volume_mounts=[k8s_client.V1VolumeMount(name="data-storage", mount_path='/mnt')],
env=[k8s_client.V1EnvVar(name="AWS_REGION", value=region),
k8s_client.V1EnvVar(name="AWS_ACCESS_KEY_ID", value_from=k8s_client.V1EnvVarSource(secret_key_ref=k8s_client.V1SecretKeySelector(key="AWS_ACCESS_KEY_ID", name="aws-secret"))),
k8s_client.V1EnvVar(name="AWS_SECRET_ACCESS_KEY", value_from=k8s_client.V1EnvVarSource(secret_key_ref=k8s_client.V1SecretKeySelector(key="AWS_SECRET_ACCESS_KEY", name="aws-secret")))
],
)
volume = k8s_client.V1Volume(
name='data-storage',
persistent_volume_claim=k8s_client.V1PersistentVolumeClaimVolumeSource(claim_name=pvc_name)
)
# Create and configurate a spec section
template = k8s_client.V1PodTemplateSpec(
# metadata=k8s_client.V1ObjectMeta(labels={"app":"copy-dataset-worker"}),
spec=k8s_client.V1PodSpec(containers=[container], volumes=[volume], restart_policy="OnFailure"))
# Create the specification of deployment
spec = k8s_client.V1JobSpec(
# selector=k8s_client.V1LabelSelector(match_labels={"app":"copy-dataset-worker"}),
template=template)
# Instantiate the deployment object
deployment = k8s_client.V1Job(
api_version="batch/v1",
kind="Job",
metadata=k8s_client.V1ObjectMeta(name=container.name),
spec=spec)
return deployment
示例3: onnx_pipeline
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1PersistentVolumeClaimVolumeSource [as 别名]
def onnx_pipeline(
model,
output_onnx_path,
model_type,
output_perf_result_path,
execution_providers="",
model_inputs_names="",
model_outputs_names="",
model_input_shapes="",
model_initial_types="",
caffe_model_prototxt="",
target_opset=7):
# Create a component named "Convert To ONNX" and "ONNX Runtime Perf". Edit the V1PersistentVolumeClaimVolumeSource
# name to match the persistent volume claim you created if needed. By default the names match ../azure-files-sc.yaml
# and ../azure-files-pvc.yaml
convert_op = onnxConverterOp('Convert To ONNX',
'%s' % model,
'%s' % output_onnx_path,
'%s' % model_type,
'%s' % model_inputs_names,
'%s' % model_outputs_names,
'%s' % model_input_shapes,
'%s' % model_initial_types,
'%s' % caffe_model_prototxt,
'%s' % target_opset).add_volume(
k8s_client.V1Volume(name='pipeline-nfs', persistent_volume_claim=k8s_client.V1PersistentVolumeClaimVolumeSource(
claim_name='azurefile'))).add_volume_mount(k8s_client.V1VolumeMount(mount_path='/mnt', name='pipeline-nfs'))
perf_op = perfTestOp('ONNX Runtime Perf',
convert_op.output,
'%s' % output_perf_result_path,
'%s' % execution_providers,
).add_volume(
k8s_client.V1Volume(name='pipeline-nfs', persistent_volume_claim=k8s_client.V1PersistentVolumeClaimVolumeSource(
claim_name='azurefile'))).add_volume_mount(
k8s_client.V1VolumeMount(mount_path='/mnt', name='pipeline-nfs')).set_gpu_limit(1)
dsl.get_pipeline_conf().set_image_pull_secrets([k8s_client.V1ObjectReference(name="regcred")])
示例4: get_info
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1PersistentVolumeClaimVolumeSource [as 别名]
def get_info(self):
from kubernetes import client as k8sclient
return k8sclient.V1PersistentVolumeClaimVolumeSource(
claim_name=self.params.pvc_name
)