Search code examples
kuberneteskubectlkubernetes-podkubernetes-container

How to create multi container pod from without yaml config of pod or deployment


Trying to figure out how do I create multicontainer pod from terminal with kubectl without yaml config of any resource tried kubectl run --image=redis --image=nginx but second --image just overrides the first one .. :)


Solution

  • You can't do this in a single kubectl command, but you could do it in two: using a kubectl run command followed by a kubectl patch command:

    kubectl run mypod --image redis && kubectl patch deploy mypod --patch '{"spec": {"template": {"spec": {"containers": [{"name": "patch-demo", "image": "nginx"}]}}}}'