From 93d39039a0369578ec3f421452499c281bdadc84 Mon Sep 17 00:00:00 2001 From: itbj00 Date: Sat, 16 Jan 2021 22:55:43 +0800 Subject: [PATCH 1/6] Create demo.md --- demo.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 demo.md diff --git a/demo.md b/demo.md new file mode 100644 index 0000000000..3d54506c11 --- /dev/null +++ b/demo.md @@ -0,0 +1,2 @@ +# 2021-01-15 +$ pip install kubernetes | tee n.txt From 68ebb0045c61f840abfd8b378e93bd7a0c1a19a3 Mon Sep 17 00:00:00 2001 From: itbj00 Date: Sat, 16 Jan 2021 22:58:37 +0800 Subject: [PATCH 2/6] Update demo.md --- demo.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/demo.md b/demo.md index 3d54506c11..518edad7af 100644 --- a/demo.md +++ b/demo.md @@ -1,2 +1,35 @@ # 2021-01-15 $ pip install kubernetes | tee n.txt +## Examples + +list all pods: + +```python +from kubernetes import client, config + +# Configs can be set in Configuration class directly or using helper utility +config.load_kube_config() + +v1 = client.CoreV1Api() +print("Listing pods with their IPs:") +ret = v1.list_pod_for_all_namespaces(watch=False) +for i in ret.items: + print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name)) +``` +Result: +$ python k2.py +``` +/home/taoli/code/py3/lib/python3.8/site-packages/kubernetes/config/kube_config.py:280: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. + config_dict=yaml.load(f), +Listing pods with their IPs: +172.17.0.4 default a1 +172.17.0.6 default b3 +172.17.0.8 default hello-f45cbcf6d-dg8r6 +172.17.0.10 default hello-f45cbcf6d-hh9q2 +172.17.0.5 default hello-f45cbcf6d-t24js +172.17.0.7 default hello-f45cbcf6d-tfk7r +172.17.0.11 default nfs-deployment-799cdcf688-lftvx +172.17.0.10 default nginx-deployment-66b6c48dd5-9625m +172.17.0.8 default nginx-deployment-66b6c48dd5-gwpjl +172.17.0.9 default nginx-deployment-66b6c48dd5-m9fsf +``` From 726ac2d4786bcfac54a25ce3d2514eea3816c420 Mon Sep 17 00:00:00 2001 From: itbj00 Date: Sat, 16 Jan 2021 23:27:33 +0800 Subject: [PATCH 3/6] Update README.md --- examples/notebooks/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/notebooks/README.md b/examples/notebooks/README.md index 324a6b0c70..6df948e597 100644 --- a/examples/notebooks/README.md +++ b/examples/notebooks/README.md @@ -17,3 +17,14 @@ If you are using minikube, you can run this command to see jupyter service in yo minikube service jupyter ``` +## 注释 + +https://github.com/itbj/python/blob/master/examples/notebooks/create_pod.ipynb +``` +config.load_incluster_config() #should be changed to new command. otherwise error to run. +``` + +#Configs can be set in Configuration class directly or using helper utility +``` +config.load_kube_config() +``` From 9f28b11fcffdfe5574b77c3cacecf3c54447794b Mon Sep 17 00:00:00 2001 From: itbj00 Date: Sat, 16 Jan 2021 23:28:52 +0800 Subject: [PATCH 4/6] Update create_pod.ipynb --- examples/notebooks/create_pod.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/notebooks/create_pod.ipynb b/examples/notebooks/create_pod.ipynb index ac863ca534..e1b8ab0445 100644 --- a/examples/notebooks/create_pod.ipynb +++ b/examples/notebooks/create_pod.ipynb @@ -49,7 +49,7 @@ }, "outputs": [], "source": [ - "config.load_incluster_config()" + "#config.load_incluster_config()" ] }, { From 8c1d7f92a88b0a8514d025eaaaed27364384bcc4 Mon Sep 17 00:00:00 2001 From: itbj00 Date: Sat, 16 Jan 2021 23:39:43 +0800 Subject: [PATCH 5/6] 2021-01-16 --- demo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo.md b/demo.md index 518edad7af..255dacf460 100644 --- a/demo.md +++ b/demo.md @@ -1,4 +1,4 @@ -# 2021-01-15 +# 2021-01-16 $ pip install kubernetes | tee n.txt ## Examples From bcce211e39cb664948d1088d4d7b1e3a029d73ad Mon Sep 17 00:00:00 2001 From: itbj00 Date: Sat, 16 Jan 2021 23:40:53 +0800 Subject: [PATCH 6/6] Update demo.md --- demo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo.md b/demo.md index 255dacf460..ac46cc90b6 100644 --- a/demo.md +++ b/demo.md @@ -19,7 +19,7 @@ for i in ret.items: Result: $ python k2.py ``` -/home/taoli/code/py3/lib/python3.8/site-packages/kubernetes/config/kube_config.py:280: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. +/home/tl/code/py3/lib/python3.8/site-packages/kubernetes/config/kube_config.py:280: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details. config_dict=yaml.load(f), Listing pods with their IPs: 172.17.0.4 default a1