Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samirbehara-zz/2a48b1bd114800682aac0ded0a0e3632 to your computer and use it in GitHub Desktop.
Save samirbehara-zz/2a48b1bd114800682aac0ded0a0e3632 to your computer and use it in GitHub Desktop.
def test_to_list_endpoints_for_all_namespaces(k8s_client):
ret = k8s_client.list_endpoints_for_all_namespaces()
epcount = len(ret.items)
print(epcount)
assert(epcount > 0)
# Iterate through all the endpoints in the K8s cluster and list it down
for item in ret.items:
print("%s\t%s\t" % (item.metadata.name, item.metadata.namespace))
def test_to_list_services_for_all_namespaces(k8s_client):
ret = k8s_client.list_service_for_all_namespaces()
print("\n")
svccount = len(ret.items)
print(svccount)
assert(svccount > 0)
# Iterate through all the services in the K8s cluster and list down all the services and respective namespace
for item in ret.items:
print("%s\t%s\t" % (item.metadata.name, item.metadata.namespace))
def test_to_list_nodes_for_all_namespaces(k8s_client):
ret = k8s_client.list_node()
nodecount = len(ret.items)
print(nodecount)
assert(nodecount > 0)
# Iterate through all the nodes in the K8s cluster and list it down
for item in ret.items:
print("%s\t" % item.metadata.name)
def test_to_list_pods_for_all_namespaces(k8s_client):
ret = k8s_client.list_pod_for_all_namespaces()
podcount = len(ret.items)
print(podcount)
assert(podcount > 0)
# Iterate through all the pods in the K8s cluster 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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment