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


Python client.V1ObjectFieldSelector方法代碼示例

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

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


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