https://github.com/dippynark/kfmt
Organises Kubernetes manifests into a standard format
https://github.com/dippynark/kfmt
gitops kubernetes-manifests
Last synced: 17 days ago
JSON representation
Organises Kubernetes manifests into a standard format
- Host: GitHub
- URL: https://github.com/dippynark/kfmt
- Owner: dippynark
- License: apache-2.0
- Created: 2021-01-22T12:42:59.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-21T23:38:32.000Z (5 months ago)
- Last Synced: 2025-03-29T21:41:21.104Z (about 1 month ago)
- Topics: gitops, kubernetes-manifests
- Language: Go
- Homepage:
- Size: 481 KB
- Stars: 16
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kfmt
kfmt takes input files and directories containing Kubernetes manifests and organises them into a
standard format:```t
# Output directory
output
| # Directory containing cluster scoped resources
├── cluster
| | # Each cluster scoped resource is given a directory named after its plural and group
│ └── .
| | # Files are named after the resource name
│ └── .yaml
| # Directory containing namespace scoped resources
└── namespaces
| # Each Namespace is given its own directory
└──
| # Files are named after the resource name, kind and group
└── .-.yaml
```Inspiration is taken from a number of other tools:
- [manifest-splitter](https://github.com/munnerz/manifest-splitter)
- [nomos](https://cloud.google.com/anthos-config-management/docs/how-to/nomos-command)
- [jx gitops split](https://github.com/jenkins-x/jx-gitops/blob/master/docs/cmd/jx-gitops_split.md)
- [jx gitops
rename](https://github.com/jenkins-x/jx-gitops/blob/master/docs/cmd/jx-gitops_rename.md)
- [jx gitops helmfile
move](https://github.com/jenkins-x/jx-gitops/blob/master/docs/cmd/jx-gitops_helmfile_move.md)## Use Cases
kfmt is useful in any situation where it's beneficial to have a collection of manifests organised
into a standard format. This could be to tidy up a large collection of manifests or just to make
them easier to browse.GitOps tools such as [Flux](https://github.com/fluxcd/flux2) and [Anthos Config
Management](https://cloud.google.com/anthos/config-management) that sync manifests from a Git
repository could also benefit from kfmt by running it as a final step in CI, taking in all the
manifests to be synced and verifying there are no clashes. Using the `kfmt.dev/namespaces`
annotation can also be used to copy policy resources across Namespaces and having a standard format
may make any changes easier to review.## Installation
```sh
GO111MODULE=on go get github.com/dippynark/kfmt
```kfmt is also distributed as a [binary](https://github.com/dippynark/kfmt/releases) and a [Docker
image](https://hub.docker.com/repository/docker/dippynark/kfmt).## Usage
The simplest usage is to format manifests coming from stdin:
```sh
cat < api-resources.txt
```Similarly, this cached discovery information can be augmented with all available versions:
```sh
kubectl api-versions > api-versions.txt
```In addition, kfmt supports the `--discovery` flag to enable use of the Kubernetes discovery API.
kfmt will only attempt to use the Kubernetes discovery API if the required discovery information is
not provided using another method.