use of io.fabric8.kubernetes.api.model.apiextensions.v1.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());
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition in project hugegraph-computer by hugegraph.
the class AbstractK8sTest method createCRD.
private void createCRD(KubernetesClient client) {
Resource<CustomResourceDefinition> crd = client.apiextensions().v1beta1().customResourceDefinitions().load(new File("../computer-k8s-operator/manifest" + "/hugegraph-computer-crd.v1beta1.yaml"));
crd.createOrReplace();
crd.waitUntilReady(2, TimeUnit.SECONDS);
Assert.assertNotNull(crd.get());
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition in project strimzi-kafka-operator by strimzi.
the class Crds method crd.
@SuppressWarnings({ "checkstyle:JavaNCSS" })
private static CustomResourceDefinition crd(Class<? extends CustomResource> cls) {
String scope, plural, singular, group, kind, listKind;
List<String> versions;
CustomResourceSubresourceStatus status = null;
if (cls.equals(Kafka.class)) {
scope = Kafka.SCOPE;
plural = Kafka.RESOURCE_PLURAL;
singular = Kafka.RESOURCE_SINGULAR;
group = Kafka.RESOURCE_GROUP;
kind = Kafka.RESOURCE_KIND;
listKind = Kafka.RESOURCE_LIST_KIND;
versions = Kafka.VERSIONS;
status = new CustomResourceSubresourceStatus();
} else if (cls.equals(KafkaConnect.class)) {
scope = KafkaConnect.SCOPE;
plural = KafkaConnect.RESOURCE_PLURAL;
singular = KafkaConnect.RESOURCE_SINGULAR;
group = KafkaConnect.RESOURCE_GROUP;
kind = KafkaConnect.RESOURCE_KIND;
listKind = KafkaConnect.RESOURCE_LIST_KIND;
versions = KafkaConnect.VERSIONS;
status = new CustomResourceSubresourceStatus();
} else if (cls.equals(KafkaTopic.class)) {
scope = KafkaTopic.SCOPE;
plural = KafkaTopic.RESOURCE_PLURAL;
singular = KafkaTopic.RESOURCE_SINGULAR;
group = KafkaTopic.RESOURCE_GROUP;
kind = KafkaTopic.RESOURCE_KIND;
listKind = KafkaTopic.RESOURCE_LIST_KIND;
versions = KafkaTopic.VERSIONS;
} else if (cls.equals(KafkaUser.class)) {
scope = KafkaUser.SCOPE;
plural = KafkaUser.RESOURCE_PLURAL;
singular = KafkaUser.RESOURCE_SINGULAR;
group = KafkaUser.RESOURCE_GROUP;
kind = KafkaUser.RESOURCE_KIND;
listKind = KafkaUser.RESOURCE_LIST_KIND;
versions = KafkaUser.VERSIONS;
status = new CustomResourceSubresourceStatus();
} else if (cls.equals(KafkaMirrorMaker.class)) {
scope = KafkaMirrorMaker.SCOPE;
plural = KafkaMirrorMaker.RESOURCE_PLURAL;
singular = KafkaMirrorMaker.RESOURCE_SINGULAR;
group = KafkaMirrorMaker.RESOURCE_GROUP;
kind = KafkaMirrorMaker.RESOURCE_KIND;
listKind = KafkaMirrorMaker.RESOURCE_LIST_KIND;
versions = KafkaMirrorMaker.VERSIONS;
status = new CustomResourceSubresourceStatus();
} else if (cls.equals(KafkaBridge.class)) {
scope = KafkaBridge.SCOPE;
plural = KafkaBridge.RESOURCE_PLURAL;
singular = KafkaBridge.RESOURCE_SINGULAR;
group = KafkaBridge.RESOURCE_GROUP;
kind = KafkaBridge.RESOURCE_KIND;
listKind = KafkaBridge.RESOURCE_LIST_KIND;
versions = KafkaBridge.VERSIONS;
status = new CustomResourceSubresourceStatus();
} else if (cls.equals(KafkaConnector.class)) {
scope = KafkaConnector.SCOPE;
plural = KafkaConnector.RESOURCE_PLURAL;
singular = KafkaConnector.RESOURCE_SINGULAR;
group = KafkaConnector.RESOURCE_GROUP;
kind = KafkaConnector.RESOURCE_KIND;
listKind = KafkaConnector.RESOURCE_LIST_KIND;
versions = KafkaConnector.VERSIONS;
status = new CustomResourceSubresourceStatus();
} else if (cls.equals(KafkaMirrorMaker2.class)) {
scope = KafkaMirrorMaker2.SCOPE;
plural = KafkaMirrorMaker2.RESOURCE_PLURAL;
singular = KafkaMirrorMaker2.RESOURCE_SINGULAR;
group = KafkaMirrorMaker2.RESOURCE_GROUP;
kind = KafkaMirrorMaker2.RESOURCE_KIND;
listKind = KafkaMirrorMaker2.RESOURCE_LIST_KIND;
versions = KafkaMirrorMaker2.VERSIONS;
status = new CustomResourceSubresourceStatus();
} else if (cls.equals(KafkaRebalance.class)) {
scope = KafkaRebalance.SCOPE;
plural = KafkaRebalance.RESOURCE_PLURAL;
singular = KafkaRebalance.RESOURCE_SINGULAR;
group = KafkaRebalance.RESOURCE_GROUP;
kind = KafkaRebalance.RESOURCE_KIND;
listKind = KafkaRebalance.RESOURCE_LIST_KIND;
versions = KafkaRebalance.VERSIONS;
status = new CustomResourceSubresourceStatus();
} else if (cls.equals(StrimziPodSet.class)) {
scope = StrimziPodSet.SCOPE;
plural = StrimziPodSet.RESOURCE_PLURAL;
singular = StrimziPodSet.RESOURCE_SINGULAR;
group = StrimziPodSet.RESOURCE_GROUP;
kind = StrimziPodSet.RESOURCE_KIND;
listKind = StrimziPodSet.RESOURCE_LIST_KIND;
versions = StrimziPodSet.VERSIONS;
status = new CustomResourceSubresourceStatus();
} else {
throw new RuntimeException();
}
List<CustomResourceDefinitionVersion> crVersions = new ArrayList<>(versions.size());
for (String apiVersion : versions) {
crVersions.add(new CustomResourceDefinitionVersionBuilder().withName(apiVersion).withNewSubresources().withStatus(status).endSubresources().withNewSchema().withNewOpenAPIV3Schema().withType("object").withXKubernetesPreserveUnknownFields(true).endOpenAPIV3Schema().endSchema().withStorage("v1beta2".equals(apiVersion)).withServed(true).build());
}
return new CustomResourceDefinitionBuilder().withNewMetadata().withName(plural + "." + group).endMetadata().withNewSpec().withScope(scope).withGroup(group).withVersions(crVersions).withNewNames().withSingular(singular).withPlural(plural).withKind(kind).withListKind(listKind).endNames().endSpec().build();
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition in project strimzi-kafka-operator by strimzi.
the class StructuralCrdIT method assertApiVersionsAreStructuralInApiextensionsV1.
private void assertApiVersionsAreStructuralInApiextensionsV1(String api, VersionRange<ApiVersion> shouldBeStructural) {
Pattern pattern = Pattern.compile("[^.]spec\\.versions\\[([0-9]+)\\]\\.[^,]*?");
CustomResourceDefinition crd = cluster.client().getClient().apiextensions().v1().customResourceDefinitions().withName(api).get();
// We can't make the following assertion because the current version of fabric8 always requests
// the CRD using v1beta1 api version, so the apiserver just replaces it and serves it.
// assertEquals(crdApiVersion, ApiVersion.parse(crd.getApiVersion().replace("apiextensions.k8s.io/", "")));
Set<ApiVersion> presentCrdApiVersions = crd.getSpec().getVersions().stream().map(v -> ApiVersion.parse(v.getName())).collect(Collectors.toSet());
assertTrue(presentCrdApiVersions.contains(shouldBeStructural.lower()), "CRD has versions " + presentCrdApiVersions + " which doesn't include " + shouldBeStructural.lower() + " which should be structural");
Map<Integer, ApiVersion> indexedVersions = new HashMap<>();
int i = 0;
for (CustomResourceDefinitionVersion version : crd.getSpec().getVersions()) {
indexedVersions.put(i, ApiVersion.parse(version.getName()));
}
Optional<CustomResourceDefinitionCondition> first = crd.getStatus().getConditions().stream().filter(cond -> "NonStructuralSchema".equals(cond.getType()) && "True".equals(cond.getStatus())).findFirst();
if (first.isPresent()) {
Matcher matcher = pattern.matcher(first.get().getMessage());
while (matcher.find()) {
Integer index = Integer.valueOf(matcher.group(1));
ApiVersion nonStructuralVersion = indexedVersions.get(index);
if (shouldBeStructural.contains(nonStructuralVersion)) {
fail(api + "/ " + nonStructuralVersion + " should be structural but there's a complaint about " + matcher.group());
}
}
}
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition in project strimzi-kafka-operator by strimzi.
the class JbodStorageTest method init.
@BeforeEach
private void init() {
this.volumes = new ArrayList<>(2);
volumes.add(new PersistentClaimStorageBuilder().withId(0).withDeleteClaim(true).withSize("100Gi").build());
volumes.add(new PersistentClaimStorageBuilder().withId(1).withDeleteClaim(false).withSize("100Gi").build());
this.kafka = new KafkaBuilder().withNewMetadata().withNamespace(NAMESPACE).withName(NAME).endMetadata().withNewSpec().withNewKafka().withReplicas(3).withListeners(new GenericKafkaListenerBuilder().withName("plain").withPort(9092).withType(KafkaListenerType.INTERNAL).withTls(false).build()).withNewJbodStorage().withVolumes(volumes).endJbodStorage().endKafka().withNewZookeeper().withReplicas(1).endZookeeper().endSpec().build();
// setting up the Kafka CRD
CustomResourceDefinition kafkaAssemblyCrd = Crds.kafka();
// setting up a mock Kubernetes client
this.mockClient = new MockKube().withCustomResourceDefinition(kafkaAssemblyCrd, Kafka.class, KafkaList.class).end().withCustomResourceDefinition(Crds.strimziPodSet(), StrimziPodSet.class, StrimziPodSetList.class).end().build();
// initialize a Kafka in MockKube
Crds.kafkaOperation(this.mockClient).inNamespace(NAMESPACE).withName(NAME).create(this.kafka);
PlatformFeaturesAvailability pfa = new PlatformFeaturesAvailability(false, KubernetesVersion.V1_16);
// creating the Kafka operator
ResourceOperatorSupplier ros = new ResourceOperatorSupplier(this.vertx, this.mockClient, ResourceUtils.zookeeperLeaderFinder(this.vertx, this.mockClient), ResourceUtils.adminClientProvider(), ResourceUtils.zookeeperScalerProvider(), ResourceUtils.metricsProvider(), pfa, FeatureGates.NONE, 60_000L);
this.operator = new KafkaAssemblyOperator(this.vertx, pfa, new MockCertManager(), new PasswordGenerator(10, "a", "a"), ros, ResourceUtils.dummyClusterOperatorConfig(VERSIONS, 2_000));
}
Aggregations