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 _SetupModelVolumeIfNeeded(self, pod_manifest: k8s_client.V1Pod):
      mount = self._FindVolumeMountForPath(self._model_path)
      if not mount:
          return
      [volume] = [
          v
          for v in self._executor_pod.spec.volumes
          if v.name == mount.name
      ]
      if volume.persistent_volume_claim is None:
          raise NotImplementedError(
              "Only PersistentVolumeClaim is allowed."
          )
      claim_name = volume.persistent_volume_claim.claim_name
      pvc = self._k8s_core_api.read_namespaced_persistent_volume_claim(
          name=claim_name, namespace=self._namespace
      )
  
      # PersistentVolumeClaim for pipeline root SHOULD have ReadWriteMany access
      # mode. Although it is allowed to mount ReadWriteOnce volume if Pods share
      # the Node, there's no guarantee the model server Pod will be launched in
      # the same Node.
      if all(
          access_mode != _AccessMode.READ_WRITE_MANY.value
          for access_mode in pvc.spec.access_modes
      ):
          raise RuntimeError("Access mode should be ReadWriteMany.")
  
      logging.info(
          "PersistentVolumeClaim %s will be mounted to %s.",
          pvc,
          mount.mount_path,
      )
  
      pod_manifest.spec.volumes.append(
          k8s_client.V1Volume(
              name=_MODEL_SERVER_MODEL_VOLUME_NAME,
              persistent_volume_claim=k8s_client.V1PersistentVolumeClaimVolumeSource(
                  claim_name=claim_name, read_only=True
              ),
          )
      )
      container_manifest = _get_container_or_error(
          pod_manifest, container_name=_MODEL_SERVER_CONTAINER_NAME
      )
      container_manifest.volume_mounts.append(
          k8s_client.V1VolumeMount(
              name=_MODEL_SERVER_MODEL_VOLUME_NAME,
              mount_path=mount.mount_path,
              read_only=True,
          )
      )
  
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 11 for calling the KubernetesRunner obj's underlying member method code with example usage: obj._SetupModelVolumeIfNeeded(pod_manifest) without return types