title: Managing Kubernetes cluster from GCP with python api
body: <p>I would like to be able to access and manage a GKE (kubernetes) cluster from a Google Cloud function written in python.
  I managed to access and retrieve data from the created cluster (endpoint, username, and password at least), however I dont know how to use them with the kubernetes package api.</p>
  
  <p>Here are my imports :</p>
  
  <pre><code>import google.cloud.container_v1 as container
  from google.auth import compute_engine
  from google.cloud.container_v1 import ClusterManagerClient
  from kubernetes import client, config
  </code></pre>
  
  <p>Here is the code for cluster data :</p>
  
  <pre><code>project_id = 'my-gcp-project'
  zone = 'my-zone'
  cluster_id = 'my-existing-cluster'
  
  credentials = compute_engine.Credentials()
  
  gclient: ClusterManagerClient = container.ClusterManagerClient(credentials=credentials)
  
  cluster = gclient.get_cluster(project_id,zone,cluster_id)
  cluster_endpoint = cluster.endpoint
  print("*** CLUSTER ENDPOINT ***")
  print(cluster_endpoint)
  
  cluster_master_auth = cluster.master_auth
  print("*** CLUSTER MASTER USERNAME PWD ***")
  cluster_username = cluster_master_auth.username
  cluster_password = cluster_master_auth.password
  print("USERNAME : %s - PASSWORD : %s" % (cluster_username, cluster_password))
  </code></pre>
  
  <p>I would like to do something like this after that :</p>
  
  <pre><code>config.load_kube_config()
  v1 = client.CoreV1Api()
  print("Listing pods with their IPs:")
  ret = v1.list_pod_for_all_namespaces(watch=False)
  for i in ret.items:
      print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
  </code></pre>
  
  <p>However, I can't figure out how to set my endpoint and authentification informations.
  Can anyone help me please ?</p>