Search in sources :

Example 61 with DefaultKubernetesClient

use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by fabric8io.

the class ListSpaces method main.

public static void main(String[] args) {
    String namespace = null;
    if (args.length > 0) {
        namespace = args[0];
    }
    KubernetesClient kubernetesClient = new DefaultKubernetesClient();
    Spaces spaces = Spaces.load(kubernetesClient, namespace);
    SortedSet<Space> set = spaces.getSpaceSet();
    for (Space space : set) {
        System.out.println("Space " + space.getName() + " = " + space);
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 62 with DefaultKubernetesClient

use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by fabric8io.

the class Example method main.

public static void main(String[] args) {
    String roomName = "fabric8_default";
    if (args.length > 0) {
        roomName = args[0];
    }
    try {
        KubernetesClient kubernetes = new DefaultKubernetesClient();
        LetsChatClient letschat = LetsChatKubernetes.createLetsChat(kubernetes);
        System.out.println("Connecting to letschat on: " + letschat.getAddress());
        List<RoomDTO> rooms = letschat.getRooms();
        for (RoomDTO room : rooms) {
            System.out.println("Room " + room.getId() + " has slug: " + room.getSlug() + " name " + room.getName());
        }
        // looking up a room
        RoomDTO myRoom = letschat.getRoom(roomName);
        System.out.println("Found room: " + myRoom + " by slug: " + roomName);
        RoomDTO notExist = letschat.getRoom("does-not-exist");
        System.out.println("Found non existing room: " + notExist);
        // lets try lazily create a room if it doesn't exist
        RoomDTO newRoom = letschat.getOrCreateRoom("my_new_room_slug");
        System.out.println("Found/created room: " + newRoom);
    } catch (Exception e) {
        System.out.println("Caught: " + e);
        e.printStackTrace();
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 63 with DefaultKubernetesClient

use of io.fabric8.kubernetes.client.DefaultKubernetesClient in project fabric8 by fabric8io.

the class Example method main.

public static void main(String[] args) {
    String projectName = "admin-beer";
    if (args.length > 0) {
        projectName = args[0];
    }
    try {
        KubernetesClient kubernetes = new DefaultKubernetesClient();
        TaigaClient taiga = TaigaKubernetes.createTaiga(kubernetes, KubernetesHelper.defaultNamespace());
        System.out.println("Connecting to taiga on: " + taiga.getAddress());
        ProjectDTO myProject = taiga.getProjectBySlug(projectName);
        System.out.println("Found project: " + myProject + " by slug: " + projectName);
        System.out.println("Project id for slug: " + myProject + " is: " + taiga.getProjectIdForSlug(projectName));
        ProjectDTO notExist = taiga.getProjectBySlug("does-not-exist");
        System.out.println("Found non existing project: " + notExist);
        Map<String, ModuleDTO> modules = taiga.getModulesForProject(projectName);
        System.out.println("Available modules for " + projectName + " are: " + modules.keySet());
        // lets try find the module for gogs
        ModuleDTO gogsModule = taiga.moduleForProject(projectName, TaigaModule.GOGS);
        System.out.println("Gogs module for " + projectName + " is " + gogsModule);
        ProjectDTO autoCreateProject = taiga.getOrCreateProject("thingy");
        System.out.println("getOrCreateProject: " + autoCreateProject);
        List<ProjectDTO> projects = taiga.getProjects();
        for (ProjectDTO project : projects) {
            System.out.println("Project " + project.getId() + " has slug: " + project.getSlug() + " name " + project.getName());
        }
    } catch (Exception e) {
        System.out.println("Caught: " + e);
        e.printStackTrace();
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Example 64 with DefaultKubernetesClient

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

the class NoNamespaceTest method testServiceInjection.

@Test
public void testServiceInjection() {
    KubernetesClient client = new DefaultKubernetesClient();
    String namespace = client.getNamespace();
    // If namespace not null or empty then don't fail if the result is unexpected.
    Assume.assumeTrue(Strings.isNullOrBlank(namespace));
    expectedException.expect(ThrowableMessageMatcher.hasMessage(CoreMatchers.equalTo("No kubernetes service could be found for name: notfound in namespace: null")));
    createInstance(MyBean.class);
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) Test(org.junit.Test)

Example 65 with DefaultKubernetesClient

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

the class ShowConfiguration method main.

public static void main(String[] args) {
    String environmentKey = "testing";
    if (args.length > 0) {
        environmentKey = args[0];
    }
    Map<String, String> map = new HashMap<>();
    map.put(FABRIC8_ENVIRONMENT, environmentKey);
    Configuration configuration = Configuration.fromMap(map, new DefaultKubernetesClient());
    System.out.println("Namespace: " + configuration.getNamespace());
    System.out.println("isEnvironmentInitEnabled: " + configuration.isEnvironmentInitEnabled());
    System.out.println("isNamespaceLazyCreateEnabled: " + configuration.isNamespaceLazyCreateEnabled());
    System.out.println("isNamespaceCleanupEnabled: " + configuration.isNamespaceCleanupEnabled());
    System.out.println("isCreateNamespaceForTest: " + configuration.isCreateNamespaceForTest());
}
Also used : HashMap(java.util.HashMap) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Aggregations

DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)79 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)55 HashMap (java.util.HashMap)13 Config (io.fabric8.kubernetes.client.Config)11 ConfigBuilder (io.fabric8.kubernetes.client.ConfigBuilder)7 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)7 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)6 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)6 TaskAction (org.gradle.api.tasks.TaskAction)6 Pod (io.fabric8.kubernetes.api.model.Pod)5 IOException (java.io.IOException)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 File (java.io.File)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 Service (io.fabric8.kubernetes.api.model.Service)3 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)3 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)3