Skip to content

Cridge fails to create CRD informer if first version is not served

When attempting to create a CRD informer, cridge will default to always using the first version specified in the CRD spec Source.

	protected void createCRDSharedIndexInformer(CustomResourceDefinition crd) {
		
		ResourceDefinitionContext context = new ResourceDefinitionContext.Builder()
				.withGroup(crd.getSpec().getGroup())
				.withVersion(crd.getSpec().getVersions().get(0).getName())
				.withKind(crd.getSpec().getNames().getKind())
				.withPlural(crd.getSpec().getNames().getPlural()).build();

This can be problematic in cases where the first version specified is one that is not served (served: false), this usually happens for CRDs that maintain old versions even after they are removed from the respective operators. In these cases when the informer attempts to query the kubernetes API it will receive an error and the informer will not be created.