Last active
March 14, 2020 00:09
-
-
Save bsnux/cbfa14a8309e3628544c1fc66cfed8a3 to your computer and use it in GitHub Desktop.
Listing all namespaces names in given cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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