kubectl get pods
NAME READY STATUS RESTARTS AGE
httpbin-service-86444cd555-82nn6 1/1 Running 0 6m24s
查看日志
✗ kubectl logs httpbin-service-86444cd555-82nn6
[2020-07-11 16:15:52 +0000] [1] [INFO] Starting gunicorn 19.9.0
[2020-07-11 16:15:52 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
[2020-07-11 16:15:52 +0000] [1] [INFO] Using worker: gevent
[2020-07-11 16:15:52 +0000] [8] [INFO] Booting worker with pid: 8
默认日志存储路径
ls /var/log/containers/ |grep hello-world
hello-world-client-57ff5b74c6-4b7dd_baxiang_hello-world-client-b5115e3200b44e4e87402755ecc3fda987a9f077eb5cdda6911937e5c9d1e61f.log
hello-world-server-65f8648b8c-s22g2_baxiang_hello-world-server-1b2b16d41b9bd83ccfa7df42608acc47d98121c9864aeededc9c83b814a631bd.log
Pod 在 Node 节点上的日志存储位置为 /var/log/containers ,
查看日志内容
# tail hello-world-client-57ff5b74c6-4b7dd_baxiang_hello-world-client-b5115e3200b44e4e87402755ecc3fda987a9f077eb5cdda6911937e5c9d1e61f.log
{"log":" - using code:\u0009gin.SetMode(gin.ReleaseMode)\n","stream":"stdout","time":"2020-07-07T02:03:32.394140946Z"}
{"log":"\n","stream":"stdout","time":"2020-07-07T02:03:32.394143047Z"}
{"log":"[GIN-debug] GET / --\u003e main.indexHandler (3 handlers)\n","stream":"stdout","time":"2020-07-07T02:03:32.394145044Z"}
{"log":"[GIN-debug] GET /ip --\u003e main.ipHandler (3 handlers)\n","stream":"stdout","time":"2020-07-07T02:03:32.394147314Z"}
{"log":"[GIN-debug] GET /ping --\u003e main.pingHandler (3 handlers)\n","stream":"stdout","time":"2020-07-07T02:03:32.394149611Z"}
{"log":"[GIN-debug] Listening and serving HTTP on :8081\n","stream":"stdout","time":"2020-07-07T02:03:32.394162027Z"}
{"log":"[GIN] 2020/07/07 - 02:03:37 | 200 | 1.271637ms | 192.168.0.3 | GET \"/\"\n","stream":"stdout","time":"2020-07-07T02:03:37.627262063Z"}
{"log":"[GIN] 2020/07/07 - 02:03:39 | 404 | 561ns | 192.168.0.3 | GET \"/favicon.ico\"\n","stream":"stdout","time":"2020-07-07T02:03:39.798283008Z"}
{"log":"[GIN] 2020/07/07 - 02:03:46 | 200 | 1.210817ms | 192.168.0.3 | GET \"/ping\"\n","stream":"stdout","time":"2020-07-07T02:03:46.781980535Z"}
{"log":"[GIN] 2020/07/08 - 02:17:44 | 200 | 5.132089952s | 192.168.0.3 | GET \"/\"\n","stream":"stdout","time":"2020-07-08T02:17:44.58210837Z"}