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

output which pods are in use by a pvc when kubectl describe pvc is run #65837

Merged
merged 1 commit into from Jul 6, 2018

Conversation

@clandry94
Copy link
Contributor

clandry94 commented Jul 5, 2018

What this PR does / why we need it:
This PR implements a feature request to display the pods mounted to a PVC when kubectl describe pvc is ran. We need it since the only way to see which pods are bound to a PVC is by checking the volume mounts of each individual pod in the namespace.

Example Output:

$ kubectl get pods,pvc
NAME     READY  STATUS    RESTARTS   AGE
test-pod   1/1       Running       0                2h

NAME      STATUS    VOLUME                                   CAPACITY  ACCESS MODES   STORAGECLASS        AGE
test-pvc  Bound     pvc-718681dd-70cc-11e7-aa14-42010af00029   100Gi      RWO            us-east1-b          345d
$ kubectl describe pvc
Name:          elasticsearch-data-elasticsearch-data-us-east1-b-0
Namespace:     partners-production
StorageClass:  us-east1-b
Status:        Bound
Volume:      pvc-718681dd-70cc-11e7-aa14-42010af00029
Labels:       <none>
Annotations:   <none>
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      1Gi
Access Modes:  RWO
Events:        <none>
Mounted By:     test-pod

Pods using the PVC are shown with the Mounted By field

Which issue(s) this PR fixes:
Closes #65233

Special notes for your reviewer:

Release note:

Running `kubectl describe pvc` now shows which pods are mounted to the pvc being described with the `Mounted By` field
@clandry94

This comment has been minimized.

Copy link
Contributor Author

clandry94 commented Jul 5, 2018

/sig storage
/sig cli

@clandry94 clandry94 changed the title output which pods are using the pvc in use when kubectl describe is run output which pods are a pvc in use when kubectl describe pvc is run Jul 5, 2018

@idealhack

This comment has been minimized.

Copy link
Member

idealhack commented Jul 5, 2018

/ok-to-test

@clandry94

This comment has been minimized.

Copy link
Contributor Author

clandry94 commented Jul 5, 2018

/test pull-kubernetes-integration

@clandry94

This comment has been minimized.

Copy link
Contributor Author

clandry94 commented Jul 5, 2018

/test pull-kubernetes-e2e-kops-aws

@clandry94

This comment has been minimized.

Copy link
Contributor Author

clandry94 commented Jul 5, 2018

/assign @mengqiy

@idealhack

This comment has been minimized.

Copy link
Member

idealhack commented Jul 5, 2018

}

func getMountPods(c coreclient.PodInterface, pvcName string) ([]api.Pod, error) {
nsPods, err := c.List(metav1.ListOptions{})

This comment has been minimized.

@juanvallejo

juanvallejo Jul 5, 2018

Member

Maybe we should set a limit as part of ListOptions in order to chunk potentially large responses? Don't feel strongly on this though cc @soltysh

This comment has been minimized.

@clandry94

clandry94 Jul 6, 2018

Author Contributor

I don't see any other usages of limiting ListOptions for other describe operations, so I figure that it hasn't been an issue yet. I have no opinion on the matter though. If you think we should set a limit, I will.

This comment has been minimized.

@soltysh

soltysh Jul 6, 2018

Contributor

I don't expect that list to be that long, besides kubectl describe can and should be verbose. It's in the kubectl get where we try to save space with more... and similar.

@soltysh

soltysh approved these changes Jul 6, 2018

Copy link
Contributor

soltysh left a comment

/approve

Please squash your changes and we'll push it forward.

show pods using pvcs for kubectl describe
sort pods in kubectl describe pvc with user-defined alignment

@clandry94 clandry94 force-pushed the clandry94:pvc_describe_claimed_by branch from 0d53cfc to d956994 Jul 6, 2018

@clandry94

This comment has been minimized.

Copy link
Contributor Author

clandry94 commented Jul 6, 2018

squashed 👍

@juanvallejo

This comment has been minimized.

Copy link
Member

juanvallejo commented Jul 6, 2018

/lgtm

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Jul 6, 2018

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clandry94, juanvallejo, soltysh

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-github-robot

This comment has been minimized.

Copy link
Contributor

k8s-github-robot commented Jul 6, 2018

/test all [submit-queue is verifying that this PR is safe to merge]

@juanvallejo

This comment has been minimized.

Copy link
Member

juanvallejo commented Jul 6, 2018

/test pull-kubernetes-e2e-gce

@k8s-github-robot

This comment has been minimized.

Copy link
Contributor

k8s-github-robot commented Jul 6, 2018

Automatic merge from submit-queue (batch tested with PRs 65838, 65837). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 54db227 into kubernetes:master Jul 6, 2018

15 of 17 checks passed

Submit Queue Required Github CI test is not green: pull-kubernetes-e2e-gce
Details
pull-kubernetes-e2e-gce Job triggered.
Details
cla/linuxfoundation clandry94 authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-cross Skipped
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gke Skipped
pull-kubernetes-e2e-kops-aws Job succeeded.
Details
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce-big Job succeeded.
Details
pull-kubernetes-local-e2e Skipped
pull-kubernetes-local-e2e-containerized Skipped
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
@dsalamancaMS

This comment has been minimized.

Copy link

dsalamancaMS commented Jul 6, 2018

Amazing! thanks @clandry94 for making this happen!

@clandry94 clandry94 changed the title output which pods are a pvc in use when kubectl describe pvc is run output which pods are in use by a pvc when kubectl describe pvc is run Jul 6, 2018

@clandry94 clandry94 deleted the clandry94:pvc_describe_claimed_by branch Aug 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.