File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
util/src/main/java/io/kubernetes/client/util Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ public class Config {
32
32
public static final String SERVICEACCOUNT_ROOT = "/var/run/secrets/kubernetes.io/serviceaccount" ;
33
33
public static final String SERVICEACCOUNT_CA_PATH = SERVICEACCOUNT_ROOT + "/ca.crt" ;
34
34
public static final String SERVICEACCOUNT_TOKEN_PATH = SERVICEACCOUNT_ROOT + "/token" ;
35
+ public static final String SERVICEACCOUNT_NAMESPACE_PATH = SERVICEACCOUNT_ROOT + "/namespace" ;
35
36
public static final String ENV_KUBECONFIG = "KUBECONFIG" ;
36
37
public static final String ENV_SERVICE_HOST = "KUBERNETES_SERVICE_HOST" ;
37
38
public static final String ENV_SERVICE_PORT = "KUBERNETES_SERVICE_PORT" ;
Original file line number Diff line number Diff line change 12
12
*/
13
13
package io .kubernetes .client .util ;
14
14
15
+ import com .google .common .io .Files ;
16
+ import java .io .File ;
17
+ import java .io .IOException ;
18
+ import java .nio .charset .Charset ;
19
+
15
20
/** Namespaces provides a set of helpers for operating namespaces. */
16
21
public class Namespaces {
17
22
18
23
public static final String NAMESPACE_DEFAULT = "default" ;
19
24
20
25
public static final String NAMESPACE_KUBESYSTEM = "kube-system" ;
26
+
27
+ public static String getPodNamespace () throws IOException {
28
+ return Files .asCharSource (
29
+ new File (Config .SERVICEACCOUNT_NAMESPACE_PATH ), Charset .defaultCharset ())
30
+ .read ();
31
+ }
21
32
}
You can’t perform that action at this time.
0 commit comments