Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mbohlool committed Nov 23, 2016
1 parent b715e99 commit cafbdf0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
7 changes: 3 additions & 4 deletions examples/example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@

import os

import k8sclient
import k8sutil
from kubernetes import client, util


def main():
# Configs can be set in Configuration class directly or using helper
# utility
k8sutil.load_kube_config(os.environ["HOME"] + '/.kube/config')
util.load_kube_config(os.environ["HOME"] + '/.kube/config')

v1 = k8sclient.CoreV1Api()
v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_pod_for_all_namespaces(watch=False)
for i in ret.items:
Expand Down
9 changes: 4 additions & 5 deletions examples/example2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@

import os

import k8sclient
import k8sutil
from kubernetes import client, util


def main():
# Configs can be set in Configuration class directly or using helper
# utility
k8sutil.load_kube_config(os.environ["HOME"] + '/.kube/config')
util.load_kube_config(os.environ["HOME"] + '/.kube/config')

v1 = k8sclient.CoreV1Api()
v1 = client.CoreV1Api()
count = 10
watch = k8sutil.Watch()
watch = util.Watch()
for event in watch.stream(v1.list_namespace, timeout_seconds=10):
print("Event: %s %s" % (event['type'], event['object'].metadata.name))
count -= 1
Expand Down
9 changes: 4 additions & 5 deletions examples/example3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@

import os

import k8sclient
import k8sutil
from kubernetes import client, util


def main():
# Configs can be set in Configuration class directly or using helper
# utility
k8sutil.load_kube_config(os.environ["HOME"] + '/.kube/config')
util.load_kube_config(os.environ["HOME"] + '/.kube/config')

print("Supported APIs (* is preferred version):")
print("%-20s %s" %
("core", ",".join(k8sclient.CoreApi().get_api_versions().versions)))
for api in k8sclient.ApisApi().get_api_versions().groups:
("core", ",".join(client.CoreApi().get_api_versions().versions)))
for api in client.ApisApi().get_api_versions().groups:
versions = []
for v in api.versions:
name = ""
Expand Down

0 comments on commit cafbdf0

Please sign in to comment.