Closed
Description
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