Closed
Description
similiar to issue 740, which deals with creating. but now i'm listing.
What is the feature and why do you need it:
In certain circumstances, the servcie account doesn't have read permission to read global crd, but we already have crd yaml locally. and i want to list namespaced cr objects.
config.load_incluster_config()
crs = client.CustomObjectsApi().list_namespaced_custom_object(group="company.com", version="v1beta1",
plural="some-configs", namespace='namespace')
won't work because it tries to read global crd via k8s api first(no permission).
Describe the solution you'd like to see:
config.load_incluster_config()
crs = client.CustomObjectsApi().list_namespaced_custom_object(group="com.company", version="v1beta1",
plural="some-configs", namespace='namespace', crd_yaml=loadresource(some_local_file))
We have similiar issue with java client and we have some working code like this:
public final CustomResourceDefinition extractCrdInfo(NamespacedKubernetesClient client,
String localCrdFileName){
InputStream is = getClass().getResourceAsStream(localCrdFileName);
return loadCRD(client, is);
}
public final CustomResourceDefinitionContext buildCrdCtx(CustomResourceDefinition crd) {
return new CustomResourceDefinitionContext.Builder()
.withName(crd.getMetadata().getName())
.withScope("Namespaced")
.withVersion("v1beta1")
.withPlural(crd.getSpec().getNames().getPlural())
.withKind(crd.getSpec().getNames().getKind())
.withGroup(crd.getSpec().getGroup())
.build();
}
return client.customResources(resourceCrdCtx, SOMEJAVA.class, SOMEJAVA1.class,
SOMEJAVA2.class);