Search in sources :

Example 96 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project xp-operator by enonic.

the class CrudTest method v1Xp7Deployment.

@Test
void v1Xp7Deployment() throws IOException, URISyntaxException {
    EnonicKubernetesClient client = new DefaultEnonicKubernetesClient(server.getClient());
    // Create crd
    CustomResourceDefinition crd = client.k8s().apiextensions().v1().customResourceDefinitions().load(getClass().getResourceAsStream("/crds/deployments.yaml")).get();
    client.k8s().apiextensions().v1().customResourceDefinitions().create(crd);
    // Create crd client
    MixedOperation<Xp7Deployment, Xp7Deployment.Xp7DeploymentList, Resource<Xp7Deployment>> crdClient = client.enonic().v1().crds().xp7deployments();
    // Create resource
    ObjectMetaBuilder metadataBuilder = new ObjectMetaBuilder().withNamespace("test").withName("test-name");
    Xp7Deployment resource = new Xp7Deployment().withSpec(new Xp7DeploymentSpec().withEnabled(true).withXpVersion("unstable").withXp7DeploymentSpecNodesSharedDisks(Collections.singletonList(new Xp7DeploymentSpecNodesSharedDisk().withName("blobstore").withSize("150"))).withXp7DeploymentSpecNodeGroups(Collections.singletonList(new Xp7DeploymentSpecNodeGroup().withName("test").withDisplayName("test").withReplicas(1).withData(true).withMaster(true).withXp7DeploymentSpecNodeGroupEnvironment(Collections.singletonList(new Xp7DeploymentSpecNodeGroupEnvVar().withName("test").withValue("test"))).withXp7DeploymentSpecNodeGroupResources(new Xp7DeploymentSpecNodeGroupResources().withCpu("1").withMemory("512Mi").withXp7DeploymentSpecNodeGroupDisks(Collections.singletonList(new Xp7DeploymentSpecNodeGroupDisk().withName("index").withSize("100m")))))));
    resource.setMetadata(metadataBuilder.build());
    assertCrd(resource, "/crud-deployment.json");
    // Send to server
    crdClient.create(resource);
    // List
    Xp7Deployment.Xp7DeploymentList list = crdClient.list();
    assertNotNull(list);
    assertEquals(1, list.getItems().size());
    assertEqualsCrd(resource, list.getItems().get(0));
    // Fetch from server
    Xp7Deployment get = crdClient.withName("test-name").get();
    assertNotNull(get);
    assertEquals(resource, get);
    // Test put
    resource.setMetadata(metadataBuilder.withLabels(Map.of("test2", "test2")).build());
    resource.setSpec(resource.getSpec().withEnabled(false));
    crdClient.withName("test-name").replace(resource);
    // Delete from server
    assertTrue(crdClient.withName("test-name").delete());
}
Also used : CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) Resource(io.fabric8.kubernetes.client.dsl.Resource) CustomResource(io.fabric8.kubernetes.client.CustomResource) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) Test(org.junit.jupiter.api.Test)

Example 97 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project xp-operator by enonic.

the class SchemaTest method v1Xp7Config.

@Test
void v1Xp7Config() throws IOException {
    CustomResourceDefinition customResourceDefinition = loadCRD("/crds/configs.yaml");
    JSONSchemaProps schema = loadSchema("/schema/v1/xp7config/xp7Config.json");
    assertSchema(getSchemaVersion(customResourceDefinition, "v1"), schema);
}
Also used : CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) JSONSchemaProps(io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps) Test(org.junit.jupiter.api.Test)

Example 98 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project xp-operator by enonic.

the class SchemaTest method loadCRD.

private CustomResourceDefinition loadCRD(final String file) {
    KubernetesClient client = server.getClient();
    CustomResourceDefinition customResourceDefinition = client.apiextensions().v1().customResourceDefinitions().load(getClass().getResourceAsStream(file)).get();
    assertNotNull(customResourceDefinition);
    return customResourceDefinition;
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition)

Example 99 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project xp-operator by enonic.

the class SchemaTest method v1Domain.

@Test
void v1Domain() throws IOException {
    CustomResourceDefinition customResourceDefinition = loadCRD("/crds/domains.yaml");
    JSONSchemaProps schema = loadSchema("/schema/v1/domain/domain.json");
    assertSchema(getSchemaVersion(customResourceDefinition, "v1"), schema);
}
Also used : CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) JSONSchemaProps(io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps) Test(org.junit.jupiter.api.Test)

Example 100 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project debezium by debezium.

the class OcpApicurioV1Controller method registryOperation.

@Override
protected NonNamespaceOperation<ApicurioRegistry, ApicurioRegistryList, Resource<ApicurioRegistry>> registryOperation() {
    CustomResourceDefinition crd = ocp.apiextensions().v1beta1().customResourceDefinitions().load(OcpApicurioV1Controller.class.getResourceAsStream(APICURIO_CRD_DESCRIPTOR)).get();
    CustomResourceDefinitionContext context = CustomResourceDefinitionContext.fromCrd(crd);
    return ocp.customResources(context, ApicurioRegistry.class, ApicurioRegistryList.class).inNamespace(project);
}
Also used : CustomResourceDefinitionContext(io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition) ApicurioRegistryList(io.apicurio.registry.operator.api.model.ApicurioRegistryList) ApicurioRegistry(io.apicurio.registry.operator.api.model.ApicurioRegistry)

Aggregations

CustomResourceDefinition (io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition)60 Test (org.junit.jupiter.api.Test)49 CustomResourceDefinition (io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition)30 Description (io.qameta.allure.Description)12 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)11 IOException (java.io.IOException)11 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)10 CustomResourceDefinitionBuilder (io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder)10 Resource (io.fabric8.kubernetes.client.dsl.Resource)10 CustomResourceDefinitionContext (io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext)10 ArrayList (java.util.ArrayList)10 BeforeEach (org.junit.jupiter.api.BeforeEach)10 CustomResource (io.fabric8.kubernetes.client.CustomResource)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)7 StartupEvent (io.quarkus.runtime.StartupEvent)7 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)6 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)6 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)6 ServiceAccount (io.fabric8.kubernetes.api.model.ServiceAccount)6