@Mumshad Mannambeth How to add the container into the running pod ? I have gener . . .

Shankar PS:
@Mumshad Mannambeth How to add the container into the running pod ? I have generated the YAML file from the running container using kubectl get command but that YAML file looks too messy.

unnivkn:
Hi Shankar, may I know, what you are trying to do ?

Shankar PS:
@unnivkn In my k8s env, already one pod is running with 1 container with some volume mount. Now I want to add one more container into that pod without deleting the old pod.

Shankar PS:
I have generated the YAML file using kubectl get command but that looks very clumsy

unnivkn:
you can’t add another container with out deleting it… Pod is not dynamic to add any new container in it. You have to do this if you don’t want to delete to your Pod: 1) Take the backup of the existing pod in yaml 2) Add new container in it 3) rename the pod with different name 4) Deploy the new Pod … once all looks good … later you can decommission the original Pod.

unnivkn:
just search for the container section in that yaml & update what you need… No need to look for other Managed fields

Shankar PS:
@unnivkn Thanks. I have generated the YAML file for running the pod but in that file adding a new container configuration its too complex. Any other option has to add the container into the exiting pod. Note: I don’t have YAML file for the previous pod.

unnivkn:
its not complex… you should know where to add the new container details

unnivkn:

image.png

unnivkn:
just below the container add another array for new container

unnivkn:
eg: like this

  • name: nginx-container
    image: nginx
  • name: count
    image: busybox

Shankar PS:
Here is my running pod YAML file.

Shankar PS:
@unnivkn In this file, how to add the busybox container and I want to use the same volume on this container as well.

unnivkn:
working on it…will share you

Shankar PS:

  • name: sidecar
    image: busybox
    args: [/bin/sh, -c, ‘tail -n+1 -f /var/log/big-corp-app.log’]
    volumeMounts:
    • mountPath: /var/log
      name: logs