Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list namespaced crd objects using crd yaml without global crd reading permission #1777

Closed
LeiYangGH opened this issue Apr 14, 2022 · 4 comments
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@LeiYangGH
Copy link

LeiYangGH commented Apr 14, 2022

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);
@LeiYangGH LeiYangGH added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 14, 2022
@roycaihw
Copy link
Member

/assign

@roycaihw
Copy link
Member

Could you enable debug logging and see what HTTP endpoints the client hits? I'd be surprised if list_namespaced_custom_object tries to reach a CRD (apiextensions) endpoint

@LeiYangGH
Copy link
Author

i will do it later. i thought i was watching(using java api). will add the logs later.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

4 participants