Rancher로 만든 workload의 로그를 정리해 본다.

동기 부여



로컬 PC에 Rancher로 k8s 클러스터를 세우고,
캬캬캇하면서 스스로 만든 앱을 움직이면,
에러가 나와서 짜증나게 되었다.

에러 로그를 추적하려고 생각했지만, 재미있는 전부 컨테이너의 수를 5로 한 결과,
어느 Pod에서 로그가 토해지고 있는지 모르게 되었다.

이 고민, 해소하고 싶다.

이 기사의 오치


tail -f /var/log/containers/${ワークロード名}-${なんかのID}-*

별표의 곳은, Pod의 ID가 들어가는 것 같다.

오류



정상시


↓ 놀이에 Pod를 스케일 해 연타한다.

오류


많은 포드




흠. 어떻게 하자.

잘 보면, Pod의 이름에 공통점이 있다.
첫 번째 워크로드 이름 + 무엇인가의 ID

rancher 로그의 항목을 본다.





/var/log/containers에있을 것 같습니다.

고리를 눌러 tail


tail -f /var/log/containers/sharemd-api-576f57c8fd-*

↓이런 느낌으로 출력된다.
[root@ssmzenbook ~]# tail -f /var/log/containers/sharemd-api-576f57c8fd-* 
==> /var/log/containers/sharemd-api-576f57c8fd-5466q_default_sharemd-api-6f6eb7dbeacf4d2c6343671b24a84d93b2bcd15a6ab29444076d6365fa07c6b6.log <==
{"log":" * Serving Flask app \"main\" (lazy loading)\r\n","stream":"stdout","time":"2018-08-12T12:46:39.120671317Z"}
{"log":" * Environment: production\r\n","stream":"stdout","time":"2018-08-12T12:46:39.120720386Z"}
{"log":"\u001b[31m   WARNING: Do not use the development server in a production environment.\u001b[0m\r\n","stream":"stdout","time":"2018-08-12T12:46:39.120728501Z"}
{"log":"\u001b[2m   Use a production WSGI server instead.\u001b[0m\r\n","stream":"stdout","time":"2018-08-12T12:46:39.120801044Z"}
{"log":" * Debug mode: off\r\n","stream":"stdout","time":"2018-08-12T12:46:39.120815698Z"}
{"log":" * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)\r\n","stream":"stdout","time":"2018-08-12T12:46:39.132532425Z"}

==> /var/log/containers/sharemd-api-576f57c8fd-65s42_default_sharemd-api-a64cc910ceb9680dbedcda27fdfae1a7d4dc172db31185cbfd4ebefbab05b897.log <==
{"log":" * Serving Flask app \"main\" (lazy loading)\r\n","stream":"stdout","time":"2018-08-12T12:46:34.070577741Z"}
{"log":" * Environment: production\r\n","stream":"stdout","time":"2018-08-12T12:46:34.070627264Z"}
{"log":"\u001b[31m   WARNING: Do not use the development server in a production environment.\u001b[0m\r\n","stream":"stdout","time":"2018-08-12T12:46:34.07069189Z"}
{"log":"\u001b[2m   Use a production WSGI server instead.\u001b[0m\r\n","stream":"stdout","time":"2018-08-12T12:46:34.070704736Z"}
{"log":" * Debug mode: off\r\n","stream":"stdout","time":"2018-08-12T12:46:34.070710825Z"}
{"log":" * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)\r\n","stream":"stdout","time":"2018-08-12T12:46:34.082531548Z"}

==> /var/log/containers/sharemd-api-576f57c8fd-g95qw_default_sharemd-api-94c6acb805fd4c6d908caa8638ec6853d4e516033ace296e3f83b6d543a629c3.log <==
{"log":" * Serving Flask app \"main\" (lazy loading)\r\n","stream":"stdout","time":"2018-08-12T12:46:37.15602442Z"}
{"log":" * Environment: production\r\n","stream":"stdout","time":"2018-08-12T12:46:37.156067984Z"}
{"log":"\u001b[31m   WARNING: Do not use the development server in a production environment.\u001b[0m\r\n","stream":"stdout","time":"2018-08-12T12:46:37.156073009Z"}
{"log":"\u001b[2m   Use a production WSGI server instead.\u001b[0m\r\n","stream":"stdout","time":"2018-08-12T12:46:37.156154701Z"}
{"log":" * Debug mode: off\r\n","stream":"stdout","time":"2018-08-12T12:46:37.156167877Z"}
{"log":" * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)\r\n","stream":"stdout","time":"2018-08-12T12:46:37.16624707Z"}

==> /var/log/containers/sharemd-api-576f57c8fd-g9hws_default_sharemd-api-3a05ac4762256a86b42c7f3661d3663e71f067cf5b8314bff2da2bcbd4804c9e.log <==
{"log":" * Serving Flask app \"main\" (lazy loading)\r\n","stream":"stdout","time":"2018-08-12T12:46:29.003961061Z"}
{"log":" * Environment: production\r\n","stream":"stdout","time":"2018-08-12T12:46:29.003993907Z"}
{"log":"\u001b[31m   WARNING: Do not use the development server in a production environment.\u001b[0m\r\n","stream":"stdout","time":"2018-08-12T12:46:29.004071121Z"}
{"log":"\u001b[2m   Use a production WSGI server instead.\u001b[0m\r\n","stream":"stdout","time":"2018-08-12T12:46:29.004085122Z"}
{"log":" * Debug mode: off\r\n","stream":"stdout","time":"2018-08-12T12:46:29.00408865Z"}
{"log":" * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)\r\n","stream":"stdout","time":"2018-08-12T12:46:29.015052717Z"}

==> /var/log/containers/sharemd-api-576f57c8fd-lkzn8_default_sharemd-api-d33a7859c37afc16e08b6afc0613fa9918690d2ae3844111cebe36ec01cb0651.log <==
{"log":" * Serving Flask app \"main\" (lazy loading)\r\n","stream":"stdout","time":"2018-08-12T12:46:31.899536133Z"}
{"log":" * Environment: production\r\n","stream":"stdout","time":"2018-08-12T12:46:31.899571802Z"}
{"log":"\u001b[31m   WARNING: Do not use the development server in a production environment.\u001b[0m\r\n","stream":"stdout","time":"2018-08-12T12:46:31.899576595Z"}
{"log":"\u001b[2m   Use a production WSGI server instead.\u001b[0m\r\n","stream":"stdout","time":"2018-08-12T12:46:31.899581022Z"}
{"log":" * Debug mode: off\r\n","stream":"stdout","time":"2018-08-12T12:46:31.899605233Z"}
{"log":" * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)\r\n","stream":"stdout","time":"2018-08-12T12:46:31.909541576Z"}

※기사를 만들기 위해서 tail했으므로, 에러는 나오지 않는다.

여러가지 해, 문제는 아무것도 해소하고 있지 않지만,
아무것도 남지 않는 것이 힘들기 때문에 여기에 기록을 남깁니다.
누군가의 도움이 되었으면 좋겠습니다.

좋은 웹페이지 즐겨찾기