项目作者: alpozcan

项目描述 :
Sorts and filters Kubernetes resource definitions in manifest files
高级语言: Python
项目地址: git://github.com/alpozcan/k8s-manifest-sorter.git
创建时间: 2020-12-15T07:17:36Z
项目社区:https://github.com/alpozcan/k8s-manifest-sorter

开源协议:GNU General Public License v3.0

下载


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:

  1. kms.py [-h] [-b] [-f] [-l] order input_file [input_file ...]
  2. positional arguments:
  3. order The order of resource Kinds as a comma-separated list. The
  4. resources will be moved to the top of the manifest in the
  5. order given.
  6. input_files One or more input files to process.
  7. optional arguments:
  8. -h, --help show this help message and exit
  9. -b, --backup Create a backup copy of the original file with .bak suffix.
  10. Default: disabled
  11. -f, --filter Filter out all resource kinds other than those specified in
  12. the order. Default: disabled
  13. -l, --last Instead of placing the specified resources at the top, place
  14. 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:

  1. ./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:

  1. ./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:

  1. ./kms.py -l Deployment manifest.yaml