Determining Object Relations

I need to use a lot of the Kubernetes API through its Java implementation.

I found that objects are generally very detached and seemingly unrelated, even though they in reality are related.

For example:

How do I find the correct relation to a Deployment from a V1Pod or any of its sub-objects?

How do I find the correct relation to a list of Deployments from a V1Node or any of its sub-objects?

All I can do is query pods and focus on pods. Or query nodes and focus on nodes. Or query deployments and focus on deployments. As long as this rule is followed, everything is so simple.

However, whenever I try to manifest relations between objects, I have to hack my way through it.

Is there a best practice way of mapping relations between object?

Node -> Deployments
Deployment -> Pods

We have developed a tool - KubePlus - that solves this problem. It build resource relationship graphs of Kubernetes resources. Check it out:

KubePlus provides a kubectl plugin (kubectl connections) to discover the relationships between resources. You can install KubePlus kubectl plugins and invoke the kubectl connections from within your Java program.

Hope this helps.