steveteuber / kubectl-graph

A kubectl plugin to visualize Kubernetes resources and relationships.
Apache License 2.0
589 stars 29 forks source link

Feature Request #11

Closed alanmbarr closed 2 years ago

alanmbarr commented 2 years ago

Any possibility to include labels as part of the graph data?

steveteuber commented 2 years ago

Hi @alanmbarr,

Thank you for opening this issue. Do you have already an idea how it should looks like?

alanmbarr commented 2 years ago

Great question Steve. I haven't done a lot of research so I don't know what this naive recommendation could mess with. In my case, I have some applications that I label and I want to separate those from others that are third parties or system namespaces. Looking at the output cypher query I was thinking something like below.

node.Name = "myapp-6dc474598f-c86rp", node.App_kubernetes_io_name = "myapp";

Other labels would be properties on the node.

These are some other labels that appear when I use kubectl describe. app.kubernetes.io/instance=myapp app.kubernetes.io/name=myapp app.website.com/name=myapp app.website.com/version=0.12.1 linkerd.io/control-plane-ns=linkerd linkerd.io/proxy-deployment=myapp linkerd.io/workload-ns=myapp

steveteuber commented 2 years ago

Thanks for the examples. I'll take a look into it.

steveteuber commented 2 years ago

Hey @alanmbarr,

I checked it out last night and I will prefix the node properties with Label_:

node.Name = "myapp-6dc474598f-c86rp", node.Label_app_kubernetes_io_name = "myapp";

This has the advantage that a label can't override the node.Name and we can add the annotations as well.

alanmbarr commented 2 years ago

That's great I think that is a smart approach.

steveteuber commented 2 years ago

Done. Please upgrade the plugin to the latest version:

$ kubectl krew upgrade graph           
Updated the local copy of plugin index.
  Upgrades available for installed plugins:
    * graph v0.3.0 -> v0.3.1
Upgrading plugin: graph
Upgraded plugin: graph