ksort

package module
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2022 License: Apache-2.0, MIT Imports: 15 Imported by: 0

README

ksort

Build Status

This is a tool which does in-place sort of Kubernetes manifests by Kind.

Description

When installing manifests, they should be sorted in a proper order by Kind. For example, Namespace object must be in the first place when installing them.

ksort sorts manfest files in a proper order by Kind.

Usage

Sort manifest files in the deploy directory in the proper order, and output the result to the stdout.

$ ls ./manifests
deployment.yaml  ingress.yaml  namespace.yaml  service.yaml
$ ksort -f ./manifests

To pass the result into the stdin of kubectl apply command is also convenient.

$ ksort -f ./manifests | kubectl apply -f -

Sort manifests contained the manifest file that is specified.

$ ksort -f ./app.yaml

Sort manifests passed into stdin.

$ cat app.yaml | ksort -f-

Installation

You can download an archive file from GitHub Releases, then extract it and install a binary.

Or use go get as follows:

$ go get github.com/superbrothers/ksort/cmd

Installation as kubectl plugin

You can also use ksort as kubectl plugin. The name as kubectl plugin is sort-manifests.

  1. Install krew that is a plugin manager for kubectl

  2. Run:

     kubectl krew install sort-manifests
    
  3. Try it out

     kubectl sort-manifests -h
    

License

This software is released under the MIT License and includes the work that is distributed in the Apache License 2.0.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GitVersion   = "v0.0.0"
	GitCommit    = "$Format:%H$"
	GitTreeState = "dirty"
	BuildDate    = "1970-01-01T00:00:00Z"
)

Functions

func NewCommand

func NewCommand(streams genericclioptions.IOStreams) *cobra.Command

Types

type KindSortOrder added in v0.3.1

type KindSortOrder []string

KindSortOrder is an ordering of Kinds.

var InstallOrder KindSortOrder = []string{
	"Namespace",
	"NetworkPolicy",
	"ResourceQuota",
	"LimitRange",
	"PodSecurityPolicy",
	"PodDisruptionBudget",
	"ServiceAccount",
	"Secret",
	"SecretList",
	"ConfigMap",
	"StorageClass",
	"PersistentVolume",
	"PersistentVolumeClaim",
	"CustomResourceDefinition",
	"ClusterRole",
	"ClusterRoleList",
	"ClusterRoleBinding",
	"ClusterRoleBindingList",
	"Role",
	"RoleList",
	"RoleBinding",
	"RoleBindingList",
	"Service",
	"DaemonSet",
	"Pod",
	"ReplicationController",
	"ReplicaSet",
	"Deployment",
	"HorizontalPodAutoscaler",
	"StatefulSet",
	"Job",
	"CronJob",
	"Ingress",
	"APIService",
}

InstallOrder is the order in which manifests should be installed (by Kind).

Those occurring earlier in the list get installed before those occurring later in the list.

var UninstallOrder KindSortOrder = []string{
	"APIService",
	"Ingress",
	"Service",
	"CronJob",
	"Job",
	"StatefulSet",
	"HorizontalPodAutoscaler",
	"Deployment",
	"ReplicaSet",
	"ReplicationController",
	"Pod",
	"DaemonSet",
	"RoleBindingList",
	"RoleBinding",
	"RoleList",
	"Role",
	"ClusterRoleBindingList",
	"ClusterRoleBinding",
	"ClusterRoleList",
	"ClusterRole",
	"CustomResourceDefinition",
	"PersistentVolumeClaim",
	"PersistentVolume",
	"StorageClass",
	"ConfigMap",
	"SecretList",
	"Secret",
	"ServiceAccount",
	"PodDisruptionBudget",
	"PodSecurityPolicy",
	"LimitRange",
	"ResourceQuota",
	"NetworkPolicy",
	"Namespace",
}

UninstallOrder is the order in which manifests should be uninstalled (by Kind).

Those occurring earlier in the list get uninstalled before those occurring later in the list.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL