Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dippynark/kfmt
Organises Kubernetes manifests into a standard format
https://github.com/dippynark/kfmt
gitops kubernetes-manifests
Last synced: 3 months 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 (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-13T17:38:27.000Z (over 1 year ago)
- Last Synced: 2024-10-09T10:43:43.212Z (4 months ago)
- Topics: gitops, kubernetes-manifests
- Language: Go
- Homepage:
- Size: 480 KB
- Stars: 15
- 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.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)## 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.## Format
The standard format used by kfmt is as follows:
```text
# kfmt output directory
output
| # Directory containing non-namespaced resources
├── cluster
| | # Each non-namespaced resource is given a directory named after its kind and group. The
| | # group is used to prevent clashes between resources with the same kind in different groups
| | # but is omitted for core resources
│ └── .
| | # Files are named after the resource name
│ └── .yaml
| # Directory containing namespaced resources
└── namespaces
| # Each Namespace is given its own directory named after its name
└──
| # Files are named after the resource name, kind and group. The group is used to prevent
| # clashes between resources with the same kind and name in different groups but is
| # ommitted for core resouces
└── .-.yaml
```## 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.