Setting up ERROR REPORTING for GKE

穿精又带淫゛_ 提交于 2020-01-06 21:16:47

问题


I am trying to setup Stackdriver Error Reporting for an app deployed to GKE.

As I understood there are two ways of doing that: Stackdriver Logging agent and Error Reporting REST API.

According to Setting up on Google Compute Engine docs If I already have a running logging agent I can reach it on localhost:24224.

It looks like there already is a logging agent for GKE:

✗ kubectl get pods --namespace=kube-system
NAME                                                      READY     STATUS    RESTARTS   AGE
fluentd-cloud-logging-gke-tc-default-pool-5713124a-969q   1/1       Running   0          3d

Is there a way to reach this fluentd with fluent-logger-node library?


回答1:


Steren, thanks a lot for your answer!

Let me share some details around this problem

Recently Stackdriver made fluentd ingest exception from the popular languages in GKE by default. It will be enabled in the next release of GKE and exceptions dumped to stdout/stderr of the container will be visible in Error Reporting.

Is there a way to reach this fluentd with fluent-logger-node library?

Logging agent on GCE and on GKE works differently. On GCE you install agent directly on the VM and can access it from the same VM using localhost. However, GKE operates with pods, nothing's installed directly on the node. Each pod has its own network stack, therefore when you call localhost from inside the container, you are not addressing VM, but rather this specific pod.

It's true that fluentd is deployed on each node if you enable Stackdriver Logging. However, it runs inside a container and because of that you currently cannot easily access it from your application.

In the future, Stackdriver and GKE teams will work on providing accessible node-wide fluentd port out of the box, but now, unfortunately, you have to do it yourself.

As mentioned, it may be easier to deploy another fluentd agent as a sidecar container in the application pod and configure it manually, here is an example how to do it with least efforts. In this case you will be able to access agent using localhost as if it would be on GCE.




回答2:


(Note that is not yet officially supported by Stackdriver Error Reporting)

This question and answer might help you about the fluentd configuration: How to setup error reporting in Stackdriver from kubernetes pods?

But also, since you seem to be using Node.js, I would encourage you do directly use https://github.com/GoogleCloudPlatform/cloud-errors-nodejs, which does not send errors via Logging, but directly to the Error Reporting report API.



来源:https://stackoverflow.com/questions/41863638/setting-up-error-reporting-for-gke

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!