tohjustin/kube-lineage

Allow excluding events

vrabbi opened this issue ยท 10 comments

i love the plugin and use it alot! the one issue i have is that when running this on a long living object which either it or dependent objects have lots of historical events, the output is unclear and an event can and very often is tansient (for example waiting for PV etc.).

is it possible to have a flag that would allow filtering out resources shown in the tree something like:
kubectl lineage deployment/demo-app --exclude=events

or even one that would be specific to events:
kubectl lineage deployment/demo-app --exclude-events=true

Hi @vrabbi, really glad you love this plugin!

I can definitely see how having too many events would be annoying & cause the output to be difficult to grok. Your suggestion makes a lot of sense & I think we should definitely have flag(s) to filter objects ๐Ÿ™‚

I actually had something similar in my feature backlog & here's what they roughly look like:

  1. --exclude-relationship flag to ignore certain types of relationships when printing dependencies & dependents

    # Show all dependencies of an object in a Kubernetes cluster
    # that aren't based on `OwnerReference` relationship
    kubectl lineage pod/demo-app-XXXXX-XXXXX --dependencies --exclude-relationship=OwnerReference
    
    # Show all dependents of an object in a Kubernetes cluster
    # that aren't based on `EventRegarding` & `EventRelated` relationship
    kubectl lineage deploy/demo-app --exclude-relationship=EventRegarding,EventRelated
  2. --include-relationship flag to only account for certain types of relationships when printing dependencies & dependents

    # Show all dependencies of an object in a Kubernetes cluster,
    # which are based on `OwnerReference` relationship
    kubectl lineage pod/demo-app-XXXXX-XXXXX --dependencies --include-relationship=OwnerReference
    
    # Show all dependents of an object in a Kubernetes cluster,
    # which are based on both `EventRegarding` & `EventRelated` relationship
    kubectl lineage deploy/demo-app --include-relationship=EventRegarding,EventRelated
  3. --exclude-kind flag to ignore certain kinds of objects when printing dependencies & dependents

    # Show all dependents of an object in a Kubernetes cluster,
    # excluding `Event` objects
    kubectl lineage deploy/demo-app --exclude-kind=Event
    
    # Show all dependencies of an object in a Kubernetes cluster,
    # excluding `ReplicaSet` & `Deployment` objects
    kubectl lineage pod/demo-app-XXXXX-XXXXX --dependencies --exclude-kind=replicaset,deploy
  4. --include-kind flag to only account for certain kinds of objects when printing dependencies & dependents

    # Show all dependents of an object in a Kubernetes cluster,
    # including only `Event` objects
    kubectl lineage deploy/demo-app --include-kind=event.events.k8s.io
    
    # Show all dependencies of an object in a Kubernetes cluster,
    # including only `ReplicaSet` & `Deployment` objects
    kubectl lineage pod/demo-app-XXXXX-XXXXX  --dependencies --include-kind=rs,deployment.apps

I think example 1 & example 3 above should be able to solve the issue that you're experiencing. ๐Ÿค” Do let me know what are your thoughts on this!

love the examples!
for me option 3 would be the best but all features seem great and option 1 would solve my issue as well.

@vrabbi That's great! I'll see if I can push out a release this week for this ๐Ÿ™๐Ÿผ

Any updates on when this will be available? Just want to get a general idea so i can plan around this for some work im planning and demos.

Hi @vrabbi, sorry have been busy lately ๐Ÿ™๐Ÿผ

I can try to prioritise in getting support for --exclude-kind out for the next release (probably by end of this week?) before working on the rest, would that help? ๐Ÿ˜…

No issues. If that is possible that would be amazing!

Hi @vrabbi, the feature is more or less completed (the --exclude-kind flag that we discussed earlier is renamed to --exclude-types instead), I'm just left with testing it out a bit more!

# Show all dependents of an object in a Kubernetes cluster,
# excluding `Event` objects
kubectl lineage deploy/demo-app --exclude-types=Event

# Show all dependencies of an object in a Kubernetes cluster,
# excluding `Event`, `ReplicaSet` & `Deployment` objects
kubectl lineage pod/demo-app-XXXXX-XXXXX --dependencies --exclude-types=ev,replicaset,Deployment
kubectl lineage pod/demo-app-XXXXX-XXXXX --dependencies --exclude-types ev --exclude-types replicaset --exclude-types Deployment

To match your initial example used in the issue, any of the following commands should exclude Event resource types from the lineage output:

kubectl lineage deployment/demo-app --exclude-types=ev
kubectl lineage deployment/demo-app --exclude-types=ev.events.k8s.io
kubectl lineage deployment/demo-app --exclude-types=event
kubectl lineage deployment/demo-app --exclude-types=event.events.k8s.io
kubectl lineage deployment/demo-app --exclude-types=events
kubectl lineage deployment/demo-app --exclude-types=events.events.k8s.io
kubectl lineage deployment/demo-app --exclude-types=Event
kubectl lineage deployment/demo-app --exclude-types=Event.events.k8s.io
kubectl lineage deployment/demo-app --exclude-types=Events
kubectl lineage deployment/demo-app --exclude-types=Events.events.k8s.io

We should be on track for a v0.5.0 release this week! ๐Ÿ˜„

Amazing!!!!!!! Thanks for the awesome work!!!!! Cant wait to use this!!!!!!

@vrabbi v0.5.0 is out! You can view the changelog for this release over at https://github.com/tohjustin/kube-lineage/releases/tag/v0.5.0.

Do let me know if you encounter any bugs or issue with this new feature! ๐Ÿ™๐Ÿผ

Awesome!!!! Thank you!!!!