1

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?

gameveloster
  • 901
  • 1
  • 6
  • 18

2 Answers2

3

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.

Thomas
  • 11,272
  • 2
  • 24
  • 40
0

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)

Blender Fox
  • 4,442
  • 2
  • 17
  • 30
  • if there's a Service pointing to those pods, and if we want to experiment stuff in that new pod, tnen creating a separate deployment (with its own labels) would make sense. If there's no service nor PVC involved, scaling would be easier indeed. – SYN Jun 08 '22 at 16:51