Home > database >  Duplicate an Existing K8s Pod
Duplicate an Existing K8s Pod

Time:06-08

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?

CodePudding user response:

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.

CodePudding user response:

Based on the naming convention, that pod looks like it's a deployment, so you should be able to scale up an additional replica (or replicas) using

kubectl scale deployment/hello-1816639685 --replicas=2

However, this is assuming you haven't added something like a persistent disk to the deployment (which then won't work with the additional replica)

  • Related