I have enabled Basic Authentication in a given cluster, but in list_cluster
, both of the username and password fields are missing. Although I can see If I use the gcloud
cli.
Please let me know how can I view the Basic Authentication credentials using google-cloud-container
library.
from google.oauth2 import service_account
from google.cloud import container_v1
credentials = service_account.Credentials.from_service_account_file(
"/tmp/.key",
scopes=["https://www.googleapis.com/auth/cloud-platform"],
)
computeAPI = container_v1.ClusterManagerClient(credentials=credentials)
clusters_list = get_clusters_list(containerAPI, event['projectId'])
for cluster in clusters_list:
print("master_auth: ", cluster.master_auth)
print("password: ", cluster.master_auth.password)
print("username: ", cluster.master_auth.username)
def get_clusters_list(containerAPI, project):
clusters_list = []
request = containerAPI.list_clusters(parent="projects/{}/locations/-".format(project))
if request != None and hasattr(request, 'clusters'):
clusters_list.extend(request.clusters)
return clusters_list
OUTPUT
master_auth: cluster_ca_certificate: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURDekNDQWZPZ0F3SUJBZ0lRTW94N01sc3hRalVEMXZwOHp6K09TekFOQmdrcWhraUc5dzBCQVFzRkFEQXYKTVMwd0t3WURWUVFERXlRd01qWmpaalk0WXkwd01URm1MVFE0TW1FdFlqWTVaaTFrTldVMU9UYzBORGd6TVRBdwpIaGNOTWpBd05USXhNVGN4TURBMFdoY05NalV3TlRJd01UZ3hNREEwV2pBdk1TMHdLd1lEVlFRREV5UXdNalpqClpqWTRZeTB3TVRGbUxUUTRNbUV0WWpZNVppMWtOV1UxT1RjME5EZ3pNVEF3Z2dFaU1BMEdDU3FHU0...."
password:
username:
P.S I am running this code on AWS Lambda.
python version: 3.7
google-cloud-container version: 0.5.0
OS: Amazon Linux
AWS AMI: amzn2-ami-hvm-2.0.20200406.0-x86_64-gp2