Search code examples
ubuntukuberneteskubectlkubernetes-pod

Duplicate an Existing K8s Pod


In a namespace foo there is an existing pod running

$ kubectl get pods -n foo

NAME                      READY     STATUS    RESTARTS   AGE
hello-1816639685-xejyk    1/1       Running   0          6d3h

How can we duplicate the hello pod so that we can try out things in this duplicated pod without affecting the original pod?


Solution

  • You can get the pod manifest using YAML output from kubectl and create a new pod based on that specification.

    For example

    kubectl get pod hello-1816639685-xejyk -n foo -o yaml

    You need to use a different name or namespace, since the name must be unique.