A CLI tool to display all dependencies or dependents of an object in a Kubernetes cluster.

Overview

kube-lineage

build release kubernetes compatibility helm compatibility license

A CLI tool to display all dependencies or dependents of an object in a Kubernetes cluster.

Usage

$ kube-lineage clusterrole system:metrics-server --output=wide
NAMESPACE     NAME                                                               READY   STATUS    AGE   RELATIONSHIPS
              ClusterRole/system:metrics-server                                  -                 30m   []
              └── ClusterRoleBinding/system:metrics-server                       -                 30m   [ClusterRoleBindingRole]
kube-system       └── ServiceAccount/metrics-server                              -                 30m   [ClusterRoleBindingSubject]
kube-system           ├── Pod/metrics-server-7b4f8b595-8m7rz                     1/1     Running   30m   [PodServiceAccount]
kube-system           │   └── Service/metrics-server                             -                 30m   [Service]
                      │       ├── APIService/v1beta1.metrics.k8s.io              True              30m   [APIService]
kube-system           │       └── EndpointSlice.discovery/metrics-server-wb2cm   -                 30m   [ControllerReference OwnerReference]
kube-system           └── Secret/metrics-server-token-nqw85                      -                 30m   [ServiceAccountSecret]
kube-system               └── Pod/metrics-server-7b4f8b595-8m7rz                 1/1     Running   30m   [PodVolume]

Use either the --dependencies or -D flag to show dependencies instead of dependents

$ kube-lineage pod coredns-5cc79d4bf5-xgvkc --dependencies
NAMESPACE     NAME                                                                   READY   STATUS         AGE
kube-system   Pod/coredns-5cc79d4bf5-xgvkc                                           1/1     Running        30m
              ├── Node/k3d-server                                                    True    KubeletReady   30m
              ├── PodSecurityPolicy/system-unrestricted-psp                          -                      30m
kube-system   ├── ConfigMap/coredns                                                  -                      30m
kube-system   ├── ReplicaSet/coredns-5cc79d4bf5                                      1/1                    30m
kube-system   │   └── Deployment/coredns                                             1/1                    30m
kube-system   ├── Secret/coredns-token-6vsx4                                         -                      30m
kube-system   │   └── ServiceAccount/coredns                                         -                      30m
              │       ├── ClusterRoleBinding/system:basic-user                       -                      30m
              │       │   └── ClusterRole/system:basic-user                          -                      30m
              │       ├── ClusterRoleBinding/system:coredns                          -                      30m
              │       │   └── ClusterRole/system:coredns                             -                      30m
              │       ├── ClusterRoleBinding/system:discovery                        -                      30m
              │       │   └── ClusterRole/system:discovery                           -                      30m
              │       ├── ClusterRoleBinding/system:public-info-viewer               -                      30m
              │       │   └── ClusterRole/system:public-info-viewer                  -                      30m
kube-system   │       └── RoleBinding/system-unrestricted-svc-acct-psp-rolebinding   -                      30m
              │           └── ClusterRole/system-unrestricted-psp-role               -                      30m
              │               └── PodSecurityPolicy/system-unrestricted-psp          -                      30m
kube-system   └── ServiceAccount/coredns                                             -                      30m

Use the helm subcommand to display Helm release resources & optionally their respective dependents in a Kubernetes cluster.

$ kube-lineage helm kube-state-metrics -n monitoring-system
helm kube-state-metrics -n monitoring-system
NAMESPACE           NAME                                                             READY   STATUS     AGE
monitoring-system   kube-state-metrics                                               True    Deployed   25m
                    ├── ClusterRole/kube-state-metrics                               -                  25m
                    │   └── ClusterRoleBinding/kube-state-metrics                    -                  25m
monitoring-system   │       └── ServiceAccount/kube-state-metrics                    -                  25m
monitoring-system   │           ├── Pod/kube-state-metrics-7dff544777-jb2q2          1/1     Running    25m
monitoring-system   │           │   └── Service/kube-state-metrics                   -                  25m
monitoring-system   │           │       └── EndpointSlice/kube-state-metrics-rq8wk   -                  25m
monitoring-system   │           └── Secret/kube-state-metrics-token-bsr4q            -                  25m
monitoring-system   │               └── Pod/kube-state-metrics-7dff544777-jb2q2      1/1     Running    25m
                    ├── ClusterRoleBinding/kube-state-metrics                        -                  25m
monitoring-system   ├── Deployment/kube-state-metrics                                1/1                25m
monitoring-system   │   └── ReplicaSet/kube-state-metrics-7dff544777                 1/1                25m
monitoring-system   │       └── Pod/kube-state-metrics-7dff544777-jb2q2              1/1     Running    25m
monitoring-system   ├── Secret/sh.helm.release.v1.kube-state-metrics.v1              -                  25m
monitoring-system   ├── Service/kube-state-metrics                                   -                  25m
monitoring-system   └── ServiceAccount/kube-state-metrics

$ kube-lineage helm traefik --depth 1 --label-columns app.kubernetes.io/managed-by --label-columns owner
NAMESPACE     NAME                                       READY   STATUS     AGE   MANAGED-BY   OWNER
kube-system   traefik                                    True    Deployed   30m
              ├── ClusterRole/traefik                    -                  30m   Helm
              ├── ClusterRoleBinding/traefik             -                  30m   Helm
kube-system   ├── ConfigMap/traefik                      -                  30m   Helm
kube-system   ├── ConfigMap/traefik-test                 -                  30m   Helm
kube-system   ├── Deployment/traefik                     1/1                30m   Helm
kube-system   ├── Secret/sh.helm.release.v1.traefik.v1   -                  30m                helm
kube-system   ├── Secret/traefik-default-cert            -                  30m   Helm
kube-system   ├── Service/traefik                        -                  30m   Helm
kube-system   ├── Service/traefik-prometheus             -                  30m   Helm
kube-system   └── ServiceAccount/traefik                 -                  30m   Helm

Use either the split or split-wide output format to display resources grouped by their type.

$ kube-lineage deploy/coredns --output=split --show-group
NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/coredns   3/3     3            3           30m

NAME                                            ADDRESSTYPE   PORTS        ENDPOINTS                          AGE
endpointslice.discovery.k8s.io/kube-dns-mz9bw   IPv4          53,9153,53   10.42.0.24,10.42.0.26,10.42.0.27   30m

NAME                           READY   STATUS    RESTARTS   AGE
pod/coredns-5cc79d4bf5-xgvkc   1/1     Running   0          30m
pod/coredns-5cc79d4bf5-rjc7d   1/1     Running   0          30m
pod/coredns-5cc79d4bf5-tt2zl   1/1     Running   0          30m

NAME                                 DESIRED   CURRENT   READY   AGE
replicaset.apps/coredns-5cc79d4bf5   3         3         3       30m

NAME               TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE
service/kube-dns   ClusterIP   10.43.0.10   <none>        53/UDP,53/TCP,9153/TCP   30m

Flags

Flags for configuring relationship discovery parameters

Flag Description
--all-namespaces, -A If present, list object relationships across all namespaces
--dependencies, -D If present, list object dependencies instead of dependents.
Not supported in helm subcommand
--depth, -d Maximum depth to find relationships
--scopes, -S Accepts a comma separated list of additional namespaces to find relationships.
You can also use multiple flag options like -S namespace1 -S namespace2...

Flags for configuring output format

Flag Description
--output, -o Output format. One of: wide | split | split-wide
--label-columns, -L Accepts a comma separated list of labels that are going to be presented as columns.
You can also use multiple flag options like -L label1 -L label2...
--no-headers When using the default output format, don't print headers
--show-group If present, include the resource group for the requested object(s)
--show-label When printing, show all labels as the last column
--show-namespace When printing, show namespace as the first column

Use the following commands to view the full list of supported flags

$ kube-lineage --help
$ kube-lineage helm --help

Supported Relationships

List of supported relationships used for discovering dependent objects:

Installation

Install via krew

$ kubectl krew install lineage

$ kubectl lineage --version

Install from Source

$ git clone [email protected]:tohjustin/kube-lineage.git && cd kube-lineage
$ make install

$ kube-lineage --version

Prior Art

kube-lineage has been inspired by the following projects:

You might also like...
A minimal CLI tool to enable (or disable) dependabot for all your repositories

Enable Dependabot A minimal CLI tool to enable (or disable) dependabot for all your repositories. Installation Install via Go go get -v github.com/RiR

A client-side agent that connects any Kubernetes cluster to AWS
A client-side agent that connects any Kubernetes cluster to AWS

EKS Connector EKS Connector is a client-side agent that connects any Kubernetes cluster to AWS. How it works EKS Connector runs in Kubernetes as a Pod

gomUP is a tool to keep track of outdated dependencies and upgrade them to the latest version
gomUP is a tool to keep track of outdated dependencies and upgrade them to the latest version

gomUP 🆙 gomUP is a tool to keep track of outdated dependencies and upgrade them to the latest version. Designed for monorepo Go projects and Go proje

A cutting edge (haha), prototype, object-oriented and highly modular slash command handler for Discordgo.
A cutting edge (haha), prototype, object-oriented and highly modular slash command handler for Discordgo.

ken ⚠️ Disclaimer This package is still in a very early state of development and future updates might include breaking changes to the API until the fi

Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

A cli program unlocks all cheats in The Sims 1
A cli program unlocks all cheats in The Sims 1

Sims 1 Cheat Unlocker This is a cli program unlocks all cheats in The Sims 1. It was tested against the base Sims 1 and the Complete Collection, so it

Code and slides from the talk "A golang CLI to rule them all" at JavaZone 2021

A Golang CLI to rule them all This is a repo for the slides and the code that were showed at the presentation with the same title at the JavaZone conf

The Emojinator CLI: for all your emojipasta needs 🦾😎

🦾 😎 The Emojinator ALL YOUR emojipasta 🍝 ARE BELONG TO US. This command line tool has one main purpose: turn your files into emojipasta by specifyi

cli tools for list all pages in logseq repo, marked with public or private

logseq-pages A cli tool for list all pages in logseq repo, marked with public or private. When I using logseq to build my knowledge base and publish p

Comments
  • Allow excluding events

    Allow excluding events

    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

    opened by vrabbi 10
  • Add license scan report and status

    Add license scan report and status

    Your FOSSA integration was successful! Attached in this PR is a badge and license report to track scan status in your README.

    Below are docs for integrating FOSSA license checks into your CI:

    opened by fossabot 0
  • Query for multiple root elements by label

    Query for multiple root elements by label

    Thanks so much for your great work here!!!

    Use Case

    It'd be so amazing if there were the ability to query by label for "multiple root elements". For example say we have multiple objects all correlated by label, but with their own lineage's below them. They are related and I'd like to view them all at the same time, with a single query.

    Rough proposed API

    kubectl lineage --selector app=my-awesome-app as an example Shorthand being -l

    Rough result

    Query for elements that don't have owner-refs and define them as "roots" and apply the standard algorithm and render from there.

    opened by alexbarbato 9
Releases(v0.5.0)
Owner
Justin Toh
YAML Engineer
Justin Toh
CLI tool to upload object to s3-compatible storage backend and set download policy for it.

typora-s3 CLI tool to upload object to s3-compatible storage backend and set download policy for it. Build $ git clone https://github.com/fengxsong/ty

fengxsong 0 Dec 29, 2021
The Keel CLI allows you to setup Keel on your local dev machine or on a Kubernetes cluster

keel-cli What is keel-cli The Keel CLI allows you to setup Keel on your local dev machine or on a Kubernetes cluster, launches and manages Keel instan

null 0 Oct 7, 2021
The Dapr CLI allows you to setup Dapr on your local dev machine or on a Kubernetes cluster

Dapr CLI The Dapr CLI allows you to setup Dapr on your local dev machine or on a

null 1 Dec 23, 2021
word2text - a tool is to convert word documents (DocX) to text on the CLI with zero dependencies for free

This tool is to convert word documents (DocX) to text on the CLI with zero dependencies for free. This tool has been tested on: - Linux 32bit and 64 bit - Windows 32 bit and 64 bit - OpenBSD 64 bit

Ryan Thomas 5 Apr 19, 2021
Display a message in morse code on your capslock LED, keyboard backlight or using your screen brightness!

halp halp is a command line utility that lets you display messages in morse code on your capslock LED, keyboard backlight (if you have it) or using yo

Madhav Jivrajani 25 Jan 26, 2022
gif effects CLI. single binary, no dependencies. linux, osx, windows.

yeetgif Composable GIF effects CLI, with reasonable defaults. Made for custom Slack/Discord emoji :) Get it Alternative 1: go get Alternative 2: just

Sergey Grebenshchikov 527 Nov 23, 2022
A tool to manage all your boilerplate from cli and generate files for you !

A tool to manage all your boilerplate from cli and generate files for you !

null 28 Jul 20, 2022
CLI tool to update ~/.aws/config with all accounts and permission sets defined in AWS SSO

aws-sso-profiles Generate or update ~/.aws/config with a profile for each SSO account you have access to, by using an existing AWS SSO session. Bootst

SpareBank 1 Utvikling 3 Nov 3, 2022
Azure-nuke - The CLI tool to delete all resources in an Azure Account

azure-nuke This repository would contain the CLI tool to delete all resources in

Hrittik Roy 3 Jun 8, 2022
Github-org-diff - Simple CLI tool to check a diff between 2 branches of all org repos

github-org-diff Simple CLI tool to list org repos that have diff between dev and

Alex Pliutau 1 Jan 25, 2022