skip to Main Content

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?

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search