Skip to content

Instantly share code, notes, and snippets.

@mbohlool
Created May 8, 2017 21:44
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 mbohlool/bde2b0dbe8352957d1ff5105cafa5049 to your computer and use it in GitHub Desktop.
Save mbohlool/bde2b0dbe8352957d1ff5105cafa5049 to your computer and use it in GitHub Desktop.

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))

ruby (speculation)

require 'kubernetes'

Kubernetes.config.load_kube_config

api_instance = Kubernetes::CoreV1Api.new

result = api_instance.list_pod_for_all_namespaces()
p result

java (speculation)

import io.kubernetes.java.Client.CoreV1Api;
import io.kubernetes.java.Config;

Config.LoadKubeConfig();

CoreV1Api apiInstance = new CoreV1Api()
V1PodList result = apiInstance.listPodForAllNamespaces();
for (V1Pod p : result) {
  System.out.println(p);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment