-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add patch_namespaced_config_map example
- Loading branch information
1 parent
f414832
commit 331848f
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
This example demonstrates how to update config map by | ||
patch_namespaced_config_map api. | ||
""" | ||
|
||
from kubernetes import client, config | ||
|
||
def main(): | ||
config.load_kube_config() | ||
v1 = client.CoreV1Api() | ||
|
||
namespace = "your-namespace" | ||
config_map_data = {"test_key": "test_value"} | ||
config_map_name = "your-config-map-name" | ||
|
||
# Use client.V1ConfigMap instead of the python dict | ||
object_meta = client.V1ObjectMeta(name=config_map_name, namespace=namespace) | ||
body = client.V1ConfigMap( | ||
api_version="v1", kind="ConfigMap", metadata=object_meta, data=config_map_data) | ||
|
||
v1.patch_namespaced_config_map(name=config_map_name, namespace=namespace, body=body) | ||
|
||
if __name__ == "__main__": | ||
main() |