https://github.com/projectsyn/k8s-object-dumper
Kubernetes object dumper for use as a pre backup command in K8up.
https://github.com/projectsyn/k8s-object-dumper
backup backup-script backup-tool backup-utility k8up kubernetes openshift vshn-team-aldebaran
Last synced: about 2 months ago
JSON representation
Kubernetes object dumper for use as a pre backup command in K8up.
- Host: GitHub
- URL: https://github.com/projectsyn/k8s-object-dumper
- Owner: projectsyn
- License: bsd-3-clause
- Created: 2020-10-08T07:36:49.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-04-11T11:40:49.000Z (about 2 months ago)
- Last Synced: 2025-04-11T13:15:00.970Z (about 2 months ago)
- Topics: backup, backup-script, backup-tool, backup-utility, k8up, kubernetes, openshift, vshn-team-aldebaran
- Language: Go
- Homepage:
- Size: 85.9 KB
- Stars: 3
- Watchers: 10
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# K8s Object Dumper
Discover and dump all listable objects from a Kubernetes cluster into JSON files.
Written to be used as a pre backup command for [K8up](https://k8up.io).## Usage
The project uses controller-runtime's configuration discovery to find the Kubernetes API server.
### Dump to STDOUT
```bash
$ k8s-object-dumper
{"apiVersion":"v1","kind":"List","items":[{"apiVersion":"v1", ...}]}
{"apiVersion":"v1","kind":"List","items":[{"apiVersion":"apps/v1", ...}]}
```### Dump to a directory
```bash
$ k8s-object-dumper -dir dir
```Will result in the following directory structure:
```
└─ dir/
├─ objects-[.].json
├─ …
└─ split/
├─ /
| ├─ __all__.json
| ├─ [.].json
| └─ …
└─ …
```### Advanced usage
```bash
# Fail if a Pods, Deployments or AlertingRules are not found
$ k8s-object-dumper \
-must-exist=pods \
-must-exist=deployments.apps \
-must-exist=alertingrules.monitoring.openshift.io
# Ignore all Secrets and all cert-manager objects
$ k8s-object-dumper \
-ignore=secrets \
-ignore=.+cert-manager.io
```## Development
The project uses [envtest](https://book.kubebuilder.io/reference/envtest) to run tests against a real Kubernetes API server.
```bash
$ make test
```## Differences to the original `bash` version `< 0.3.0`
- All APIs are fully qualified in both the options (`--must-exist=certificates.cert-manager.io`, `--ignore=deployment.apps`) and the output files (`objects-Certificate.cert-manager.io.json`).
This makes it possible to distinguish between objects with the same kind but different groups. See https://github.com/projectsyn/k8s-object-dumper/issues/47.
- Resources without a list endpoint are ignored, do not cause an error, and don't need to be explicitly ignored.
- Ignore and must-exist options are now command line flags instead of files in `/usr/local/share`.## Contributing and license
This library is licensed under [BSD-3-Clause](LICENSE).
For information about how to contribute see [CONTRIBUTING](CONTRIBUTING.md).