Skip to content

Sorts and filters Kubernetes resource definitions in manifest files

License

Notifications You must be signed in to change notification settings

alpozcan/k8s-manifest-sorter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k8s-manifest-sorter

Sorts Kubernetes manifest files in-place by resource kind.

It can also be used to filter resources with the -f switch.

Usage:

kms.py [-h] [-b] [-f] [-l] order input_file [input_file ...]

positional arguments:
  order         The order of resource Kinds as a comma-separated list. The
                resources will be moved to the top of the manifest in the
                order given.
  input_files   One or more input files to process.

optional arguments:
  -h, --help    show this help message and exit
  -b, --backup  Create a backup copy of the original file with .bak suffix.
                Default: disabled
  -f, --filter  Filter out all resource kinds other than those specified in
                the order. Default: disabled
  -l, --last    Instead of placing the specified resources at the top, place
                them at the bottom. Default: disabled

Example:

Reorder the manifest so that CustomResourceDefinitions are at the top of the manifest, therefore ensuring they get applied first:

./kms.py CustomResourceDefinition manifest.yaml

Reorder the manifest so that Projects get created before the Applications to avoid error in Argo CD. Also, take a backup of the original manifest:

./kms.py -b AppProject,Application manifest.yaml

Reorder the manifest so that Deployments are at the bottom of the manifest, therefore ensuring they get applied last:

./kms.py -l Deployment manifest.yaml

About

Sorts and filters Kubernetes resource definitions in manifest files

Topics

Resources

License

Stars

Watchers

Forks

Languages