class_docstr: A model server runner that launches model server in kubernetes cluster.
class_docstr_tok: ["A","model","server","runner","that","launches","model","server","in","kubernetes","cluster","."]
code: def _BuildPodManifest(self) -> k8s_client.V1Pod:
      annotations = {}
      env_vars = []
      resources = None
  
      if isinstance(
          self._serving_binary, serving_bins.TensorFlowServing
      ):
          env_vars_dict = self._serving_binary.MakeEnvVars(
              model_path=self._model_path
          )
          env_vars.extend(
              k8s_client.V1EnvVar(name=key, value=value)
              for key, value in env_vars_dict.items()
          )
  
      if self._config.serving_pod_overrides:
          overrides = self._config.serving_pod_overrides
          if overrides.annotations:
              annotations.update(overrides.annotations)
          if overrides.env:
              env_vars.extend(
                  _convert_to_kube_env(env) for env in overrides.env
              )
          if overrides.resources:
              resources = _convert_to_resource_requirements(
                  overrides.resources
              )
  
      service_account_name = (
          self._config.service_account_name
          or self._executor_pod.spec.service_account_name
      )
      active_deadline_seconds = (
          self._config.active_deadline_seconds
          or _DEFAULT_ACTIVE_DEADLINE_SEC
      )
      if active_deadline_seconds < 0:
          raise ValueError(
              "active_deadline_seconds should be > 0, but got "
              f"{active_deadline_seconds}."
          )
  
      result = k8s_client.V1Pod(
          metadata=k8s_client.V1ObjectMeta(
              generate_name=_MODEL_SERVER_POD_NAME_PREFIX,
              annotations=annotations,
              labels=self._label_dict,
              # Resources with ownerReferences are automatically deleted once all
              # its owners are deleted.
              owner_references=[
                  k8s_client.V1OwnerReference(
                      api_version=self._executor_pod.api_version,
                      kind=self._executor_pod.kind,
                      name=self._executor_pod.metadata.name,
                      uid=self._executor_pod.metadata.uid,
                  ),
              ],
          ),
          spec=k8s_client.V1PodSpec(
              containers=[
                  k8s_client.V1Container(
                      name=_MODEL_SERVER_CONTAINER_NAME,
                      image=self._serving_binary.image,
                      env=env_vars,
                      resources=resources,
                      volume_mounts=[],
                  ),
              ],
              service_account_name=service_account_name,
              # No retry in case model server container failed. Retry will happen
              # at the outermost loop (executor.py).
              restart_policy=_RestartPolicy.NEVER.value,
              # This is a hard deadline for the model server container to ensure
              # the Pod is properly cleaned up even with an unexpected termination
              # of an infra validator. After the deadline, container will be
              # removed but Pod resource won't. This makes the Pod log visible
              # after the termination.
              active_deadline_seconds=active_deadline_seconds,
              volumes=[],
              # TODO(b/152002076): Add TTL controller once it graduates Beta.
              # ttl_seconds_after_finished=,
          ),
      )
  
      self._SetupModelVolumeIfNeeded(result)
  
      return result
  
imports: import datetime
  import os
  import time
  from typing import Optional
  from absl import logging
  from apache_beam.utils import retry
  from kubernetes import client
  from kubernetes.client import rest
  from tfx.components.infra_validator import error_types
  from tfx.components.infra_validator import serving_bins
  from tfx.components.infra_validator.model_server_runners import base_runner
  from tfx.proto import infra_validator_pb2
  from tfx.utils import kube_utils
label_desc: Use image node_id 9 for calling the KubernetesRunner obj's underlying member method code with example usage: obj._BuildPodManifest() and returns: result