本文整理汇总了Python中kubernetes.client.V1ObjectFieldSelector方法的典型用法代码示例。如果您正苦于以下问题:Python client.V1ObjectFieldSelector方法的具体用法?Python client.V1ObjectFieldSelector怎么用?Python client.V1ObjectFieldSelector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kubernetes.client
的用法示例。
在下文中一共展示了client.V1ObjectFieldSelector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_kubernetes_environment
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1ObjectFieldSelector [as 别名]
def get_kubernetes_environment(self) -> Sequence[V1EnvVar]:
kubernetes_env = [
V1EnvVar(
name="PAASTA_POD_IP",
value_from=V1EnvVarSource(
field_ref=V1ObjectFieldSelector(field_path="status.podIP")
),
),
V1EnvVar(
# this is used by some functions of operator-sdk
# it uses this environment variable to get the pods
name="POD_NAME",
value_from=V1EnvVarSource(
field_ref=V1ObjectFieldSelector(field_path="metadata.name")
),
),
V1EnvVar(
name="PAASTA_HOST",
value_from=V1EnvVarSource(
field_ref=V1ObjectFieldSelector(field_path="spec.nodeName")
),
),
]
return kubernetes_env
示例2: add_pod_env
# 需要导入模块: from kubernetes import client [as 别名]
# 或者: from kubernetes.client import V1ObjectFieldSelector [as 别名]
def add_pod_env(op: BaseOp) -> BaseOp:
"""Adds pod environment info to ContainerOp.
"""
if isinstance(op, ContainerOp) and op.pod_labels and 'add-pod-env' in op.pod_labels and op.pod_labels['add-pod-env'] == 'true':
from kubernetes import client as k8s_client
op.container.add_env_variable(
k8s_client.V1EnvVar(
name='KFP_POD_NAME',
value_from=k8s_client.V1EnvVarSource(
field_ref=k8s_client.V1ObjectFieldSelector(
field_path='metadata.name'
)
)
)
).add_env_variable(
k8s_client.V1EnvVar(
name='KFP_NAMESPACE',
value_from=k8s_client.V1EnvVarSource(
field_ref=k8s_client.V1ObjectFieldSelector(
field_path='metadata.namespace'
)
)
)
)
return op