Skip to content

Allow to run on specific namespaces with restricted permission #46

Closed

Description

@MrLuje

Describe the bug
On the cluster I used, I don't have access to all namespaces.
Even if I specify my namespaces, it seems it try to get the resources through a cluster-scoped api instead of a namespaced one.

To Reproduce
Steps to reproduce the behavior:

  1. Make sure you don't have access to all namespaces, ex :
$ kubectl get po -A
Error from server (Forbidden): pods is forbidden: User "u-wf3je4hm2h" cannot list resource "pods" in API group "" at the cluster scope
  1. krr simple -n my_namespace
  2. See error
Running Robusta's KRR (Kubernetes Resource Recommender) 1.0.0
Using strategy: Simple
Using formatter: table

[ERROR] Error trying to list pods in cluster k8s-prod: (403)
Reason: Forbidden
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"deployments.apps is forbidden: User \"u-wf3je4hm2h\" cannot list resource \"deployments\" in API group \"apps\" at the cluster
scope","reason":"Forbidden","details":{"group":"apps","kind":"deployments"},"code":403}

Expected behavior
It should be able to get the data if I have access to the specified namespace

Thank for krr, it's awesome :)

Activity

  1. mnbbrown commented on May 25, 2023

    @mnbbrown

    #48 I had a similar challenge so have opened a PR.

  2. LeaveMyYard commented on Jul 10, 2023

    @LeaveMyYard
    Contributor

    Update on this one: @mnbbrown has done a great job, but he did not sign the CLA so we can not merge it
    We really hope he will come back, if not - we will make another PR

  3. ZodZekri commented on Jul 13, 2023

    @ZodZekri

    same issue with me !!

  4. ZodZekri commented on Jul 17, 2023

    @ZodZekri

    can someone merge the PR of @mnbbrown please

  5. aantn commented on Jul 17, 2023

    @aantn
    Contributor

    Hey all, we'd really like to merge but like most open source projects, we require a CLA signature before we can merge.

    @mnbbrown if you have questions regarding the CLA, let me know.

    The PR needs some updating due to recent changes we made elsewhere, but we can handle that on our end.

  6. ZodZekri commented on Jul 25, 2023

    @ZodZekri

    @aantn Yes if you cant handle it it will be a pleasure thanks to try it

  7. linked a pull request that will close this issueFix listing namespaced workflows #122on Aug 9, 2023
  8. ecourreges-orange commented on Aug 28, 2023

    @ecourreges-orange

    Hello, I am not sure this is fully fixed,
    Launching it today from a clone that includes this supposed fix commit, with command
    python krr.py simple --namespace cclexploit-monitoring
    I get the error below that shows that cluster scope requests are still made, here it's a get services which I am allowed on kubectl if i stay in my namespace.

    ApiException: (403)
    Reason: Forbidden
    HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"services is forbidden: User \"https://xxx/dex#ecourreges\" cannot list
    resource \"services\" in API group \"\" at the cluster scope","reason":"Forbidden","details":{"kind":"services"},"code":403}
    
  9. saeidakbari commented on Nov 27, 2023

    @saeidakbari

    I got the same issue while listing resources for Services

  10. rohank07 commented on Feb 15, 2024

    @rohank07
    Contributor

    Encountering the same issue

  11. aantn commented on Mar 3, 2024

    @aantn
    Contributor

    Does #220 fix this?

  12. ecourreges-orange commented on Mar 4, 2024

    @ecourreges-orange

    Does #220 fix this?

    It improves for sure compared to the main branch, now it does display the table of deployments for the namespace correctly, but it still tries to get HPA at cluster scope which is not allowed:

    HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"horizontalpodautoscalers.autoscaling is forbidden: User
                        \"https://mysite.com/dex#myuser\" cannot list resource \"horizontalpodautoscalers\" in API group \"autoscaling\" at the cluster
                        scope","reason":"Forbidden","details":{"group":"autoscaling","kind":"horizontalpodautoscalers"},"code":403}
    
  13. rohank07 commented on Mar 4, 2024

    @rohank07
    Contributor

    Does #220 fix this?

    It improves for sure compared to the main branch, now it does display the table of deployments for the namespace correctly, but it still tries to get HPA at cluster scope which is not allowed:

    HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"horizontalpodautoscalers.autoscaling is forbidden: User
                        \"https://mysite.com/dex#myuser\" cannot list resource \"horizontalpodautoscalers\" in API group \"autoscaling\" at the cluster
                        scope","reason":"Forbidden","details":{"group":"autoscaling","kind":"horizontalpodautoscalers"},"code":403}
    

    HPA detection is still broken on https://github.com/robusta-dev/krr/pull/220 (for now) but everything else should work

  14. aantn commented on Mar 5, 2024

    @aantn
    Contributor

    Can you try the lastest commit on #220?
    I've added a fix for the HPA there.

    Thanks for the patience!

  15. ecourreges-orange commented on Mar 5, 2024

    @ecourreges-orange

    Can you try the lastest commit on #220? I've added a fix for the HPA there.

    Thanks for the patience!

    Good job, it works for me with no error now!

  16. aantn commented on Mar 5, 2024

    @aantn
    Contributor

    Wonderful, thanks.

    In general, we're figuring out how to better support enterprise environments (w/ limited permissions and organizational difficulties in actually getting KRR's recommendations applied after a scan). If you're open to it, would love to chat and get feedback on related areas.

  17. ecourreges-orange commented on Mar 5, 2024

    @ecourreges-orange

    Wonderful, thanks.

    In general, we're figuring out how to better support enterprise environments (w/ limited permissions and organizational difficulties in actually getting KRR's recommendations applied after a scan). If you're open to it, would love to chat and get feedback on related areas.

    I sent you a message on linkedIn for follow-up, happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions