Merge pull request #1903 from shafinhasnat/master
example added for create_from_dict
This commit is contained in:
commit
5385eb0123
10
examples/apply_from_dict.py
Normal file
10
examples/apply_from_dict.py
Normal file
@ -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()
|
||||
Loading…
Reference in New Issue
Block a user