From 3aa11438e381d56989b9462cba25ee6b38d2fed8 Mon Sep 17 00:00:00 2001 From: shafinhasnat Date: Wed, 28 Sep 2022 12:33:57 +0600 Subject: [PATCH] example added for create_from_dict --- examples/apply_from_dict.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 examples/apply_from_dict.py diff --git a/examples/apply_from_dict.py b/examples/apply_from_dict.py new file mode 100644 index 000000000..9c0ac8124 --- /dev/null +++ b/examples/apply_from_dict.py @@ -0,0 +1,10 @@ +from kubernetes import client, config, utils +def main(): + config.load_kube_config() + k8s_client = client.ApiClient() + # example nginx deployment + example_dict = {'apiVersion': 'apps/v1', 'kind': 'Deployment', 'metadata': {'name': 'k8s-py-client-nginx'}, 'spec': {'selector': {'matchLabels': {'app': 'nginx'}}, 'replicas': 1, 'template': {'metadata': {'labels': {'app': 'nginx'}}, 'spec': {'containers': [{'name': 'nginx', 'image': 'nginx:1.14.2', 'ports': [{'containerPort': 80}]}]}}}} + utils.create_from_dict(k8s_client, example_dict) + +if __name__ == '__main__': + main() \ No newline at end of file