Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Show HierarchicalResourceQuota status by kubectl-hns #283

Merged

Conversation

mochizuki875
Copy link
Contributor

What type of PR is this?:

/kind feature

What this PR does / why we need it:

As #274, there is no way to know the quota and consumption of resource in the HierarchicalResourceQuota other than check the detail.
So I added new sub-command to show HierarchicalResourceQuota status as below.

$ kubectl hns hrq -n test
NAME         AGE     REQUEST                                              LIMIT
test-hrq     2m37s   requests.cpu: 500m/1, requests.memory: 100Mi/200Mi   limits.cpu: 500m/2, limits.memory: 100Mi/500Mi
test-hrq-2   4m6s    requests.memory: 100Mi/300Mi                         limits.cpu: 500m/1

$ kubectl hns hrq test-hrq -n test
NAME       AGE     REQUEST                                              LIMIT
test-hrq   2m43s   requests.cpu: 500m/1, requests.memory: 100Mi/200Mi   limits.cpu: 500m/2, limits.memory: 100Mi/500Mi

$ kubectl hns hrq --all-namespaces
NAMESPACE   NAME         AGE     REQUEST                                              LIMIT
test        test-hrq     2m49s   requests.cpu: 500m/1, requests.memory: 100Mi/200Mi   limits.cpu: 500m/2, limits.memory: 100Mi/500Mi
test        test-hrq-2   4m18s   requests.memory: 100Mi/300Mi                         limits.cpu: 500m/1

Tested:

Unit and E2E tests has passed.
I also added test case to HRQ E2E test which is now Pending.

Which issue(s) this PR fixes:

#274

Special notes for your reviewer:

In this case, if there is a .status.hard.<requests/limits>.<resource> field in HierarchicalResourceQuota, the corresponding content should appear in REQUEST and LIMIT.

I tried using JsonPath with HierarchicalResourceQuota's CustomResourceDefinition(.spec.versions.additionalPrinterColumns field), but I couldn't come up with an expression to control what is displayed.

So in this PR, I propose a new sub-command of kubectl-hns in the following format to view the status of HierarchicalResourceQuota

kubectl-hns hrq [NAME] [flags]

If you have better ideas for doing that, please let me know and I'll fix it.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 26, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @mochizuki875. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 26, 2023
@k8s-ci-robot k8s-ci-robot requested review from srampal and tashimi May 26, 2023 07:07
@adrianludwin
Copy link
Contributor

This looks amazing. No notes, thank you for doing this!

Can you please also cherry-pick this to the v1.1 branch?

/ok-to-test
/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 26, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 26, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianludwin, mochizuki875

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 26, 2023
@k8s-ci-robot k8s-ci-robot merged commit 97817c0 into kubernetes-retired:master May 26, 2023
keisukesakasai added a commit to keisukesakasai/hierarchical-namespaces that referenced this pull request May 27, 2023
k8s-ci-robot added a commit that referenced this pull request Jun 12, 2023
@adrianludwin adrianludwin added this to the release-v1.1 milestone Jun 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants