當前位置: 首頁>>代碼示例>>Python>>正文


Python client.V1HostPathVolumeSource方法代碼示例

本文整理匯總了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 
開發者ID:Yelp,項目名稱:paasta,代碼行數:37,代碼來源:kubernetes_tools.py

示例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
        ) 
開發者ID:Yelp,項目名稱:paasta,代碼行數:36,代碼來源:test_kubernetes_tools.py

示例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)
    ) 
開發者ID:anibali,項目名稱:margipose,代碼行數:7,代碼來源:deploy.py

示例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)) 
開發者ID:kubeflow,項目名稱:pipelines,代碼行數:39,代碼來源:pipeline.py


注:本文中的kubernetes.client.V1HostPathVolumeSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。