Documentation ¶
Index ¶
Constants ¶
const ( // DeletionPolicyAnnotation can be set on a resources to control the // behaviour of the resource deletion operation. DeletionPolicyAnnotation = "kcm/deletion-policy" // DeletePersistentVolumeClaimsPolicy will cause the deletion of all PVCs // that were created for a StatefulSet. DeletePersistentVolumeClaimsPolicy = "delete-pvcs" )
const ( // Kinds of Kubernetes resources that are treated in a special way by kcm. Job = "Job" PersistentVolumeClaim = "PersistentVolumeClaim" StatefulSet = "StatefulSet" )
Variables ¶
This section is empty.
Functions ¶
func FormatSlice ¶
FormatSlice formats a slice of resources as string. If s is nil or empty the formatted string will also be empty. The formatted output will be prepended with a summary of the counts of different resource hints (e.g. updates).
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer wraps a bytes.Buffer and delimits the bytes of every write so that the resulting byte slice is valid multi-document yaml.
type Head ¶
Head defines the yaml structure of a resource head. This is used for parsing metadata from raw yaml documents.
type Hint ¶
type Hint int
Hint is the type for resource hints. Hints are used to add context to a resource so that output formatters can make a decision on how to format it.
type Metadata ¶
type Metadata struct { Name string `yaml:"name"` Namespace string `yaml:"namespace"` Annotations map[string]string `yaml:"annotations"` }
Metadata is the resource metadata we are interested in.
type Order ¶
type Order []string
Order is a slice of strings that defines the ordering of resources.
var ApplyOrder Order = []string{
"Namespace",
"ResourceQuota",
"LimitRange",
"PodSecurityPolicy",
"PodDisruptionBudget",
"Secret",
"ConfigMap",
"StorageClass",
"PersistentVolume",
"PersistentVolumeClaim",
"ServiceAccount",
"CustomResourceDefinition",
"ClusterRole",
"ClusterRoleBinding",
"Role",
"RoleBinding",
"Service",
"DaemonSet",
"Pod",
"ReplicationController",
"ReplicaSet",
"Deployment",
"StatefulSet",
"Job",
"CronJob",
"Ingress",
"APIService",
}
ApplyOrder is the resource order for apply operations.
var DeleteOrder Order = []string{
"APIService",
"Ingress",
"Service",
"CronJob",
"Job",
"StatefulSet",
"Deployment",
"ReplicaSet",
"ReplicationController",
"Pod",
"DaemonSet",
"RoleBinding",
"Role",
"ClusterRoleBinding",
"ClusterRole",
"CustomResourceDefinition",
"ServiceAccount",
"PersistentVolumeClaim",
"PersistentVolume",
"StorageClass",
"ConfigMap",
"Secret",
"PodDisruptionBudget",
"PodSecurityPolicy",
"LimitRange",
"ResourceQuota",
"Namespace",
}
DeleteOrder is the resource order for delete operations.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer can print resources in a formatted way.
func NewPrinter ¶
NewPrinter creates a new Printer with w as the backing writer for the formatted output.
func (*Printer) PrintSlice ¶
PrintSlice prints a formatted resource slice.
type Resource ¶
type Resource struct { Kind string Name string Namespace string Content []byte DeletePersistentVolumeClaims bool // contains filtered or unexported fields }
Resource is a kubernetes resource.
func FindMatching ¶
FindMatching searches haystack for a resource matching needle and returns it if found, nil otherwise.
func (*Resource) WithContentHint ¶
WithContentHint hints the resource with its current content so that diffs can be generated for the new content in formatted output.
type Slice ¶
type Slice []*Resource
Slice is a slice of resources.
func (Slice) PersistentVolumeClaimsForDeletion ¶
PersistentVolumeClaimsForDeletion extracts all PersistentVolumeClaims for StatefulSets that have been annotated with:
kcm/deletion-policy: delete-pvcs
It returns a slice of Head containing name and namespace of every PVC that should be deleted after the StatefulSet is deleted. This is a workaround until a similar feature (https://github.com/kubernetes/kubernetes/issues/55045) is implemented in Kubernetes itself.