Search in sources :

Example 1 with PodGroupList

use of io.fabric8.volcano.scheduling.v1beta1.PodGroupList in project kubernetes-client by fabric8io.

the class V1Beta1VolcanoTest method testV1Beta1PodGroup.

@Test
void testV1Beta1PodGroup() {
    PodGroup podGroup = new PodGroupBuilder().editOrNewMetadata().withName("Pod").endMetadata().build();
    client.v1beta1().podGroups().inNamespace("ns1").create(podGroup);
    PodGroupList podGroupList = client.v1beta1().podGroups().inNamespace("ns1").list();
    assertNotNull(podGroupList);
    assertEquals(1, podGroupList.getItems().size());
}
Also used : PodGroupBuilder(io.fabric8.volcano.scheduling.v1beta1.PodGroupBuilder) PodGroup(io.fabric8.volcano.scheduling.v1beta1.PodGroup) PodGroupList(io.fabric8.volcano.scheduling.v1beta1.PodGroupList) Test(org.junit.jupiter.api.Test)

Example 2 with PodGroupList

use of io.fabric8.volcano.scheduling.v1beta1.PodGroupList in project kubernetes-client by fabric8io.

the class VolcanoTest method testPodGroupWithMetaAndSpec.

@Test
void testPodGroupWithMetaAndSpec() {
    Quantity cpu = new QuantityBuilder(false).withAmount("1").build();
    Quantity memory = new QuantityBuilder(false).withAmount(TEST_MEMORY + "Mi").build();
    Map<String, Quantity> resourceMap = new HashMap<>();
    resourceMap.put("cpu", cpu);
    resourceMap.put("memory", memory);
    // Create PodGroup with metadata and spec
    PodGroup podGroup = new PodGroupBuilder().editOrNewMetadata().withName(TEST_GROUP_NAME).withNamespace(TEST_NAMESPACE_NAME).endMetadata().editOrNewSpec().withMinResources(resourceMap).endSpec().build();
    client.podGroups().inNamespace(TEST_NAMESPACE_NAME).create(podGroup);
    // Check podgroup
    PodGroupList podGroupList = client.podGroups().inNamespace(TEST_NAMESPACE_NAME).list();
    assertNotNull(podGroupList);
    assertEquals(1, podGroupList.getItems().size());
    PodGroup group1 = podGroupList.getItems().get(0);
    // Check name and namespace in metadata
    assertEquals(TEST_GROUP_NAME, group1.getMetadata().getName());
    assertEquals(TEST_NAMESPACE_NAME, group1.getMetadata().getNamespace());
    // Check cpu/memory amount in spec
    assertEquals(TEST_CPU_NUM, group1.getSpec().getMinResources().get("cpu").getAmount());
    assertEquals(TEST_MEMORY, group1.getSpec().getMinResources().get("memory").getAmount());
}
Also used : QuantityBuilder(io.fabric8.kubernetes.api.model.QuantityBuilder) PodGroupBuilder(io.fabric8.volcano.scheduling.v1beta1.PodGroupBuilder) HashMap(java.util.HashMap) Quantity(io.fabric8.kubernetes.api.model.Quantity) PodGroup(io.fabric8.volcano.scheduling.v1beta1.PodGroup) PodGroupList(io.fabric8.volcano.scheduling.v1beta1.PodGroupList) Test(org.junit.jupiter.api.Test)

Example 3 with PodGroupList

use of io.fabric8.volcano.scheduling.v1beta1.PodGroupList in project kubernetes-client by fabric8io.

the class PodGroupCreate method main.

public static void main(String[] args) {
    try (NamespacedVolcanoClient volcanoClient = new DefaultVolcanoClient()) {
        String namespace = "default";
        String groupName = "group1";
        PodGroup podGroup = Utils.buildDefaultPodGroups(namespace, groupName);
        // Create PodGroup
        volcanoClient.podGroups().inNamespace(namespace).createOrReplace(podGroup);
        System.out.println("Created: " + podGroup.getMetadata().getName());
        // Wait for status or 5s timeout
        volcanoClient.podGroups().inNamespace(namespace).withName(groupName).waitUntilCondition(group -> Objects.nonNull(group.getStatus()) && group.getStatus().getPhase().equals("Running"), 5, TimeUnit.SECONDS);
        System.out.println("Created: " + podGroup.getMetadata().getName());
        // List PodGroup
        PodGroupList podGroupList = volcanoClient.podGroups().inNamespace(namespace).list();
        System.out.println("There are " + podGroupList.getItems().size() + " PodGroup objects in " + namespace);
        // Delete PodGroup
        volcanoClient.podGroups().inNamespace(namespace).withName(groupName).delete();
    }
}
Also used : NamespacedVolcanoClient(io.fabric8.volcano.client.NamespacedVolcanoClient) DefaultVolcanoClient(io.fabric8.volcano.client.DefaultVolcanoClient) PodGroup(io.fabric8.volcano.scheduling.v1beta1.PodGroup) PodGroupList(io.fabric8.volcano.scheduling.v1beta1.PodGroupList)

Example 4 with PodGroupList

use of io.fabric8.volcano.scheduling.v1beta1.PodGroupList in project kubernetes-client by fabric8io.

the class PodGroupCreate method main.

public static void main(String[] args) {
    try (NamespacedVolcanoClient volcanoClient = new DefaultVolcanoClient()) {
        String namespace = "default";
        String groupName = "group1";
        PodGroup podGroup = Utils.buildDefaultPodGroups(namespace, groupName);
        // Create PodGroup
        volcanoClient.v1beta1().podGroups().inNamespace(namespace).createOrReplace(podGroup);
        System.out.println("Created: " + podGroup.getMetadata().getName());
        // Wait for status or 5s timeout
        volcanoClient.v1beta1().podGroups().inNamespace(namespace).withName(groupName).waitUntilCondition(group -> Objects.nonNull(group.getStatus()) && group.getStatus().getPhase().equals("Running"), 5, TimeUnit.SECONDS);
        System.out.println("Created: " + podGroup.getMetadata().getName());
        // List PodGroup
        PodGroupList podGroupList = volcanoClient.v1beta1().podGroups().inNamespace(namespace).list();
        System.out.println("There are " + podGroupList.getItems().size() + " PodGroup objects in " + namespace);
        // Delete PodGroup
        volcanoClient.v1beta1().podGroups().inNamespace(namespace).withName(groupName).delete();
    }
}
Also used : NamespacedVolcanoClient(io.fabric8.volcano.client.NamespacedVolcanoClient) DefaultVolcanoClient(io.fabric8.volcano.client.DefaultVolcanoClient) PodGroup(io.fabric8.volcano.scheduling.v1beta1.PodGroup) PodGroupList(io.fabric8.volcano.scheduling.v1beta1.PodGroupList)

Aggregations

PodGroup (io.fabric8.volcano.scheduling.v1beta1.PodGroup)4 PodGroupList (io.fabric8.volcano.scheduling.v1beta1.PodGroupList)4 DefaultVolcanoClient (io.fabric8.volcano.client.DefaultVolcanoClient)2 NamespacedVolcanoClient (io.fabric8.volcano.client.NamespacedVolcanoClient)2 PodGroupBuilder (io.fabric8.volcano.scheduling.v1beta1.PodGroupBuilder)2 Test (org.junit.jupiter.api.Test)2 Quantity (io.fabric8.kubernetes.api.model.Quantity)1 QuantityBuilder (io.fabric8.kubernetes.api.model.QuantityBuilder)1 HashMap (java.util.HashMap)1