Skip to content

Repository files navigation

Kleanup

License: MITGo Version

A lightweight tool to clean Kubernetes YAML manifests by removing runtime-specific fields, making them portable across clusters and namespaces.

Features

  • Removes runtime-specific metadata (timestamps, UIDs, etc.)
  • Cleans up controller-specific annotations
  • Removes cluster-specific configuration
  • Makes manifests portable across namespaces
  • Supports multiple Kubernetes resource types
  • Preserves essential configuration

Installation

go install github.com/OpScaleHub/Kleanup@latest

Usage

# Clean a deployment manifest
kubectl get deployment myapp -o yaml | klean > clean-deployment.yaml
# Clean multiple resources
kubectl get deployment,service,configmap -o yaml | klean > clean-manifests.yaml
# Clean all resources in a namespace
kubectl get all -o yaml | klean > backup.yaml
# Clean and apply to another namespace
kubectl get deployment myapp -o yaml | klean | kubectl apply -f - --namespace=staging

Examples

Input:

apiVersion: apps/v1kind: Deploymentmetadata:
annotations:
deployment.kubernetes.io/revision: "2"creationTimestamp: "2023-04-08T19:51:09Z"generation: 2name: myappnamespace: defaultresourceVersion: "4433"uid: a174f3d1-0b1d-4ec5-9da4-8b7c889362caspec:
replicas: 1template:
spec:
containers:
- image: nginxname: nginx

Output:

apiVersion: apps/v1kind: Deploymentmetadata:
name: myappnamespace: defaultspec:
template:
spec:
containers:
- image: nginxname: nginx

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details

About

K8s manifest cleanup tool-box

Topics

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages