我有Kubernetes集群,由AKS设置和管理,我可以通过python客户端访问它。
问题是,当我试图发送补丁规模请求时,我得到了一个错误。
我在GitHub文档中找到了关于从python客户端扩展命名空间部署的信息,但不清楚为了使请求工作所需的主体是什么:
# Enter a context with an instance of the API kubernetes.client
with kubernetes.client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = kubernetes.client.AppsV1Api(api_client)
name = 'name_example' # str | name of the Scale
namespace = 'namespace_example' # str | object name and auth scope, such as for teams and projects
body = None # object |
pretty = 'pretty_example' # str | If 'true', then the output is pretty printed. (optional)
dry_run = 'dry_run_example' # str | When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed (optional)
field_manager = 'field_manager_example' # str | fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is required for apply requests (application/apply-patch) but optional for non-apply patch types (JsonPatch, MergePatch, StrategicMergePatch). (optional)
force = True # bool | Force is going to \"force\" Apply requests. It means user will re-acquire conflicting fields owned by other people. Force flag must be unset for non-apply patch requests. (optional)
try:
api_response = api_instance.patch_namespaced_deployment_scale(name, namespace, body, pretty=pretty, dry_run=dry_run, field_manager=field_manager, force=force)
pprint(api_response)
except ApiException as e:
print("Exception when calling AppsV1Api->patch_namespaced_deployment_scale: %s\n" % e)
所以当运行代码时,我得到Reason: Unprocessable Entity
有没有人知道身体应该是什么样的?例如,如果我想将部署扩展到2个副本,该如何完成?
1条答案
按热度按时间sulc1iza1#
patch_namespaced_deployment_scale
的body
参数可以是JSONPatch文档,如@RakeshGupta在注解中所示,但它也可以是部分资源清单。例如,这起作用:(Note
value
需要是整数,而不是注解中的字符串。)但这也行得通: