项目作者: latchmihay

项目描述 :
Combined Kubernetes YAML Splitter
高级语言: Go
项目地址: git://github.com/latchmihay/k8s-yaml-splitter.git
创建时间: 2018-11-17T23:32:35Z
项目社区:https://github.com/latchmihay/k8s-yaml-splitter

开源协议:GNU General Public License v2.0

下载


k8s-yaml-splitter

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

Install

  1. # Go 1.17+
  2. go install github.com/latchmihay/k8s-yaml-splitter@latest
  3. # everything before 1.17
  4. go get github.com/latchmihay/k8s-yaml-splitter

Usage

  1. Usage: ./k8s-yaml-splitter /path/to/combined-k8s.yaml /path/to/output/dir
  2. Usage Dry Run: ./k8s-yaml-splitter /path/to/combined-k8s.yaml /path/to/output/dir -d
  3. # Piped in
  4. cat example/combined-k8s.yaml | ./k8s-yaml-splitter

Example:

Dry Run:

  1. # ./k8s-yaml-splitter example/combined-k8s.yaml /tmp/k8s-split/ -d
  2. Found! type: Secret | apiVersion: v1 | name: grafana | namespace: istio-system
  3. ==> DryRun: Writing /tmp/k8s-split/Secret-grafana.yaml
  4. Found! type: Secret | apiVersion: v1 | name: kiali | namespace: istio-system
  5. ==> DryRun: Writing /tmp/k8s-split/Secret-kiali.yaml
  6. Found! type: ConfigMap | apiVersion: v1 | name: istio-galley-configuration | namespace: istio-system
  7. ==> DryRun: Writing /tmp/k8s-split/ConfigMap-istio-galley-configuration.yaml

Normal Run:

  1. # ./k8s-yaml-splitter example/combined-k8s.yaml /tmp/k8s-split/
  2. Found! type: Secret | apiVersion: v1 | name: grafana | namespace: istio-system
  3. * Writing /tmp/k8s-split/Secret-grafana.yaml
  4. * Wrote 250 bytes to /tmp/k8s-split/Secret-grafana.yaml
  5. Found! type: Secret | apiVersion: v1 | name: kiali | namespace: istio-system
  6. * Writing /tmp/k8s-split/Secret-kiali.yaml
  7. * Wrote 242 bytes to /tmp/k8s-split/Secret-kiali.yaml
  8. Found! type: ConfigMap | apiVersion: v1 | name: istio-galley-configuration | namespace: istio-system
  9. * Writing /tmp/k8s-split/ConfigMap-istio-galley-configuration.yaml
  10. * 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

  1. # cat example/combined-k8s.yaml | ./k8s-yaml-splitter
  2. Found! type: Secret | apiVersion: v1 | name: grafana | namespace: istio-system
  3. * Writing /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/Secret-grafana.yaml
  4. * Wrote 250 bytes to /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/Secret-grafana.yaml
  5. Found! type: Secret | apiVersion: v1 | name: kiali | namespace: istio-system
  6. * Writing /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/Secret-kiali.yaml
  7. * Wrote 242 bytes to /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/Secret-kiali.yaml
  8. Found! type: ConfigMap | apiVersion: v1 | name: istio-galley-configuration | namespace: istio-system
  9. * Writing /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/ConfigMap-istio-galley-configuration.yaml
  10. * Wrote 3308 bytes to /Users/madcricket/go/src/github.com/latchmihay/k8s-yaml-splitter/.k8s-yaml-splitter/ConfigMap-istio-galley-configuration.yaml