How to check API access log in kubernetes. I have an application with two pods. I want to see the access logs how it is getting distributed.
The answer depends on your architecture. Unfortunately, the question is not complete, so we can provide only general info here.
The common way acessing logs in Kubernetes is through kubectl logs <pod_name>
command. That'll give you logs for the first container on that Pod. It's needed to specify particular container name if you are running some side-car containers there.
kubectl get pods
NAME READY STATUS
nginx-65f88748fd-scxzl 1/1 Running
kubectl logs nginx-65f88748fd-scxzl
<Nginx Logs from my pod>
Additionally (if your app supports internal logging) it is possible to connect to the Pod in interactive mode and run some command directly on pod (if supported).
kubectl exec <parameters> <pod_name> -- <command>
For example you can run some shell on Pod and check logs.
kubectl exec -it nginx-65f88748fd-scxzl -- bash
root@nginx-65f88748fd-scxzl:/#
-it
initiates connection in interactive mode and command to run is placed after --
.
Hope that helps.