Search in sources :

Example 11 with DefaultKubernetesClient

use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project jointware by isdream.

the class KubernetesClient method create.

@Override
public Object create(Map<String, Object> map) {
    String prefix = null;
    if (map == null || map.get(MASTER_TYPE) == null) {
        return null;
    } else if (map.get(MASTER_TYPE).equals(PROTOCOL_HTTP)) {
        prefix = PROTOCOL_HTTP + "://";
    } else {
        return null;
    }
    Config config = new ConfigBuilder().withMasterUrl(prefix + map.get(MASTER_IP) + ":" + map.get(MASTER_PORT)).build();
    return new DefaultKubernetesClient(config);
}
Also used : Config(io.fabric8.kubernetes.client.Config) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 12 with DefaultKubernetesClient

use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.

the class DevOpsConnector method getKubernetes.

public KubernetesClient getKubernetes() {
    if (kubernetes == null) {
        Config config = new ConfigBuilder().withNamespace(namespace).build();
        kubernetes = new DefaultKubernetesClient(config);
    }
    return kubernetes;
}
Also used : Config(io.fabric8.kubernetes.client.Config) ProjectConfig(io.fabric8.devops.ProjectConfig) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 13 with DefaultKubernetesClient

use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.

the class UpdateEnviromentConfigMap method main.

public static void main(String... args) {
    try {
        KubernetesClient kube = new DefaultKubernetesClient();
        System.out.println("Using namespace " + kube.getNamespace() + " on master: " + kube.getMasterUrl());
        Map<String, String> environments = new HashMap<>();
        environments.put("Testing2", "default-testing");
        environments.put("Staging2", "default-staging");
        DevOpsConnector connector = new DevOpsConnector();
        String consoleUrl = "http://fabric8.vagrant.f8/";
        Map<String, String> annotations = new HashMap<>();
        System.out.println("Starting to create/update the environment ConfigMap with " + environments);
        connector.updateEnvironmentConfigMap(environments, kube, annotations, consoleUrl);
        System.out.println("Now trying a second time!");
        connector.updateEnvironmentConfigMap(environments, kube, annotations, consoleUrl);
        System.out.println("Worked!!!");
    } catch (Exception e) {
        System.out.println("FAILED: " + e);
        e.printStackTrace();
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) HashMap(java.util.HashMap) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 14 with DefaultKubernetesClient

use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.

the class CreateBuildConfig method main.

public static void main(String... args) {
    if (args.length < 1) {
        System.out.println("Usage nameOfBuildConfig");
        return;
    }
    try {
        KubernetesClient kube = new DefaultKubernetesClient();
        String name = args[0];
        String namespace = kube.getNamespace();
        if (Strings.isNullOrBlank(namespace)) {
            namespace = KubernetesHelper.defaultNamespace();
        }
        if (Strings.isNullOrBlank(namespace)) {
            namespace = "default";
        }
        System.out.println("Creating a BuildConfig for name: " + name + " in namespace: " + namespace);
        BuildConfig buildConfig = new BuildConfigBuilder().withNewMetadata().withName(name).withNamespace(namespace).endMetadata().withNewSpec().withNewSource().withType("Git").withNewGit().withUri("http://gogs.vagrant.f8/gogsadmin/" + name + ".git").endGit().endSource().endSpec().build();
        System.out.println("Creating BuildConfig: " + buildConfig);
        Controller controller = new Controller(kube);
        if (controller.getNamespace() == null) {
            controller.setNamespace(namespace);
        }
        controller.applyBuildConfig(buildConfig, "Generated!");
        System.out.println("Applied!: " + name);
    } catch (Exception e) {
        System.out.println("FAILED: " + e);
        e.printStackTrace();
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) BuildConfigBuilder(io.fabric8.openshift.api.model.BuildConfigBuilder)

Example 15 with DefaultKubernetesClient

use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by jboss-fuse.

the class ViewEndpoints method main.

public static void main(String... args) {
    System.out.println("Usage: [serviceId] [namespace]");
    KubernetesClient client = new DefaultKubernetesClient();
    try {
        String service = null;
        String namespace = null;
        if (args.length > 0) {
            service = args[0];
        }
        if (args.length > 1) {
            namespace = args[1];
        }
        listEndpoints(client, service, namespace);
    } catch (Exception e) {
        System.out.println("FAILED: " + e);
        e.printStackTrace();
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Aggregations

DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)101 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)77 File (java.io.File)27 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)22 FileInputStream (java.io.FileInputStream)22 HashMap (java.util.HashMap)13 Test (org.testng.annotations.Test)12 Config (io.fabric8.kubernetes.client.Config)11 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)11 BeforeClass (org.testng.annotations.BeforeClass)10 Service (io.fabric8.kubernetes.api.model.Service)8 ConfigBuilder (io.fabric8.kubernetes.client.ConfigBuilder)7 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)7 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)6 TaskAction (org.gradle.api.tasks.TaskAction)6 Pod (io.fabric8.kubernetes.api.model.Pod)5 Map (java.util.Map)5 Test (org.junit.Test)5 KubernetesModelGenerator (com.github.isdream.chameleon.container.kubernetes.KubernetesModelGenerator)4 ImmutableMap (com.google.common.collect.ImmutableMap)4