{"id":13521967,"url":"https://github.com/steveteuber/kubectl-graph","last_synced_at":"2025-05-14T11:09:59.609Z","repository":{"id":39409630,"uuid":"240712313","full_name":"steveteuber/kubectl-graph","owner":"steveteuber","description":"A kubectl plugin to visualize Kubernetes resources and relationships.","archived":false,"fork":false,"pushed_at":"2025-04-28T17:01:57.000Z","size":1172,"stargazers_count":629,"open_issues_count":3,"forks_count":32,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-28T18:22:20.029Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/steveteuber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-15T13:00:44.000Z","updated_at":"2025-04-28T17:02:00.000Z","dependencies_parsed_at":"2023-02-19T06:55:16.491Z","dependency_job_id":"c7574d86-047d-4316-81b8-0169addc0c16","html_url":"https://github.com/steveteuber/kubectl-graph","commit_stats":{"total_commits":214,"total_committers":4,"mean_commits":53.5,"dds":0.3551401869158879,"last_synced_commit":"ebf6f9589b6880272e269fcf2de495124d9c437a"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steveteuber%2Fkubectl-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steveteuber%2Fkubectl-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steveteuber%2Fkubectl-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steveteuber%2Fkubectl-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steveteuber","download_url":"https://codeload.github.com/steveteuber/kubectl-graph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254129489,"owners_count":22019628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T06:00:40.391Z","updated_at":"2025-05-14T11:09:59.587Z","avatar_url":"https://github.com/steveteuber.png","language":"Go","funding_links":[],"categories":["Containers","others","Go","kubectl Plugins","Generation Tools"],"sub_categories":["Kubernetes","Installing plugins via awesome-kubectl-plugins","Comparing generated diagrams"],"readme":"# kubectl-graph\n\n[![License](https://img.shields.io/github/license/steveteuber/kubectl-graph)](https://github.com/steveteuber/kubectl-graph/blob/main/LICENSE)\n[![Go Report Card](https://goreportcard.com/badge/github.com/steveteuber/kubectl-graph)](https://goreportcard.com/report/github.com/steveteuber/kubectl-graph)\n[![Workflow Status](https://img.shields.io/github/actions/workflow/status/steveteuber/kubectl-graph/ci.yml?branch=main)](https://github.com/steveteuber/kubectl-graph/actions/workflows/ci.yml?query=branch:main)\n[![GitHub Issues](https://img.shields.io/github/issues/steveteuber/kubectl-graph)](https://github.com/steveteuber/kubectl-graph/issues)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/steveteuber/kubectl-graph)](https://github.com/steveteuber/kubectl-graph/blob/main/go.mod#L3)\n[![Latest Release](https://img.shields.io/github/v/release/steveteuber/kubectl-graph)](https://github.com/steveteuber/kubectl-graph/releases/latest)\n\nA kubectl plugin to visualize Kubernetes resources and relationships.\n\n## Prerequisites\n\nThis plugin requires [Graphviz](https://graphviz.org), [Neo4j](https://neo4j.com) *or* [ArangoDB](https://www.arangodb.com) to visualize the dependency graph.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eGraphviz\u003c/strong\u003e\u003c/summary\u003e\u003cbr\u003e\n\nThe *default* output format requires `dot` to convert the output into a useful format.\n\n```\nbrew install graphviz\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eNeo4j\u003c/strong\u003e\u003c/summary\u003e\u003cbr\u003e\n\nThe *CQL* output format requires `cypher-shell` to connect to a Neo4j database.\n\n```\nbrew install cypher-shell\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eArangoDB\u003c/strong\u003e\u003c/summary\u003e\u003cbr\u003e\n\nThe *AQL* output format requires `curl` and `jq` to send API requests to an ArangoDB server.\n\n```\nbrew install curl jq\n```\n\u003c/details\u003e\n\n\u003csup\u003eDo you miss something? Please open an issue or create a pull request.\u003c/sup\u003e\n\n## Installation\n\nThis `kubectl` plugin is distributed via [krew](https://krew.sigs.k8s.io). To install it, run the following command:\n\n```\nkubectl krew install graph\n```\n\n## Usage\n\nIn general, this plugin is working like `kubectl get` but it tries to resolve relationships between the Kubernetes\nresources before it prints a graph in `AQL`, `CQL` *or* `DOT` format. By default, the plugin will use `DOT` as output format.\n\n```\nkubectl graph [(-o|--output=)aql|arangodb|cql|cypher|dot|graphviz|mermaid] (TYPE[.VERSION][.GROUP] ...) [flags]\n```\n\n## Quickstart\n\nThis quickstart guide uses macOS. It's possible that the commands can differ on other operating systems.\n\n### Graphviz\n\n![Graphviz Logo](assets/graphviz-logo.png)\n\nWhen you have installed the `dot` command line tool, then you can start to fetch all running Pods in the\n`kube-system` namespace and pipe the output directly to the `dot` command.\n\n```\nkubectl graph pods --field-selector status.phase=Running -n kube-system | dot -T svg -o pods.svg\n```\n\nNow you will have a `pods.svg` file in the current working directory, which can be viewed with any web browser:\n\n```\nopen pods.svg\n```\n\nIf you're not happy with SVG as output format, please take a look at the offical [documentation](https://graphviz.org/doc/info/output.html).\n\n### Neo4j\n\n![Neo4j Logo](assets/neo4j-logo-light.png#gh-dark-mode-only)\n![Neo4j Logo](assets/neo4j-logo-dark.png#gh-light-mode-only)\n\nBefore you can import all your Kubernetes resources, you will need to create a Neo4j database.\\\nThis can be done in multiple ways and is based on your preference.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eDocker\u003c/strong\u003e\u003c/summary\u003e\u003cbr\u003e\n\n[Docker](https://docs.docker.com/get-started/) is the easiest way to get started with a Neo4j server and an empty database.\n\n```\ndocker run --rm -p 7474:7474 -p 7687:7687 -e NEO4J_AUTH=neo4j/secret neo4j\n```\n\nWhen the container is up and running then you can open the Neo4j Browser interface at http://localhost:7474/.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eNeo4j Desktop\u003c/strong\u003e\u003c/summary\u003e\u003cbr\u003e\n\nThe [Neo4j Desktop](https://neo4j.com/developer/neo4j-desktop/) application lets you easily create any number of local databases.\n\n```\nbrew install --cask neo4j\n```\n\nAfter installation, open the `Neo4j Desktop.app` and do the following steps:\n\n1. Create a new project and give it a name.\n2. Create a new local DBMS with a name like `quickstart` and password `secret`.\n3. Click Start and enter the password.\n4. When the database is up and running then you can click Open to open the Neo4j Browser interface.\n\n![Neo4j Desktop](assets/neo4j-desktop.png)\n\u003c/details\u003e\n\nWhen you have opened the Neo4j Browser interface, then you can start to fetch all resources in the\n`kube-system` namespace and pipe the output directly to the `cypher-shell` command.\n\n```\nkubectl graph all -n kube-system -o cypher | cypher-shell -u neo4j -p secret\n```\n\nFinally, within the Neo4j Browser interface you can enter the following queries in the command line:\n\n```\nMATCH (n) RETURN n         // Render all nodes as a visual graph\nMATCH (n) DETACH DELETE n  // Delete all nodes and relationships\n```\n\nFor more information about the Cypher query language, please take a look at the offical [documentation](https://neo4j.com/docs/cypher-manual/current/clauses/).\n\n### ArangoDB\n\n![ArangoDB Logo](assets/arangodb-logo-light.png#gh-dark-mode-only)\n![ArangoDB Logo](assets/arangodb-logo-dark.png#gh-light-mode-only)\n\nBefore you can import all your Kubernetes resources, you will need to create an ArangoDB database.\\\nThis can be done in multiple ways and is based on your preference.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eDocker\u003c/strong\u003e\u003c/summary\u003e\u003cbr\u003e\n\n[Docker](https://docs.docker.com/get-started/) is the easiest way to get started with an ArangoDB server and an empty database.\n\n```\ndocker run --rm -p 8529:8529 -e ARANGO_NO_AUTH=1 arangodb\n```\n\nWhen the container is up and running then you can open the ArangoDB Browser interface at http://localhost:8529/.\n\u003c/details\u003e\n\nIf you start with an empty database you need to create two collections one for resources and one for relationships.\n\n```\ncurl http://localhost:8529/_api/collection -d '{\"type\": 2, \"name\": \"resources\"}'\ncurl http://localhost:8529/_api/collection -d '{\"type\": 3, \"name\": \"relationships\"}'\n```\n\nAfter that you also need to create a graph which requires the name and a definition of its edges.\n\n```\ncurl http://localhost:8529/_api/gharial -d @- \u003c\u003cEOF\n  {\"name\": \"quickstart\", \"edgeDefinitions\": [\n    {\"collection\": \"relationships\", \"from\": [\"resources\"], \"to\": [\"resources\"]}\n  ]}\nEOF\n```\n\nFinally, when you created the two collections then you can start to fetch all resources in the \n`kube-system` namespace and pipe the output directly to the ArangoDB HTTP API endpoint.\n\n```\nkubectl graph all -n kube-system -o aql \\\n  | eval 'jq -n --arg stdin \"$(cat)\" \"{query:\\$stdin}\"' \\\n  | curl http://localhost:8529/_api/cursor -d @-\n```\n\nFor more information about the HTTP API, please take a look at the offical [documentation](https://www.arangodb.com/docs/stable/http/).\n\n## Examples\n\n### Grafana Loki\n\nLoki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus.\n\n![Grafana Loki](assets/grafana-loki.png)\n\n```\nkubectl graph all -n loki -o cypher | cypher-shell -u neo4j -p secret\n```\n\n## Development\n\nIf you wish to work on the plugin, you'll first need [Go](http://www.golang.org/) installed on your machine\nand then you can simply run the following command to test your changes:\n\n```\ngo run ./cmd/kubectl-graph/main.go all -n \u003cnamespace\u003e | dot -T png -o all.png\n```\n\n## License\n\nThis project is licensed under the Apache License 2.0, see [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteveteuber%2Fkubectl-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteveteuber%2Fkubectl-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteveteuber%2Fkubectl-graph/lists"}