在GCP API Explorer中为GKE尝试“container.projects.locations.clusters.get”kubernetes API时遇到“500内部服务器错误”

问题描述 投票:1回答:1

在尝试“container.projects.locations.clusters.get”GCP API Explorer Web控制台获取“500内部服务器错误”时,原因可以帮助我解决这个问题。

google-kubernetes-engine google-apis-explorer
1个回答
0
投票

我确实使用了Method: projects.locations.clusters.get,我的所有群集信息都得到了“200”响应。一个字段需要做的是“名称”字段,表达式应如下所示:

项目/您的项目ID /位置/您的群集区域/群集/您的群集名称

你也可以使用python脚本来运行同样的东西

"""
from pprint import pprint

from googleapiclient import discovery
from oauth2client.client import GoogleCredentials

credentials = GoogleCredentials.get_application_default()

service = discovery.build('container', 'v1', credentials=credentials)

# The name (project, location, cluster) of the cluster to retrieve.
# Specified in the format 'projects/*/locations/*/clusters/*'.
name = 'projects/<your project ID>/locations/<your cluster zone>/clusters/<your cluster name>'  # TODO: Update placeholder value.

request = service.projects().locations().clusters().get(name=name)
response = request.execute()

# TODO: Change code below to process the `response` dict:
pprint(response) 

确保按照以下身份安装模块进行身份验证:

sudo pip install --upgrade google-api-python-client

sudo pip install --upgrade oauth2client
© www.soinside.com 2019 - 2024. All rights reserved.