-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
How to find out whether a pod belongs to statefulset/deployment/replica-set #78181
Comments
/sig API-Machinery |
I would use selector(pod's label) to retrieve all relevant replica set(kind field from pod's owner reference), and then use owner reference to further narrow it down |
kubernetes/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go Lines 315 to 319 in 1c10061
the in-tree fields from |
Yes, this is what I described in last post, but how can I filter it via k8s pysdk, or only have to list all pod and resolve it by myself? |
sadly, yes. the good news is that we can do pagination so that list chunks won't jam the traffic. |
Pod has UID attribute. If the pod belongs to other object such as Job, Deployment, statefulset, the "controller-uid" is set in Pod's Labels. You can compare these 2 fields. func getPodControlID(pod *corev1.Pod) string {
} |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
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. |
how can I use kubenetes client-sdk to figure out whether a pod belongs to statefulset/deployment/replica-set?
the same issue as this, but that method does not work, also
kubectl describe pod
is not the same askubectl get pods
What I can find is, for a pod belong to a high-level controller, it will have
metadata.generateName
andmetadata.ownerReferences
. Unfortunately, it is not supported viaField Selectors
.So how can I filter it out?
The text was updated successfully, but these errors were encountered: