How to quickly query/verify if a pod is "bare pod" or a pod supported by replication controller?

1

In OKD v3.11, how to find out if pods running on a node are under the control of replication controller. Is there an oc command or console feature that quickly find the information? Thanks,

DXY

Posted 2019-10-25T16:37:15.587

Reputation: 11

Answers

0

You can relly on the ownerReferences API object to find this:

$ kubectl explain pod.metadata.ownerReferences

KIND: Pod

VERSION: v1

RESOURCE: ownerReferences <[]Object>

DESCRIPTION: List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.

Bare pods (i.e., pods without controllers/owners) will not contain the ownerReferences field, so you can use the --custom-columns to find out which pods are controlled or not:

$ kubectl get pods --all-namespaces -o custom-columns=NAME:.metadata.name,CONTROLLER:.metadata.ownerReferences[].kind,NAMESPACE:.metadata.namespace
NAME                               CONTROLLER   NAMESPACE
nginx-85ff79dd56-tvpts             ReplicaSet   default
static-pod1                        <none>       default
static-pod2                        <none>       default
coredns-5644d7b6d9-6hg82           ReplicaSet   kube-system
coredns-5644d7b6d9-wtph7           ReplicaSet   kube-system
etcd-minikube                      <none>       kube-system
kube-addon-manager-minikube        <none>       kube-system
kube-apiserver-minikube            <none>       kube-system
kube-controller-manager-minikube   <none>       kube-system
kube-proxy-fff5c                   DaemonSet    kube-system
kube-scheduler-minikube            <none>       kube-system
storage-provisioner                <none>       kube-system
tiller-deploy-55c9c4b4df-hgzwm     ReplicaSet   kube-system

Eduardo Baitello

Posted 2019-10-25T16:37:15.587

Reputation: 178