Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
K

kubectl-slice

> 编程语言
Open source

Split multiple Kubernetes files into smaller files with ease. Split multi-YAML files into individual files.

368 stars0 likes1 views
WebsiteGitHub

About

Split multiple Kubernetes files into smaller files with ease. Split multi-YAML files into individual files.

kubectl-slice: split Kubernetes YAMLs into files

  • kubectl-slice: split Kubernetes YAMLs into files
    • Installation
      • Using krew
      • Using Homebrew
      • Download and install manually
    • Usage
    • Why kubectl-slice?
    • Passing configuration options to kubectl-slice
    • Including and excluding manifests from the output
    • Examples
    • Contributing & Roadmap

kubectl-slice is a tool that allows you to split a single multi-YAML Kubernetes manifest (with --input-file or -f), or a folder containing multiple manifests files (with --input-folder or -d, optionally with --recursive), into multiple subfiles using a naming convention you choose. This is done by parsing the YAML code and allowing you to access any key from the YAML object using Go Templates.

By default, kubectl-slice will split your files into multiple subfiles following this naming convention that you can configure to your liking:

handlebars
{{.kind | lower}}-{{.metadata.name}}.yaml

That is, the Kubernetes kind -- in this case, the value Namespace -- lowercased, followed by a dash, followed by the resource name -- in this case, the value production:

namespace-production.yaml

If your YAML includes multiple files, for example:

yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx-ingress
---
apiVersion: v1
kind: Namespace
metadata:
  name: production

Then the following files will be created:

$ kubectl-slice --input-file=input.yaml --output-dir=.
Wrote pod-nginx-ingress.yaml -- 58 bytes.
Wrote namespace-production.yaml -- 61 bytes.
2 files generated.

You can customize the file name to your liking, by using the --template flag.

Installation

kubectl-slice can be used as a standalone tool or through kubectl, as a plugin.

Using krew

kubectl-slice is available as a krew plugin.

To install, use the following command:

bash
kubectl krew install slice

Using Homebrew

kubectl-slice is available as a Homebrew tap for both macOS and Linux:

bash
brew install patrickdappollonio/tap/kubectl-slice

Download and install manually

Download the latest release for your platform from the Releases page, then extract and move the kubectl-slice binary to any place in your $PATH. If you have kubectl installed, you can use both kubectl-slice and kubectl slice (note in the later the absence of the -).

Usage

…

Why kubectl-slice?

See why kubectl-slice? for more information.

Passing configuration options to kubectl-slice

Besides command-line flags, you can also use environment variables and a YAML configuration file to pass options to kubectl-slice. See the documentation for configuration options for details about both, including precedence.

Including and excluding manifests from the output

Including or excluding manifests from the output via metadata.name or kind is possible. Globs are supported in both cases. See the documentation for including and excluding items for more information.

Examples

See examples for more information.

Contributing & Roadmap

Pull requests are welcomed! So far, looking for help with the following items, which are also part of the roadmap:

  • Adding unit tests
  • Improving the YAML file-by-file parser, right now it works by buffering line by line
  • Adding support to install through brew
  • Adding new features marked as enhancement

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gohacktoberfestkubectlkubectl-pluginkubectl-plugins

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言