本文整理汇总了Python中kubernetes.client.V1HostPathVolumeSource方法的典型用法代码示例。如果您正苦于以下问题:Python client.V1HostPathVolumeSource方法的具体用法?Python client.V1HostPathVolumeSource怎么用?Python client.V1HostPathVolumeSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kubernetes.client
的用法示例。
在下文中一共展示了client.V1HostPathVolumeSource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_pod_volumes
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1HostPathVolumeSource [as 别名]
def get_pod_volumes(
self,
docker_volumes: Sequence[DockerVolume],
aws_ebs_volumes: Sequence[AwsEbsVolume],
) -> Sequence[V1Volume]:
pod_volumes = []
unique_docker_volumes = {
self.get_docker_volume_name(docker_volume): docker_volume
for docker_volume in docker_volumes
}
for name, docker_volume in unique_docker_volumes.items():
pod_volumes.append(
V1Volume(
host_path=V1HostPathVolumeSource(path=docker_volume["hostPath"]),
name=name,
)
)
unique_aws_ebs_volumes = {
self.get_aws_ebs_volume_name(aws_ebs_volume): aws_ebs_volume
for aws_ebs_volume in aws_ebs_volumes
}
for name, aws_ebs_volume in unique_aws_ebs_volumes.items():
pod_volumes.append(
V1Volume(
aws_elastic_block_store=V1AWSElasticBlockStoreVolumeSource(
volume_id=aws_ebs_volume["volume_id"],
fs_type=aws_ebs_volume.get("fs_type"),
partition=aws_ebs_volume.get("partition"),
# k8s wants RW volume even if it's later mounted RO
read_only=False,
),
name=name,
)
)
return pod_volumes
示例2: test_get_pod_volumes
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1HostPathVolumeSource [as 别名]
def test_get_pod_volumes(self):
mock_docker_volumes = [
{"hostPath": "/nail/blah", "containerPath": "/nail/foo"},
{"hostPath": "/nail/thing", "containerPath": "/nail/bar"},
]
mock_aws_ebs_volumes = [
{
"volume_id": "vol-zzzzzzzzzzzzzzzzz",
"fs_type": "ext4",
"container_path": "/nail/qux",
}
]
expected_volumes = [
V1Volume(
host_path=V1HostPathVolumeSource(path="/nail/blah"),
name="host--slash-nailslash-blah",
),
V1Volume(
host_path=V1HostPathVolumeSource(path="/nail/thing"),
name="host--slash-nailslash-thing",
),
V1Volume(
aws_elastic_block_store=V1AWSElasticBlockStoreVolumeSource(
volume_id="vol-zzzzzzzzzzzzzzzzz", fs_type="ext4", read_only=False
),
name="aws-ebs--vol-zzzzzzzzzzzzzzzzz",
),
]
assert (
self.deployment.get_pod_volumes(
docker_volumes=mock_docker_volumes, aws_ebs_volumes=mock_aws_ebs_volumes
)
== expected_volumes
)
示例3: _host_volume
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1HostPathVolumeSource [as 别名]
def _host_volume(name, path, type):
return client.V1Volume(
name=name,
host_path=client.V1HostPathVolumeSource(path=path, type=type)
)
示例4: resnet_pipeline
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1HostPathVolumeSource [as 别名]
def resnet_pipeline(
raw_data_dir='/mnt/workspace/raw_data',
processed_data_dir='/mnt/workspace/processed_data',
model_dir='/mnt/workspace/saved_model',
epochs=50,
trtserver_name='trtis',
model_name='resnet_graphdef',
model_version=1,
webapp_prefix='webapp',
webapp_port=80
):
persistent_volume_name = 'nvidia-workspace'
persistent_volume_path = '/mnt/workspace'
op_dict = {}
op_dict['preprocess'] = PreprocessOp(
'preprocess', raw_data_dir, processed_data_dir)
op_dict['train'] = TrainOp(
'train', op_dict['preprocess'].output, model_dir, model_name, model_version, epochs)
op_dict['deploy_inference_server'] = InferenceServerLauncherOp(
'deploy_inference_server', op_dict['train'].output, trtserver_name)
op_dict['deploy_webapp'] = WebappLauncherOp(
'deploy_webapp', op_dict['deploy_inference_server'].output, model_name, model_version, webapp_prefix, webapp_port)
for _, container_op in op_dict.items():
container_op.add_volume(k8s_client.V1Volume(
host_path=k8s_client.V1HostPathVolumeSource(
path=persistent_volume_path),
name=persistent_volume_name))
container_op.add_volume_mount(k8s_client.V1VolumeMount(
mount_path=persistent_volume_path,
name=persistent_volume_name))