Sign inSign up

looztra/kubesplit

By looztra

•Updated about 6 years ago

Split multidoc yaml formatted kubernetes descriptors to a set of single resource files.

Image
0

10K+

looztra/kubesplit repository overview

⁠What?

Split multidoc yaml formatted kubernetes⁠ descriptors to a set of single resource files.

If you just want an opinionated yaml formatter, you can have a look at yamkix⁠.

⁠Installation

# Use latest
docker image pull looztra/kubesplit
# Or one of the version+sha1 related tags
docker image pull looztra/kubesplit:[version]-[sha1]
# Enjoy
docker container run \
        -i --rm \
        -v $(pwd):/code \
        -w /code looztra/kubesplit \
        -i path/to/yaml_file.yml \
        -o path/to/output/directory
# or
cat path/to/yaml_file.yml | \
        docker container run \
        -i --rm \
        -v $(pwd):/code \
        -w /code looztra/kubesplit \
        -o path/to/output/directory

Note : do NOT specify the -t/--ttyflag when using the second invocation style to avoid the error message the input device is not a TTY

⁠Usage

╰(.venv)─» kubesplit -h
usage: kubesplit [-h] [-i INPUT] [-t TYP] -o OUTPUT_DIR [-n] [-e] [-q] [-f]
                   [-d] [-c] [-p]

Split a set of Kubernetes descriptors to a set of files. The yaml format of
the generated files can be tuned using the same parameters as the one used by
Yamkix. By default, explicit_start is `On`, explicit_end is `Off` and array
elements are pushed inwards the start of the matching sequence. Comments are
preserved thanks to default parsing mode `rt`.

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        the file to parse, or STDIN if not specified or if
                        value is -
  -t TYP, --typ TYP     the yaml parser mode. Can be `safe` or `rt`
  -o OUTPUT_DIR, --output-dir OUTPUT_DIR
                        the name of the output target directory. The target
                        directory will be created if it does not exist if it's
                        possible
  -n, --no-explicit-start
                        by default, explicit start (---) of the yaml doc is
                        `On`, you can disable it with this option
  -e, --explicit-end    by default, explicit end (...) of the yaml doc is
                        `Off`, you can enable it with this option
  -q, --no-quotes-preserved
                        by default, quotes are preserved you can disable this
                        with this option
  -f, --default-flow-style
                        enable the default flow style `Off` by default. In
                        default flow style (with typ=`rt`), maps and lists are
                        written like json
  -d, --no-dash-inwards
                        by default, dash are pushed inwards use `--no-dash-
                        inwards` to have the dash start at the sequence level
  -c, --clean-output-dir
                        clean the output directory (rmtree) if set (default is
                        False)
  -p, --no-resource-prefix
                        by default, resource files are number prefixed, you
                        can disable this behaviour with this flag

⁠Features

  • Invalid Kubernetes resources are ignored
  • Empty resources are ignored
  • Each resource found in the input is stored in a file with a name reflecting the name of the resource and its kubernetes kind
  • Cluster-wide resources (namespaces, clusterroles, clusterrolebindings) are stored in the root directory of the output, namespaced resources are stored in a subdirectory named like the namespace
  • By default, resources are prefixed, use --no-resource-prefix to disable order prefixes
  • By default, quotes are preserved, use --no-quotes-preserved to disable quotes unless needed (for boolean and numbers if they were provided in the input as for the moment Kubesplit is not aware of the fact that only kubernetes annotations and environment variables require string)
  • By default, dash elements in list are pushed inwards, you can disable this behaviour with the -d/--no-dash-inwards option
  • Comments are preserved
  • The output directory will be created if it doesn't exist (if the user running the command as sufficient rights)
  • You can clean (delete files and directories existing before running kubesplit) the output directory with the -c/--clean-output-dir (use at your own risks)

⁠Source code

https://github.com/looztra/kubesplit⁠

Tag summary

Content type

Image

Digest

Size

29.2 MB

Last updated

about 6 years ago

docker pull looztra/kubesplit