本文整理匯總了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