{"id":13549863,"url":"https://github.com/darkbitio/k8s-mirror","last_synced_at":"2025-04-02T23:31:15.104Z","repository":{"id":39407977,"uuid":"334518976","full_name":"darkbitio/k8s-mirror","owner":"darkbitio","description":"Creates a local mirror of a Kubernetes cluster in a docker container to support offline reviewing","archived":true,"fork":false,"pushed_at":"2021-01-30T21:57:20.000Z","size":6,"stargazers_count":338,"open_issues_count":0,"forks_count":23,"subscribers_count":32,"default_branch":"main","last_synced_at":"2024-11-03T19:37:19.517Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/darkbitio.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}},"created_at":"2021-01-30T21:52:28.000Z","updated_at":"2024-06-06T09:52:17.000Z","dependencies_parsed_at":"2022-09-08T13:23:01.149Z","dependency_job_id":null,"html_url":"https://github.com/darkbitio/k8s-mirror","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkbitio%2Fk8s-mirror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkbitio%2Fk8s-mirror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkbitio%2Fk8s-mirror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkbitio%2Fk8s-mirror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darkbitio","download_url":"https://codeload.github.com/darkbitio/k8s-mirror/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246910955,"owners_count":20853652,"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-01T12:01:26.432Z","updated_at":"2025-04-02T23:31:14.686Z","avatar_url":"https://github.com/darkbitio.png","language":"Ruby","funding_links":[],"categories":["Ruby","Networking Utilities"],"sub_categories":[],"readme":"# K8s-mirror\n\n## Why?\n\nTo enable high-fidelity, offline review of Kubernetes clusters as a part of Darkbit's cloud and Kubernetes security [consulting services offerings](https://darkbit.io/services/), a simple script to export all K8s resources from a cluster was developed.  A modified version of this script is included in this repository as `kube-exporter.sh`.\n\nThe original goal of this export format was to support ingestion by the [OpenCSPM](https://github.com/opencspm/opencspm) analysis platform.  However, there are instances where analysis is best performed with a quick run of `kubectl`.  Without having direct access to a client's cluster, a \"mirror\" cluster is needed.\n\n## What?\n\nUsing the `kube-exporter.sh` in this repo, all the resources in a target cluster are exported to a local, new-line delimited json format.  To view, this data, another instance of etcd and the kube-apiserver are needed, so that's what is baked into the container specified by this Dockerfile.  The idea is that a local docker container running just the barebones components needed can be populated with the raw exported data directly into etcd.\n\n## How?\n\n* Clone the repository\n* Run `kube-exporter.sh` against the target cluster.  It's output file should be named `\u003ckubecontext_name\u003e.json`.\n* Copy `\u003ckubecontext_name\u003e.json` to `data/import.json`\n* Modify the `Dockerfile` to use the correct `K8S_VERSION`\n* Run `make build` to build the docker container.\n* Run `make run` to launch the \"mirror\" cluster container.  This container runs etcd, loads the data from `/data/import.json` into etcd, and then launches an _insecure_ API server.  That is, it runs without TLS, listens on `localhost:31337` and requires a simple token for authentication as `cluster-admin`.\n* Run `export KUBECONFIG=kubeconfig.honk`\n* Run `kubectl get pods -A` to query for pods in the \"mirror\" cluster container.\n* When done, kill the container to clean up.\n\n## Warning!\n\nThis is a working proof of concept and \"pre-alpha\" quality. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkbitio%2Fk8s-mirror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarkbitio%2Fk8s-mirror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkbitio%2Fk8s-mirror/lists"}