Java Code Examples for io.fabric8.kubernetes.internal.KubernetesDeserializer#registerCustomKind()

The following examples show how to use io.fabric8.kubernetes.internal.KubernetesDeserializer#registerCustomKind() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KubernetesConnection.java    From vault-crd with Apache License 2.0 6 votes vote down vote up
@Bean
public MixedOperation<Vault, VaultList, DoneableVault, Resource<Vault, DoneableVault>> customResource(
        KubernetesClient client, @Value("${kubernetes.crd.name}") String crdName) {
    Resource<CustomResourceDefinition, DoneableCustomResourceDefinition> crdResource
            = client.customResourceDefinitions().withName(crdName);

    // Hack for bug in Kubernetes-Client for CRDs https://github.com/fabric8io/kubernetes-client/issues/1099
    String kind = StringUtils.substringAfter(crdName, ".") + "/v1#Vault";
    KubernetesDeserializer.registerCustomKind(kind, Vault.class);

    CustomResourceDefinition customResourceDefinition = crdResource.get();
    if (customResourceDefinition == null) {
        log.error("Please first apply custom resource definition and then restart vault-crd");
        System.exit(1);
    }

    return client.customResources(customResourceDefinition, Vault.class, VaultList.class, DoneableVault.class);
}
 
Example 2
Source File: CustomResourceOperationsImpl.java    From kubernetes-client with Apache License 2.0 6 votes vote down vote up
public CustomResourceOperationsImpl(CustomResourceOperationContext context) {
  super(context.withApiGroupName(context.getCrdContext().getGroup())
    .withApiGroupVersion(context.getCrdContext().getVersion())
    .withPlural(context.getCrdContext().getPlural()));

  this.type = context.getType();
  this.listType = context.getListType();
  this.doneableType = context.getDoneableType();

  this.resourceNamespaced = resourceNamespaced(context.getCrdContext());
  this.apiVersion = getAPIGroup() + "/" + getAPIVersion();

  KubernetesDeserializer.registerCustomKind(apiVersion, kind(context.getCrdContext()), type);
  if (KubernetesResource.class.isAssignableFrom(listType)) {
    KubernetesDeserializer.registerCustomKind(listType.getSimpleName(), (Class<? extends KubernetesResource>) listType);
  }
}
 
Example 3
Source File: Operator.java    From java-operator-sdk with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
private <R extends CustomResource> void registerController(ResourceController<R> controller,
                                                           boolean watchAllNamespaces, Retry retry, String... targetNamespaces) throws OperatorException {
    Class<R> resClass = getCustomResourceClass(controller);
    CustomResourceDefinition crd = getCustomResourceDefinitionForController(controller);
    KubernetesDeserializer.registerCustomKind(getApiVersion(crd), getKind(crd), resClass);

    MixedOperation client = k8sClient.customResources(crd, resClass, CustomResourceList.class, getCustomResourceDoneableClass(controller));
    EventDispatcher eventDispatcher = new EventDispatcher(controller,
            getDefaultFinalizer(controller), new EventDispatcher.CustomResourceReplaceFacade(client));
    EventScheduler eventScheduler = new EventScheduler(eventDispatcher, retry, ControllerUtils.getGenerationEventProcessing(controller));
    registerWatches(controller, client, resClass, watchAllNamespaces, targetNamespaces, eventScheduler);
}
 
Example 4
Source File: Crds.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
/**
 * Register custom resource kinds with {@link KubernetesDeserializer} so Fabric8 knows how to deserialize them.
 */
public static void registerCustomKinds() {
    for (Class<? extends CustomResource> crdClass : CRDS) {
        for (String version : apiVersions(crdClass)) {
            KubernetesDeserializer.registerCustomKind(version, kind(crdClass), crdClass);
        }
    }
}
 
Example 5
Source File: CoreCrd.java    From enmasse with Apache License 2.0 5 votes vote down vote up
public static void registerCustomCrds() {
    KubernetesDeserializer.registerCustomKind(API_VERSION, Address.KIND, Address.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION, AddressList.KIND, AddressList.class);

    KubernetesDeserializer.registerCustomKind(API_VERSION, AddressSpace.KIND, AddressSpace.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION, AddressSpaceList.KIND, AddressSpaceList.class);

    KubernetesDeserializer.registerCustomKind(API_VERSION, AddressSpaceSchema.KIND, AddressSpaceSchema.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION, AddressSpaceSchemaList.KIND, AddressSpaceSchemaList.class);

    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingInfrastructure", MessagingInfrastructure.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingInfrastructureList", MessagingInfrastructureList.class);

    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingTenant", MessagingTenant.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingTenantList", MessagingTenantList.class);

    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingAddress", MessagingAddress.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingAddressList", MessagingAddressList.class);

    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingEndpoint", MessagingEndpoint.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingEndpointList", MessagingEndpointList.class);

    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingPlan", MessagingPlan.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingPlanList", MessagingPlanList.class);

    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingAddressPlan", MessagingAddressPlan.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION_BETA2, "MessagingAddressPlanList", MessagingAddressPlanList.class);
}
 
Example 6
Source File: CustomResourceCrudTest.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@BeforeEach
void setUp() {
  KubernetesDeserializer.registerCustomKind("stable.example.com/v1", "CronTab", CronTab.class);
  cronTabCrd = kubernetesServer.getClient()
    .customResourceDefinitions()
    .load(getClass().getResourceAsStream("/crontab-crd.yml"))
    .get();
  kubernetesServer.getClient().customResourceDefinitions().create(cronTabCrd);
  crdContext = CustomResourceDefinitionContext.fromCrd(cronTabCrd);
}
 
Example 7
Source File: RabbitMQOperator.java    From rabbitmq-operator with Apache License 2.0 4 votes vote down vote up
private void registerCrdDeserializationTypes() {
    KubernetesDeserializer.registerCustomKind("indeed.com/v1alpha1", "RabbitMQCustomResource", RabbitMQCustomResource.class);
    KubernetesDeserializer.registerCustomKind("indeed.com/v1alpha1", "RabbitMQNetworkPartitionCustomResource", RabbitMQNetworkPartitionCustomResource.class);
}
 
Example 8
Source File: K8SCoreRuntime.java    From jhipster-operator with Apache License 2.0 4 votes vote down vote up
public void registerCustomKind(String apiVersion, String kind, Class<? extends KubernetesResource> clazz) {
    KubernetesDeserializer.registerCustomKind(apiVersion, kind, clazz);
}
 
Example 9
Source File: AdmissionReviewTest.java    From vault-crd with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
    String kind = StringUtils.substringAfter("vault.koudingspawn.de", ".") + "/v1#Vault";
    KubernetesDeserializer.registerCustomKind(kind, Vault.class);
}
 
Example 10
Source File: AdminCrd.java    From enmasse with Apache License 2.0 4 votes vote down vote up
public static void registerCustomCrds() {

        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA2, AddressPlan.KIND, AddressPlan.class);
        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA2, AddressPlanList.KIND, AddressPlanList.class);

        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA2, AddressSpacePlan.KIND, AddressSpacePlan.class);
        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA2, AddressSpacePlanList.KIND, AddressSpacePlanList.class);

        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA1, BrokeredInfraConfig.KIND, BrokeredInfraConfig.class);
        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA1, BrokeredInfraConfigList.KIND, BrokeredInfraConfigList.class);

        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA1, StandardInfraConfig.KIND, StandardInfraConfig.class);
        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA1, StandardInfraConfigList.KIND, StandardInfraConfigList.class);

        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA1, AuthenticationService.KIND, AuthenticationService.class);
        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA1, AuthenticationServiceList.KIND, AuthenticationServiceList.class);

        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA1, ConsoleService.KIND, ConsoleService.class);
        KubernetesDeserializer.registerCustomKind(API_VERSION_V1BETA1, ConsoleServiceList.KIND, ConsoleServiceList.class);

    }
 
Example 11
Source File: UserCrd.java    From enmasse with Apache License 2.0 4 votes vote down vote up
public static void registerCustomCrds() {
    KubernetesDeserializer.registerCustomKind(API_VERSION, User.KIND, User.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION, UserList.KIND, UserList.class);
}
 
Example 12
Source File: IoTCrd.java    From enmasse with Apache License 2.0 4 votes vote down vote up
public static void registerCustomCrds() {
    KubernetesDeserializer.registerCustomKind(API_VERSION, IoTProject.KIND, IoTProject.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION, IoTProjectList.KIND, IoTProjectList.class);
    KubernetesDeserializer.registerCustomKind(API_VERSION, IoTConfig.KIND, IoTConfig.class);
}