A lightweight tool to clean Kubernetes YAML manifests by removing runtime-specific fields, making them portable across clusters and namespaces.
- 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
go install github.com/OpScaleHub/Kleanup@latest# 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=stagingInput:
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: nginxOutput:
apiVersion: apps/v1kind: Deploymentmetadata:
name: myappnamespace: defaultspec:
template:
spec:
containers:
- image: nginxname: nginxContributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details