clone
Create a copy of a resource with the same values.
Install
kubectl-clonecurl -fsSL https://kubectl-plugins.dev/install.sh | sh -s -- clone
Download a binary instead
macOS (Apple silicon) · macOS (Intel) · Linux (amd64) · Linux (arm64) · Windows (amd64)kubectl clone RESOURCE NAME [NEW_NAME] [-n NAMESPACE] [--to-namespace NAMESPACE] [--dry-run]
Copies any resource type (plural, singular, short name or resource.group) under a new name, a new namespace, or both. kubectl cp is built in to kubectl (it copies files to and from pods), so this plugin is named clone.
Server-populated fields (uid, resourceVersion, managedFields, ownerReferences, status, the last-applied annotation) are dropped, along with values that must be unique: a Service’s clusterIP(s), a Pod’s nodeName and a PVC’s volumeName. The copy never overwrites the source: give a new name or --to-namespace.
Flags
| Flag | Description |
|---|---|
-n, --namespace | Namespace of the source (default: current context namespace) |
--to-namespace | Namespace for the copy (default: the source namespace) |
--dry-run | Validate server-side without creating the copy |
Examples
kubectl clone deployment web web-copy
kubectl clone configmap app-config --to-namespace staging
kubectl clone secret db-creds db-creds-v2 -n prod --to-namespace staging