How to enter the container in k8s

First check the name of the container you want to enter

kubectl get pod | awk '{print $1}'

Note: If there is a namespace, you need to add the namespace

Namespace viewing mode (the arrow marks the namespace)

kubectl -n namespace get pod | awk '{print $1}'

-n: namespace

Enter the container after finding it

kubectl exec -it podname[the name of the container just found] /bin/bash

exec: command to enter the container

/bin/bash: Enter the container in bash mode (if there is no /bin/bash, enter directly in bash mode)

The other ways to enter the container are bash and sh.

kubectl exec -it podname [container name just found] bash

kubectl exec -it podname[the name of the container just found] sh

Guess you like

Origin blog.csdn.net/m0_73126743/article/details/129555515