Giter VIP home page Giter VIP logo

kubegraph's Introduction

Kubegraph

Yet another kubernetes resource graph generator

Kubegraph sample

Status GitHub Issues GitHub Pull Requests

pre-commit.ci status Maintainability Test Coverage

License FOSSA Status CII Best Practices

Docker Image Size (latest semver) Docker Image Version (latest semver) Docker Pulls


๐Ÿ“ Table of Contents

๐Ÿง About

Kubegraph is a CLI tool that parses kubernetes resources and generates a graph with the relations between those. The graph is done using Graphviz, and can be further customized after generation.

๐Ÿ Getting Started

Fetch the dependencies and build with

make build

Prerequisites

Kubegraph is done using Golang 1.15, using a pure Go graphviz implementation to generate the graph.

Everything is set as a direct dependency, and go mod vendor will install for you.

Installing

It can be installed using standard go install

go install ./...

Then, if you have GOPATH on your path, you can call kubepath directly anywhere.

๐Ÿ”ง Running the tests

WIP, there's no tests yet ๐Ÿ˜ž

๐ŸŽˆ Usage

kubegraph my-multidoc.yaml

or using the docker image

docker run --rm -it -v ${PWD}:/home/kubegraph wwmoraes/kubegraph:latest my-multidoc.yaml

On this example, a my-multidoc.dot file will be generated, alongside with an icons folder used by the graph. You can convert it to an image using dot, e.g.

dot -Tsvg -o my-multidoc.svg my-multidoc.dot

If your graphviz installation has been compiled with pango, cairo and rsvg, you'll also be able to generate static formats as png or jpeg. Do note that currently kubegraph uses svg icons, and cairo mess up when generating raster images with those (namely they'll either look blurred or won't be drawn at all). A future version will address this by using raster icons.

How to add support for a single/suite of custom resource definitions

First, import the scheme and add it to client-go's scheme on internal/loader/getDecoder.go@init:

import (
  "k8s.io/client-go/kubernetes/scheme"
  // import the target scheme
  myAwesomeScheme "githost.com/owner/repository/pkg/client/clientset/scheme"
)

func init() {
  // add the scheme to client-go's scheme
  _ = myAwesomeScheme.AddToScheme(scheme.Scheme)
}

then:

  1. vendor it with go mod vendor to update go.mod and go.sum

  2. add adapters for the kinds on that scheme at internal/adapters/<api-group>/<api-version>. You can copy from an existing one, or use the internal/adapters/dummy/v1/dummy.go as a guide.

  3. import your API versions on the group level (check internal/adapters/dummy/dummy.go)

  4. import the group on the top level on internal/adapters/adapters.go

  5. [optional, recommended] add a SVG icon for the new kinds on icons/ and set it on your adapter's Create function, on the call to statefulGraph.AddStyledNode

  6. regenerate the icons embedded asset module with make icons

  7. commit and profit :D

๐Ÿ›  Built Using

๐Ÿง‘โ€๐Ÿ’ป Authors

๐ŸŽ‰ Acknowledgements

  • Kubernetes sigs members for the excellent abstractions and interfaces available on Golang
  • @damianopetrungaro for the honest reviews and patience

kubegraph's People

Contributors

wwmoraes avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.