百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
K

kubectl-slice

> 编程语言
开源

轻松地将多个 Kubernetes 文件分割成较小的文件。将多个 YAML 文件分割成单独的文件。

368 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

轻松地将多个 Kubernetes 文件分割成较小的文件。将多个 YAML 文件分割成单独的文件。

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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gohacktoberfestkubectlkubectl-pluginkubectl-plugins

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

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