Search in sources :

Example 16 with ConfigBuilder

use of io.fabric8.kubernetes.api.model.ConfigBuilder in project fabric8 by jboss-fuse.

the class PodIdToReplicationControllerIDExample method main.

public static void main(String[] args) {
    if (args.length < 3) {
        System.out.println("Arguments: kuberneteMasterUrl namespace podID");
        return;
    }
    String kuberneteMasterUrl = args[0];
    String namespace = args[1];
    String podID = args[2];
    System.out.println("Looking up ReplicationController for pod ID: " + podID);
    KubernetesClient client = new DefaultKubernetesClient(new ConfigBuilder().withMasterUrl(kuberneteMasterUrl).build());
    Pod pod = (Pod) client.pods().inNamespace(namespace).withName(podID);
    pod.getMetadata().getLabels();
    List<ReplicationController> replicationControllers = client.replicationControllers().inNamespace(namespace).withLabels(pod.getMetadata().getLabels()).list().getItems();
    if (replicationControllers.size() == 1) {
        ReplicationController replicationController = replicationControllers.get(0);
        String id = KubernetesHelper.getName(replicationController);
        System.out.println("Found replication controller: " + id);
    } else {
        System.out.println("Could not find replication controller!");
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) Pod(io.fabric8.kubernetes.api.model.Pod) ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 17 with ConfigBuilder

use of io.fabric8.kubernetes.api.model.ConfigBuilder in project jbosstools-openshift by jbosstools.

the class OdoCli method getConfig.

protected Config getConfig() {
    ConfigBuilder builder = new ConfigBuilder();
    try {
        IProxyData data = getProxyData(new URI(builder.getMasterUrl()));
        if (data != null) {
            if (data.isRequiresAuthentication()) {
                builder.withProxyUsername(data.getUserId());
                builder.withProxyPassword(data.getPassword());
            }
            builder.withHttpsProxy("http://" + data.getHost() + ':' + data.getPort());
        }
    } catch (URISyntaxException e) {
        OpenShiftUIActivator.log(IStatus.ERROR, e.getLocalizedMessage(), e);
    }
    return builder.build();
}
Also used : IProxyData(org.eclipse.core.net.proxy.IProxyData) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

ConfigBuilder (io.fabric8.kubernetes.client.ConfigBuilder)13 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)7 Config (io.fabric8.kubernetes.client.Config)5 Config (io.fabric8.docker.client.Config)3 ConfigBuilder (io.fabric8.docker.client.ConfigBuilder)3 DockerClient (io.fabric8.docker.client.DockerClient)3 ProjectConfig (io.fabric8.devops.ProjectConfig)2 AuthConfig (io.fabric8.docker.api.model.AuthConfig)2 AuthConfigBuilder (io.fabric8.docker.api.model.AuthConfigBuilder)2 DefaultDockerClient (io.fabric8.docker.client.DefaultDockerClient)2 EventListener (io.fabric8.docker.dsl.EventListener)2 OutputHandle (io.fabric8.docker.dsl.OutputHandle)2 Pod (io.fabric8.kubernetes.api.model.Pod)2 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)2 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)2 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)2 Config (io.fabric8.kubernetes.api.model.Config)1 ConfigBuilder (io.fabric8.kubernetes.api.model.ConfigBuilder)1 NamedClusterBuilder (io.fabric8.kubernetes.api.model.NamedClusterBuilder)1 NamedContextBuilder (io.fabric8.kubernetes.api.model.NamedContextBuilder)1