k8s-object-dumper

command module
v0.0.0-...-7807a54 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

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.

Usage

The project uses controller-runtime's configuration discovery to find the Kubernetes API server.

Dump to STDOUT
$ k8s-object-dumper
{"apiVersion":"v1","kind":"List","items":[{"apiVersion":"v1", ...}]}
{"apiVersion":"v1","kind":"List","items":[{"apiVersion":"apps/v1", ...}]}
Dump to a directory
$ k8s-object-dumper -d dir

Will result in the following directory structure:

└─ dir/
   ├─ objects-<kind>[.<group>].json
   ├─ …
   └─ split/
      ├─ <namespace>/
      |  ├─ __all__.json
      |  ├─ <kind>[.<group>].json
      |  └─ …
      └─ …
Advanced usage
# 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 to run tests against a real Kubernetes API server.

$ 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 and do not cause and error or 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. For information about how to contribute see CONTRIBUTING.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
pkg/dumper
Dumper provides means to dump a UnstructuredList returned by a dynamic client.
Dumper provides means to dump a UnstructuredList returned by a dynamic client.

Jump to

Keyboard shortcuts

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