Como abrir um shell em um Pod

Comando:

kubectl exec -it nginx -- /bin/sh

Teste:

ls -l

Resultado:

total 80
drwxr-xr-x   2 root root 4096 Dec 20 00:00 bin
drwxr-xr-x   2 root root 4096 Dec 11 17:25 boot
drwxr-xr-x   5 root root  360 Jan 10 19:14 dev
drwxr-xr-x   1 root root 4096 Dec 29 19:28 docker-entrypoint.d
-rwxrwxr-x   1 root root 1202 Dec 29 19:28 docker-entrypoint.sh
drwxr-xr-x   1 root root 4096 Jan 10 19:14 etc
drwxr-xr-x   2 root root 4096 Dec 11 17:25 home
drwxr-xr-x   1 root root 4096 Dec 20 00:00 lib
drwxr-xr-x   2 root root 4096 Dec 20 00:00 lib64
drwxr-xr-x   2 root root 4096 Dec 20 00:00 media
drwxr-xr-x   2 root root 4096 Dec 20 00:00 mnt
drwxr-xr-x   2 root root 4096 Dec 20 00:00 opt
dr-xr-xr-x 314 root root    0 Jan 10 19:14 proc
drwx------   2 root root 4096 Dec 20 00:00 root
drwxr-xr-x   1 root root 4096 Jan 10 19:14 run
drwxr-xr-x   2 root root 4096 Dec 20 00:00 sbin
drwxr-xr-x   2 root root 4096 Dec 20 00:00 srv
dr-xr-xr-x  13 root root    0 Jan 10 19:14 sys
drwxrwxrwt   1 root root 4096 Dec 29 19:28 tmp
drwxr-xr-x   1 root root 4096 Dec 20 00:00 usr
drwxr-xr-x   1 root root 4096 Dec 20 00:00 var

Como visualizar o log de um Pod para debug

Comando:

kubectl logs nginx

Resultado:

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2022/01/10 19:14:26 [notice] 1#1: using the "epoll" event method
2022/01/10 19:14:26 [notice] 1#1: nginx/1.21.5
2022/01/10 19:14:26 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2022/01/10 19:14:26 [notice] 1#1: OS: Linux 5.10.76-linuxkit
2022/01/10 19:14:26 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2022/01/10 19:14:26 [notice] 1#1: start worker processes
2022/01/10 19:14:26 [notice] 1#1: start worker process 31
2022/01/10 19:14:26 [notice] 1#1: start worker process 32
2022/01/10 19:14:26 [notice] 1#1: start worker process 33
2022/01/10 19:14:26 [notice] 1#1: start worker process 34
2022/01/10 19:14:26 [notice] 1#1: start worker process 35
2022/01/10 19:14:26 [notice] 1#1: start worker process 36