Skip to content

Commit 4da83df

Browse files
authored
Merge pull request #2301 from broken-dream/master
Add patch_namespaced_config_map example
2 parents f414832 + 331848f commit 4da83df

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
This example demonstrates how to update config map by
3+
patch_namespaced_config_map api.
4+
"""
5+
6+
from kubernetes import client, config
7+
8+
def main():
9+
config.load_kube_config()
10+
v1 = client.CoreV1Api()
11+
12+
namespace = "your-namespace"
13+
config_map_data = {"test_key": "test_value"}
14+
config_map_name = "your-config-map-name"
15+
16+
# Use client.V1ConfigMap instead of the python dict
17+
object_meta = client.V1ObjectMeta(name=config_map_name, namespace=namespace)
18+
body = client.V1ConfigMap(
19+
api_version="v1", kind="ConfigMap", metadata=object_meta, data=config_map_data)
20+
21+
v1.patch_namespaced_config_map(name=config_map_name, namespace=namespace, body=body)
22+
23+
if __name__ == "__main__":
24+
main()

0 commit comments

Comments
 (0)