本文整理汇总了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
示例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'}
)
)
示例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'}
)
)
示例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
示例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))
示例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
示例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'})
)
]
)
)
示例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'})
)
]
)
)
示例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