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

[Question] How do you find out what a pod belongs to (Rep. Controller, Deployment, Replica Set, etc.? #32051

Closed
jason-riddle opened this issue Sep 4, 2016 · 6 comments

Comments

@jason-riddle
Copy link
Contributor

Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see http://kubernetes.io/docs/troubleshooting/.): No

What keywords did you search in Kubernetes issues before filing this one? (If you have found any duplicates, you should instead reply there.): It's a bit tough to search for this since this includes a lot of keywords.


Is this a BUG REPORT or FEATURE REQUEST? (choose one): Question

Pretty much what the title says. I'm asking because sometimes I want to kill a pod for good but I don't remember what I used to create it.

@adohe-zz
Copy link

adohe-zz commented Sep 5, 2016

@jason-riddle I think you could check the created-by annotation of pod.

@jason-riddle
Copy link
Contributor Author

@adohe But that's assuming it was set in the first place which I didn't do. However, your suggestion lead to the following.

With the describe call, you can just grep for Controllers.

kubectl describe pods dd-agent-4qwo1 | grep Controllers
# Controllers:      DaemonSet/dd-agent

In the case of a lone pod running, Controllers will be empty.

kubectl describe pods apache | grep Controllers
# Controllers:      <none>

Thanks!

@abhishekanne
Copy link

Worked for me:

kubectl describe pod <Podname> -n <namespace> | grep "Controlled By"

@ye
Copy link

ye commented Feb 17, 2021

Grep'ing Controlled By works with the latest version of the Kubernetes client and server as of this note while grep'ing Controllers no longer works as at some point the pod manifest has changed to print "Controlled By" instead of "Controllers".

$ kubenetes version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.15", GitCommit:"73dd5c840662bb066a146d0871216333181f4b64", GitTreeState:"clean", BuildDate:"2021-01-13T13:22:41Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.12-gke.1206", GitCommit:"4ad64c148c8fa54132c0730a4838c7b5e4e1b342", GitTreeState:"clean", BuildDate:"2021-01-25T20:33:15Z", GoVersion:"go1.13.15b4", Compiler:"gc", Platform:"linux/amd64"}

@scardena
Copy link

using jsonpath can help too, if you want to check for more than 1:

kubectl  get pods -o jsonpath="{range .items[*]}{.metadata.name}{'-> Controlled by ->'}{.metadata.ownerReferences[0].kind}{': '}{.metadata.ownerReferences[0].name}{'\n'}"

@jwilleke
Copy link

So the question is how to determine the "Deployment"?

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

No branches or pull requests

7 participants