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


Python client.V1PodStatus方法代碼示例

本文整理匯總了Python中kubernetes.client.V1PodStatus方法的典型用法代碼示例。如果您正苦於以下問題:Python client.V1PodStatus方法的具體用法?Python client.V1PodStatus怎麽用?Python client.V1PodStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kubernetes.client的用法示例。


在下文中一共展示了client.V1PodStatus方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_assert_kube_pods_running

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import V1PodStatus [as 別名]
def test_assert_kube_pods_running():
    with mock.patch(
        "paasta_tools.metrics.metastatus_lib.get_all_pods", autospec=True
    ) as mock_get_all_pods:
        client = Mock()
        mock_get_all_pods.return_value = [
            V1Pod(status=V1PodStatus(phase="Running")),
            V1Pod(status=V1PodStatus(phase="Pending")),
            V1Pod(status=V1PodStatus(phase="Pending")),
            V1Pod(status=V1PodStatus(phase="Failed")),
            V1Pod(status=V1PodStatus(phase="Failed")),
            V1Pod(status=V1PodStatus(phase="Failed")),
        ]
        output, ok = metastatus_lib.assert_kube_pods_running(client)
        assert re.match("Pods: running: 1 pending: 2 failed: 3", output)
        assert ok 
開發者ID:Yelp,項目名稱:paasta,代碼行數:18,代碼來源:test_metastatus_lib.py

示例2: pod3

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import V1PodStatus [as 別名]
def pod3():
    return V1Pod(
        metadata=V1ObjectMeta(name='pod3', annotations=dict()),
        status=V1PodStatus(
            phase='Pending',
            conditions=[
                V1PodCondition(status='False', type='PodScheduled', reason='Unschedulable')
            ]
        ),
        spec=V1PodSpec(
            containers=[
                V1Container(
                    name='container2',
                    resources=V1ResourceRequirements(requests={'cpu': '1.5'})
                )
            ],
            node_selector={'clusterman.com/pool': 'bar'}
        )
    ) 
開發者ID:Yelp,項目名稱:clusterman,代碼行數:21,代碼來源:kubernetes_cluster_connector_test.py

示例3: pod5

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import V1PodStatus [as 別名]
def pod5():
    return V1Pod(
        metadata=V1ObjectMeta(name='pod5', annotations=dict()),
        status=V1PodStatus(
            phase='Pending',
            conditions=None,
        ),
        spec=V1PodSpec(
            containers=[
                V1Container(
                    name='container2',
                    resources=V1ResourceRequirements(requests={'cpu': '1.5'})
                )
            ],
            node_selector={'clusterman.com/pool': 'bar'}
        )
    ) 
開發者ID:Yelp,項目名稱:clusterman,代碼行數:19,代碼來源:kubernetes_cluster_connector_test.py

示例4: test_clusterinit_update_pod_with_init_container

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import V1PodStatus [as 別名]
def test_clusterinit_update_pod_with_init_container():
    pod_passed = k8sclient.V1Pod(
        metadata=k8sclient.V1ObjectMeta(annotations={}),
        spec=k8sclient.V1PodSpec(containers=[
            k8sclient.V1Container(name="cmk")
        ]),
        status=k8sclient.V1PodStatus()).to_dict()
    cmd = "cmd"
    cmk_img = "cmk_img"
    cmk_img_pol = "policy"
    args = "argument"
    clusterinit.update_pod_with_init_container(pod_passed, cmd, cmk_img,
                                               cmk_img_pol,
                                               args)
    pods = json.loads(pod_passed["metadata"]["annotations"][
                          "pod.beta.kubernetes.io/init-containers"])
    assert len(pods) == 1
    assert pods[0]["name"] == cmd
    assert pods[0]["image"] == cmk_img
    assert pods[0]["imagePullPolicy"] == cmk_img_pol
    assert args in pods[0]["args"]

    second_cmd = "cmd2"
    second_img = cmk_img
    second_img_pol = "Always"
    second_args = ["arg1", "arg2"]
    clusterinit.update_pod_with_init_container(pod_passed, second_cmd,
                                               second_img,
                                               second_img_pol,
                                               second_args)

    pods = json.loads(pod_passed["metadata"]["annotations"][
                          "pod.beta.kubernetes.io/init-containers"])
    assert len(pods) == 2 
開發者ID:intel,項目名稱:CPU-Manager-for-Kubernetes,代碼行數:36,代碼來源:test_clusterinit.py

示例5: _mock_executor_pod

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import V1PodStatus [as 別名]
def _mock_executor_pod(self, phase):
    return client.V1Pod(status=client.V1PodStatus(phase=phase)) 
開發者ID:tensorflow,項目名稱:tfx,代碼行數:4,代碼來源:kubernetes_component_launcher_test.py

示例6: status

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import V1PodStatus [as 別名]
def status(self) -> client.V1PodStatus:
        """Get the status of the Pod.

        Returns:
            The status of the Pod.
        """
        # first, refresh the pod state to ensure latest status
        self.refresh()

        # return the status of the pod
        return self.obj.status 
開發者ID:vapor-ware,項目名稱:kubetest,代碼行數:13,代碼來源:pod.py

示例7: pod1

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import V1PodStatus [as 別名]
def pod1():
    return V1Pod(
        metadata=V1ObjectMeta(name='pod1'),
        status=V1PodStatus(phase='Running'),
        spec=V1PodSpec(containers=[
               V1Container(
                    name='container1',
                    resources=V1ResourceRequirements(requests={'cpu': '1.5'})
                )
            ]
        )
    ) 
開發者ID:Yelp,項目名稱:clusterman,代碼行數:14,代碼來源:kubernetes_cluster_connector_test.py

示例8: pod2

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import V1PodStatus [as 別名]
def pod2():
    return V1Pod(
        metadata=V1ObjectMeta(name='pod2', annotations={'clusterman.com/safe_to_evict': 'false'}),
        status=V1PodStatus(phase='Running'),
        spec=V1PodSpec(containers=[
               V1Container(
                    name='container1',
                    resources=V1ResourceRequirements(requests={'cpu': '1.5'})
                )
            ]
        )
    ) 
開發者ID:Yelp,項目名稱:clusterman,代碼行數:14,代碼來源:kubernetes_cluster_connector_test.py

示例9: test_calculate_resource_utilization_for_kube_nodes

# 需要導入模塊: from kubernetes import client [as 別名]
# 或者: from kubernetes.client import V1PodStatus [as 別名]
def test_calculate_resource_utilization_for_kube_nodes():
    fake_nodes = [
        V1Node(
            metadata=V1ObjectMeta(name="fake_node1"),
            status=V1NodeStatus(
                allocatable={
                    "cpu": "500",
                    "ephemeral-storage": "200Mi",
                    "memory": "750Mi",
                },
            ),
        )
    ]
    fake_pods_by_node = {
        "fake_node1": [
            V1Pod(
                metadata=V1ObjectMeta(name="pod1"),
                status=V1PodStatus(phase="Running"),
                spec=V1PodSpec(
                    containers=[
                        V1Container(
                            name="container1",
                            resources=V1ResourceRequirements(
                                requests={
                                    "cpu": "20",
                                    "ephemeral-storage": "20Mi",
                                    "memory": "20Mi",
                                }
                            ),
                        )
                    ]
                ),
            )
        ]
    }
    free = metastatus_lib.calculate_resource_utilization_for_kube_nodes(
        nodes=fake_nodes, pods_by_node=fake_pods_by_node
    )["free"]

    assert free.cpus == 480
    assert free.mem == 730
    assert free.disk == 180 
開發者ID:Yelp,項目名稱:paasta,代碼行數:44,代碼來源:test_metastatus_lib.py


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