An open API service indexing awesome lists of open source software.

https://github.com/latchmihay/k8s-yaml-splitter

Combined Kubernetes YAML Splitter
https://github.com/latchmihay/k8s-yaml-splitter

k8s k8s-yaml-splitter kubernetes kustomize split splitter yaml

Last synced: 6 months ago
JSON representation

Combined Kubernetes YAML Splitter

Awesome Lists containing this project

README

          

# k8s-yaml-splitter
It takes a combined kubernetes yaml config and splits it into multiple files in a folder of your choosing

# Install
```console
# Go 1.17+
go install github.com/latchmihay/k8s-yaml-splitter@latest
# everything before 1.17
go get github.com/latchmihay/k8s-yaml-splitter
```

# Usage

```console
Usage: ./k8s-yaml-splitter /path/to/combined-k8s.yaml /path/to/output/dir
Usage Dry Run: ./k8s-yaml-splitter /path/to/combined-k8s.yaml /path/to/output/dir -d

# Piped in
cat example/combined-k8s.yaml | ./k8s-yaml-splitter
```

# Example:
#### Dry Run:
```console
# ./k8s-yaml-splitter example/combined-k8s.yaml /tmp/k8s-split/ -d
Found! type: Secret | apiVersion: v1 | name: grafana | namespace: istio-system
==> DryRun: Writing /tmp/k8s-split/Secret-grafana.yaml
Found! type: Secret | apiVersion: v1 | name: kiali | namespace: istio-system
==> DryRun: Writing /tmp/k8s-split/Secret-kiali.yaml
Found! type: ConfigMap | apiVersion: v1 | name: istio-galley-configuration | namespace: istio-system
==> DryRun: Writing /tmp/k8s-split/ConfigMap-istio-galley-configuration.yaml
```

#### Normal Run:
```console
# ./k8s-yaml-splitter example/combined-k8s.yaml /tmp/k8s-split/
Found! type: Secret | apiVersion: v1 | name: grafana | namespace: istio-system
* Writing /tmp/k8s-split/Secret-grafana.yaml
* Wrote 250 bytes to /tmp/k8s-split/Secret-grafana.yaml
Found! type: Secret | apiVersion: v1 | name: kiali | namespace: istio-system
* Writing /tmp/k8s-split/Secret-kiali.yaml
* Wrote 242 bytes to /tmp/k8s-split/Secret-kiali.yaml
Found! type: ConfigMap | apiVersion: v1 | name: istio-galley-configuration | namespace: istio-system
* Writing /tmp/k8s-split/ConfigMap-istio-galley-configuration.yaml
* Wrote 3308 bytes to /tmp/k8s-split/ConfigMap-istio-galley-configuration.yaml
```

#### Piped in
> will create a `.k8s-global-obejcts` folder in your current directory and split the yamls in there

```console
# cat example/combined-k8s.yaml | ./k8s-yaml-splitter
Found! type: Secret | apiVersion: v1 | name: grafana | namespace: istio-system
* Writing /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/Secret-grafana.yaml
* Wrote 250 bytes to /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/Secret-grafana.yaml
Found! type: Secret | apiVersion: v1 | name: kiali | namespace: istio-system
* Writing /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/Secret-kiali.yaml
* Wrote 242 bytes to /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/Secret-kiali.yaml
Found! type: ConfigMap | apiVersion: v1 | name: istio-galley-configuration | namespace: istio-system
* Writing /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/ConfigMap-istio-galley-configuration.yaml
* Wrote 3308 bytes to /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/ConfigMap-istio-galley-configuration.yaml
```