Search in sources :

Example 31 with CustomResourceDefinition

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

the class CrdMatchTest method customResourcesYamlSingular_shouldMatchWithSingularInJavaDefinition.

@Test
void customResourcesYamlSingular_shouldMatchWithSingularInJavaDefinition() throws IOException {
    withEveryYaml(crdTree -> {
        JsonNode crdNames = crdTree.get("spec").get("names");
        String declaredSingular = crdNames.get("singular").asText();
        CustomResourceDefinition definition = getDefinition(crdTree);
        assertEquals(declaredSingular, definition.getSpec().getNames().getSingular());
        Class<? extends CustomResource> clazz = getCustomResourceClass(crdTree);
        String singular = HasMetadata.getSingular(clazz);
        assertEquals(declaredSingular, singular, "Kind : " + HasMetadata.getKind(clazz));
    });
}
Also used : CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.jupiter.api.Test)

Example 32 with CustomResourceDefinition

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

the class ApplyService method applyCustomResourceDefinition.

public void applyCustomResourceDefinition(CustomResourceDefinition entity, String sourceName) {
    String currentNamespace = applicableNamespace(entity, namespace, fallbackNamespace);
    String id = getName(entity);
    Objects.requireNonNull(id, "No name for " + entity + " " + sourceName);
    if (isServicesOnlyMode()) {
        log.debug("Only processing Services right now so ignoring Custom Resource Definition: " + currentNamespace + ":" + id);
        return;
    }
    CustomResourceDefinition old = kubernetesClient.apiextensions().v1().customResourceDefinitions().withName(id).get();
    if (isRunning(old)) {
        if (UserConfigurationCompare.configEqual(entity, old)) {
            log.info("Custom Resource Definition has not changed so not doing anything");
        } else {
            if (isRecreateMode()) {
                log.info("Deleting Custom Resource Definition: " + id);
                kubernetesClient.apiextensions().v1().customResourceDefinitions().withName(id).delete();
                doCreateCustomResourceDefinition(entity, sourceName);
            } else {
                doPatchEntity(old, entity, currentNamespace, sourceName);
            }
        }
    } else {
        if (!isAllowCreate()) {
            log.warn("Creation disabled so not creating a Custom Resource Definition from " + sourceName + " name " + getName(entity));
        } else {
            doCreateCustomResourceDefinition(entity, sourceName);
        }
    }
}
Also used : CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition)

Example 33 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class StrimziBundleManagerTest method createKafkaCRDs.

private CustomResourceDefinition createKafkaCRDs() {
    CustomResourceDefinition crd = new CustomResourceDefinitionBuilder(Crds.kafka()).editMetadata().withName("kafkas.kafka.strimzi.io").withLabels(Map.of("app", "strimzi")).endMetadata().build();
    this.openShiftClient.apiextensions().v1().customResourceDefinitions().create(crd);
    return crd;
}
Also used : CustomResourceDefinitionBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionBuilder) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition)

Example 34 with CustomResourceDefinition

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class PrometheusRegisterInterceptor method registerPrometheus.

@AroundInvoke
public Object registerPrometheus(InvocationContext context) throws Exception {
    if (!ServiceMonitorClient.isServiceMonitorAvailable(kubernetesClient)) {
        final CustomResourceDefinition serviceMonitorCRD = kubernetesClient.apiextensions().v1().customResourceDefinitions().load(this.getClass().getResourceAsStream("/k8s/servicemonitor.v1.crd.yaml")).get();
        kubernetesClient.apiextensions().v1().customResourceDefinitions().withName(SERVICE_MONITOR_CRD_NAME).create(serviceMonitorCRD);
    }
    return context.proceed();
}
Also used : CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) AroundInvoke(javax.interceptor.AroundInvoke)

Example 35 with CustomResourceDefinition

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

the class CamelKPublishHandler method createIntegration.

@SuppressWarnings({ "unchecked" })
protected StateUpdate createIntegration(IntegrationDeployment integrationDeployment, CustomResourceDefinition integrationCRD) {
    logInfo(integrationDeployment, "Creating Camel-K resource");
    prepareDeployment(integrationDeployment);
    io.syndesis.server.controller.integration.camelk.crd.Integration camelkIntegration = createIntegrationCR(integrationDeployment);
    camelkIntegration = applyCustomizers(integrationDeployment, camelkIntegration);
    Secret camelkSecret = createIntegrationSecret(integrationDeployment);
    getOpenShiftService().createOrReplaceSecret(camelkSecret);
    getOpenShiftService().createOrReplaceCR(integrationCRD, io.syndesis.server.controller.integration.camelk.crd.Integration.class, IntegrationList.class, DoneableIntegration.class, camelkIntegration);
    logInfo(integrationDeployment, "Camel-K resource created " + camelkIntegration.getMetadata().getName());
    return new StateUpdate(IntegrationDeploymentState.Pending, Collections.emptyMap());
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) StateUpdate(io.syndesis.server.controller.StateUpdate)

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