KB:Kubernetes run imperative Busybox pod and connect

#buysbox
kubectl run -it --rm busybox01 --image=busybox --restart=Never --command -- sh

#Network Tools
kubectl run -it --rm netshoot --image=nicolaka/netshoot --restart=Never --command -- bash


note, busybox image uses "sh" shell, /bin/bash will not work!
by design busybox will exit, there is no process/cmd that will run, so you have to connect to the pod/container during run time by overriding the command arg. 

  • kubectl run: This is the command used to create and run a new Pod.

  • -it: This flag is a combination of -i and -t. -i stands for "interactive", which keeps the stdin open even if not attached, and -t stands for "tty", which allocates a TTY (terminal).

  • --rm: This flag tells Kubernetes to automatically remove the Pod once it has finished executing.

  • busybox01: This is the name of the Pod being created.

  • --image=busybox: This specifies the Docker image to use for the Pod. In this case, it is the busybox image, which is a lightweight Linux distribution.

  • --restart=Never: This specifies the restart policy for the Pod. By setting it to Never, Kubernetes will not attempt to restart the Pod if it exits.

  • --command: This flag indicates that the following arguments should be treated as the command to run in the container.

  • -- sh: This specifies the command to run inside the container. sh is the shell command, which will start a shell session inside the container.

In summary, this command runs a temporary interactive BusyBox container with a shell (sh), and the Pod will be deleted automatically after the shell session ends. This is useful for running one-off tasks or debugging purposes in a Kubernetes cluster.


Ref: https://hub.docker.com/_/busybox


Comments

Popular posts from this blog

KB: Azure ACA Container fails to start (no User Assigned or Delegated Managed Identity found for specified ClientId)

Electron Process Execution Failure with FSLogix

KB:RMM VS DEX (Remote Monitoring Management vs Digital Employee Experience)