我一直在编写一些需要在Kubernetes中使用Python Client官方库执行的操作
一个示例是更新标签值的服务补丁:
# Code to instantiate the api object.
config.load_kube_config()
self.v1 = client.CoreV1Api()
# Code to call the patch function
def patch_namespaced_service(self, name, namespace, body, dry_run=True):
logging.debug(body)
response = self.v1.patch_namespaced_service(name, namespace, body, dry_run=dry_run)
logging.info("Service patched. status='%s'" % str(response.status))
它像一个符咒一样工作,但是dry_run
选项从未被应用,并且无论我发送了什么值,它总是执行补丁
这是源代码,其中记录了dry_run
参数:
def patch_namespaced_service(self, name, namespace, body, **kwargs): # noqa: E501
"""patch_namespaced_service # noqa: E501
partially update the specified Service # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.patch_namespaced_service(name, namespace, body, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str name: name of the Service (required)
:param str namespace: object name and auth scope, such as for teams and projects (required)
:param UNKNOWN_BASE_TYPE body: (required)
:param str pretty: If 'true', then the output is pretty printed.
:param str dry_run: 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
:param str field_manager: 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).
:param bool force: 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.
:return: V1Service
If the method is called asynchronously,
returns the request thread.
"""
我想指出这一部分:
Valid values are: - All: all dry run stages will be processed
在文档的其他部分,他们使用dry_run
作为列表:
https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1DeleteOptions.md
但是我试过{
有人知道如何使用dry_run
执行此操作吗
目前没有回答
相关问题 更多 >
编程相关推荐