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

Como visualizar informações de um Pod para debug

Comando:

kubectl describe po nginx

Resultado:


Name:         nginx
Namespace:    default
Priority:     0
Node:         kind-worker/172.18.0.2
Start Time:   Mon, 10 Jan 2022 16:14:22 -0300
Labels:       run=nginx
Annotations:  <none>
Status:       Running
IP:           10.244.2.5
IPs:
  IP:  10.244.2.5
Containers:
  nginx:
    Container ID:   containerd://39d1aef31b080005b2171b3554369c9e7fccd76f3d45af4630baab0f0a9a49ae
    Image:          nginx
    Image ID:       docker.io/library/nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Mon, 10 Jan 2022 16:14:26 -0300
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-zbc2s (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  default-token-zbc2s:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-zbc2s
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  8s    default-scheduler  Successfully assigned default/nginx to kind-worker
  Normal  Pulling    7s    kubelet            Pulling image "nginx"
  Normal  Pulled     4s    kubelet            Successfully pulled image "nginx" in 3.528517877s
  Normal  Created    4s    kubelet            Created container nginx
  Normal  Started    4s    kubelet            Started container nginx