Change currentContext of the F8 Kubernetes client

9 views
Skip to first unread message

cmou...@redhat.com

unread,
Mar 22, 2017, 5:10:21 AM3/22/17
to fabric8
Hi,

The F8 kubernetes client recuperates the currentContext of the $home/.kube/config file using this method

Context currentContext = KubeConfigUtils.getCurrentContext(kubeConfig);

which is declared within the class Config under "private boolean tryKubeConfig(Config config)" 

Is it possible to set this context programmatically which is equivalent to ("oc oc config set-context <context_nickname> [--cluster=<cluster_nickname>] [--user=<user_nickname>] [--namespace=<namespace>]") ? 

As I know the user & has its Oauth token

        Config config = new ConfigBuilder()
                .withUsername("admin")
                .withOauthToken("zWKpiRNfMxfk8r4GRx12kNA4PrnAQugDcUSIbYi3fGE")
                .build();

        try (final KubernetesClient client = new DefaultKubernetesClient(config)) {,

I would like to access its namespace (= default") and not what is defined within the currentContext (by example --> myproject/192-168-64-25:8443/developer) 

Regards,

Charles
Reply all
Reply to author
Forward
0 new messages