class_docstr: ClusterResolver for Kubernetes.
  
  This is an implementation of cluster resolvers for Kubernetes. When given the
  the Kubernetes namespace and label selector for pods, we will retrieve the
  pod IP addresses of all running pods matching the selector, and return a
  ClusterSpec based on that information.
  
  Note: it cannot retrieve `task_type`, `task_id` or `rpc_layer`. To use it
  with some distribution strategies like
  `tf.distribute.experimental.MultiWorkerMirroredStrategy`, you will need to
  specify `task_type` and `task_id` by setting these attributes.
  
  Usage example with tf.distribute.Strategy:
  
    ```Python
    # On worker 0
    cluster_resolver = KubernetesClusterResolver(
        {"worker": ["job-name=worker-cluster-a", "job-name=worker-cluster-b"]})
    cluster_resolver.task_type = "worker"
    cluster_resolver.task_id = 0
    strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy(
        cluster_resolver=cluster_resolver)
  
    # On worker 1
    cluster_resolver = KubernetesClusterResolver(
        {"worker": ["job-name=worker-cluster-a", "job-name=worker-cluster-b"]})
    cluster_resolver.task_type = "worker"
    cluster_resolver.task_id = 1
    strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy(
        cluster_resolver=cluster_resolver)
    ```
docstr: Returns the master address to use when creating a session.
  
  You must have set the task_type and task_id object properties before
  calling this function, or pass in the `task_type` and `task_id`
  parameters when using this function. If you do both, the function parameters
  will override the object properties.
  
  Note: this is only useful for TensorFlow 1.x.
  
  Args:
    task_type: (Optional) The type of the TensorFlow task of the master.
    task_id: (Optional) The index of the TensorFlow task of the master.
    rpc_layer: (Optional) The RPC protocol for the given cluster.
  
  Returns:
    The name or URL of the session master.
code: def master(self, task_type=None, task_id=None, rpc_layer=None):
      """Returns the master address to use when creating a session.
  
      You must have set the task_type and task_id object properties before
      calling this function, or pass in the `task_type` and `task_id`
      parameters when using this function. If you do both, the function parameters
      will override the object properties.
  
      Note: this is only useful for TensorFlow 1.x.
  
      Args:
        task_type: (Optional) The type of the TensorFlow task of the master.
        task_id: (Optional) The index of the TensorFlow task of the master.
        rpc_layer: (Optional) The RPC protocol for the given cluster.
  
      Returns:
        The name or URL of the session master.
      """
      task_type = task_type if task_type is not None else self.task_type
      task_id = task_id if task_id is not None else self.task_id
  
      if task_type is not None and task_id is not None:
          return format_master_url(
              self.cluster_spec().task_address(task_type, task_id),
              rpc_layer or self.rpc_layer,
          )
  
      return ""
  
file_path: tensorflow-upstream/tensorflow/python/distribute/cluster_resolver/kubernetes_cluster_resolver.py
imports: from tensorflow.python.distribute.cluster_resolver.cluster_resolver import ClusterResolver
  from tensorflow.python.distribute.cluster_resolver.cluster_resolver import format_master_url
  from tensorflow.python.training import server_lib
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 2 for calling the KubernetesClusterResolver obj's underlying member method code with example usage: obj.master(task_type, task_id, rpc_layer) and returns: str, format_master_url