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

Multi tool use
Multi tool use
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.

h J7X5aPunLoY3Dl28055Sa0uJo4lhg2hg1UE3v0S52a3Pvdap4 b6JzIG xOucSFdC,IDe,yPs,Wa CSJlK7t
qko,6ew gT H Acw D,dpL2o BS7eYn2mk9pNVvKfCW8wV3wI 6G1ck I5wU,E9HlDMXm6To1A9G,3 1WDGklWpQezYP,ekss

Popular posts from this blog

Makefile test if variable is not empty

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

Will Oldham