Skip to content

body type of patch_namespaced_config_map is not clear #2299

Closed
@broken-dream

Description

@broken-dream

Link to the issue (please include a link to the specific documentation or example):
documentation for patch_namespaced_config_map

Description of the issue (please include outputs or screenshots if possible):
I want to update config map from python client. I implemented it according the example in homepage and the doc above:

from kubernetes import client, config
config.load_kube_config("my-kube-file-path")

v1 = client.CoreV1Api()
body = {"test_key": "test_value"}
v1.patch_namespaced_config_map(name="my-config-map", namespace="my-namespace", body=body)

No error occurred but the config map is not updated, which is very confusing. When searching solution, I found another implementation in this issue. I modified my code as follow:

from kubernetes import client, config
config.load_kube_config("my-kube-file-path")

v1 = client.CoreV1Api()
data = {"test_key": "test_value"}
namespace = "my-namespace"
object_meta = client.V1ObjectMeta(name="my-config-map", namespace=namespace)
body = client.V1ConfigMap(api_version="v1", kind="ConfigMap", metadata=object_meta, data=data)
v1.patch_namespaced_config_map(name="my-config-map", namespace=namespace, body=body)

then it worked.

I'm not sure whether my original implementation is correct, but I think the documentation should be more detailed or the API should raise exception when the body type is wrong.

my environment information:

  • k8s server version: 1.26.8
  • python client version: 31.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/documentationCategorizes issue or PR as related to documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions