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

Feature Request: Add Option to Exclude Nodes and Avoid Node List API Call #161

Open
M-JavadHeydarpour opened this issue Oct 1, 2024 · 0 comments

Comments

@M-JavadHeydarpour
Copy link

Problem Statement:

When using kubectl resource-capacity in an environment with namespace-scoped permissions, the command attempts to list nodes by calling the Kubernetes API (v1 list nodes). This causes issues for users who do not have permissions to access node resources, resulting in errors or incomplete outputs.

Example command:

kubectl resource-capacity --sort cpu.request --util --pods --sort cpu.request --pod-count --output table --namespace nginx
NODE         POD                                                         CPU REQUESTS   CPU LIMITS   CPU UTIL   MEMORY REQUESTS   MEMORY LIMITS   MEMORY UTIL   POD COUNT
*            *                                                           100m (0%)      200m (0%)    0m (0%)    256Mi (0%)        512Mi (0%)      0Mi (0%)      1/220
                                                                                                                                                                
eu-kube-w1   *                                                           100m (2%)      200m (5%)    2m (0%)    256Mi (1%)        512Mi (3%)      110Mi (0%)    1/110
eu-kube-w1   nginx-nginx-deployment-sample-deployment-55b768d7fd-2nk9l   100m (2%)      200m (5%)    2m (0%)    256Mi (1%)        512Mi (3%)      110Mi (0%)    
                                                                                                                                                                
eu-kube-m1   *                                                           0m (0%)        0m (0%)      0m (0%)    0Mi (0%)          0Mi (0%)        0Mi (0%)      0/110

In environments without node access, the command fails or cannot display the node-related information.

Feature Request:

  • Add an option to exclude node information from the output.
  • Prevent the command from making API calls to list nodes when this option is enabled.

This would allow users with namespace-scoped permissions to use kubectl resource-capacity without encountering permission errors.

Proposed Solution:

Introduce a flag (e.g., --exclude-nodes or --namespace-scope) that:

  • Omits node information from the output.
  • Skips any API calls that attempt to list or describe nodes.
  • Focuses solely on the resources within the specified namespace(s).

Benefits:

  • Enhances usability for users with limited permissions.
  • Aligns with Kubernetes' RBAC practices by respecting the user's scope.
  • Increases the tool's flexibility in various operational environments.

Additional Context:

Users operating in restricted environments (e.g., developers in a multi-tenant cluster) often have permissions only within certain namespaces. By avoiding unnecessary API calls that require cluster-wide permissions, the tool becomes more accessible and useful to a broader audience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant