How do I run a single container from the command line in a Kubernetes cluster (like docker run)?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How do I run a single container from the command line in a Kubernetes cluster (like docker run)?



I would like to run a one-off container Pod from the command line in my Kubernetes cluster. I am looking for the equivalent of:


docker run --rm -it centos /bin/bash



Is there a kubectl equivalent?


kubectl




1 Answer
1



It looks like the simplest way is:


kubectl run tmp-shell --rm -i --tty --image centos -- /bin/bash



Notes:


Deployment


tmp-shell


kubectl run


--rm


Deployment


--rm


kubectl delete deploy/tmp-shell


--rm


kubectl attach $pod-name -c $pod-container -i -t



If your shell does not start, check whether your cluster is out of resources (kubectl describe nodes). You can control the resources this deployment is requesting with --requests:


kubectl describe nodes


--requests


--requests='': The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges.



(Inspired by https://gc-taylor.com/blog/2016/10/31/fire-up-an-interactive-bash-pod-within-a-kubernetes-cluster)






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived