Skip to content

Instantly share code, notes, and snippets.

@bsnux
Last active March 14, 2020 00:09
Show Gist options
  • Save bsnux/cbfa14a8309e3628544c1fc66cfed8a3 to your computer and use it in GitHub Desktop.
Save bsnux/cbfa14a8309e3628544c1fc66cfed8a3 to your computer and use it in GitHub Desktop.
Listing all namespaces names in given cluster
(ns cleanup-wg.core
(:import [io.kubernetes.client.util ClientBuilder]
[io.kubernetes.client.util KubeConfig]
[io.kubernetes.client Configuration]
[io.kubernetes.client.apis CoreV1Api])
(:gen-class))
(defn -main
"List all namespaces on given Kubernetes cluster"
[& args]
(Configuration/setDefaultApiClient
(.build
(ClientBuilder/kubeconfig
(KubeConfig/loadKubeConfig
(clojure.java.io/reader "/Users/afernandez/.kube/config")))))
(def api (CoreV1Api.))
(doseq [item
(.getItems
(.listNamespace api nil nil nil nil nil nil nil nil))]
(println (.getName (.getMetadata item)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment