Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save samirbehara-zz/12ac713d1dec879d1c1b542f2d6b936e to your computer and use it in GitHub Desktop.
Save samirbehara-zz/12ac713d1dec879d1c1b542f2d6b936e to your computer and use it in GitHub Desktop.
def test_to_list_pods_for_specific_namespace(k8s_client):
ret = k8s_client.list_namespaced_pod("default")
podcount = len(ret.items)
print(podcount)
assert(podcount > 0)
# Iterate through all the pods in the default namespace and list down the pod name and respective namespace
for item in ret.items:
print("%s\t%s\t" % (item.metadata.name, item.metadata.namespace))
def test_to_list_services_for_specific_namespace(k8s_client):
ret = k8s_client.list_namespaced_service("default")
svccount = len(ret.items)
print(svccount)
assert(svccount > 0)
# Iterate through all the services in the default namespace and list down the service name and respective namespace
for item in ret.items:
print("%s\t%s\t" % (item.metadata.name, item.metadata.namespace))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment