8000 Merge pull request #1903 from shafinhasnat/master · chrisgzf/python@5385eb0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5385eb0

Browse files
authored
Merge pull request kubernetes-client#1903 from shafinhasnat/master
example added for create_from_dict
2 parents 5c2cbff + 3aa1143 commit 5385eb0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

examples/apply_from_dict.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from kubernetes import client, config, utils
2+
def main():
3+
config.load_kube_config()
4+
k8s_client = client.ApiClient()
5+
# example nginx deployment
6+
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}]}]}}}}
7+
utils.create_from_dict(k8s_client, example_dict)
8+
9+
if __name__ == '__main__':
10+
main()

0 commit comments

Comments
 (0)
0