kraph

package module
v0.0.0-...-0bc4b66 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

THIS IS a PoC

GoDoc Go Report Card License Travis CI

kraph

kraph is an experimental Go module that allows to build a graph of API objects. The resulting graph can be represented as gonum.Graph which allows for advanced graph analysis!

You can query the resulting graph nodes and edges based on various attributes. Equally, you can also retrieve a subgraph of the graph starting with a chosen node and perform further analysis on it.

At the moment only kubernetes API object graph is implemented, but the module [hopefully] defines pluggable interfaces which should allow for adding the support for arbitrary APIs, such as AWS etc.

Getting started

The project provides a simple Makefile which makes basic tasks, such as running tests and building the module simple:

Get dependencies:

make dep

Run tests:

make test

Build module:

make build

kctl

There is also a simple command line utility which allows to build and query API object graphs in-memory and display the results.

At the moment it only provides build command with kubernetes/k8s subcommand which allows to build and query the kubernetes API object graph.

HOWTO

Run kctl make task to build the kctl binary:

Build:

make kctl

kctl command line options:

$ ./kctl help
NAME:
   kctl - build and query API object graphs

USAGE:
   kctl [global options] command [command options] [arguments...]

COMMANDS:
   build    build a graph
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help (default: false)

kctl allows to dump the graph in DOT GraphViz format. This can be piped into GraphViz tool for further processing. kctl is in the pre-alpha state (if it can be called that at all!) and it's more of a debugging help tool at the moment as the focus of the project is the API graph mapping.

NOTE: You must have kubeconfig properly configured.

$ ./kctl build k8s -format "dot" | dot -Tsvg > cluster.svg && open cluster.svg

NOTE: dot format is the only available and default format so you can get the same results as above by running the command below, too:

$ ./kctl build k8s | dot -Tsvg > cluster.svg && open cluster.svg

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter func(api.Object) bool

type Kraph

type Kraph interface {
	// Build builds a graph and returns graph store
	Build(api.Client, ...Filter) (store.Graph, error)
	// Store returns graph store
	Store() store.Store
}

Kraph builds a graph of API objects

func New

func New(opts ...Option) (Kraph, error)

New creates new kraph and returns it

type Option

type Option func(*Options)

Option is functional kraph option

func Store

func Store(s store.Store) Option

Store configures kraph store

type Options

type Options struct {
	Store store.Store
}

Options are kraph options

func NewOptions

func NewOptions() (*Options, error)

NewOptions creates default options and returns it

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL