Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change fluentd config for GKE-managed logging agent?

I have a container cluster in Google Container Engine with Stackdriver logging agent enabled. It is correctly pulling stdout logs from my containers. Now I would like to change the fluentd config to specify a log parser so that the logs shown in the GCP Logging view will have the correct severity and component.

Following this Stackdriver logging guide from kubernetes.io, I have attempted to:

  1. Get the fluentd ConfigMap as a yml file
  2. Added a new <filter> according to my log4js log format
  3. Created a new ConfigMap named fluentd-cm-2 in kube-system namespace
  4. Edited the DaemonSet for fluentd and set its ConfigMap to fluentd-cm-2. I did this using kubectl edit ds instead of kubectl replace -f because the latter failed with an error message: "the object has been modified", even after getting a fresh copy of the DaemonSet yaml.

Unexpected result: The DaemonSet is restarted, but its configuration is reverted back to the original ConfigMap, so my changes did not take effect.

I have also tried editing the ConfigMap directly (kubectl edit cm fluentd-gcp-config-v1.1 --namespace kube-system) and saved it, but it was also reverted.

I noticed that the DaemonSet and ConfigMap for fluentd are tagged with addonmanager.kubernetes.io/mode: Reconcile. I would conclude that GKE has overwritten my settings because of this "reconcile" mode.

So, my question is: how can I change the fluentd configuration in a Google Container Engine cluster, when the logging agent was installed by GKE on cluster provisioning?

like image 490
edwinbs Avatar asked Sep 21 '17 00:09

edwinbs


People also ask

Can you monitor container logs for pods running on Gke?

Accessing your logs There are several different ways to access your GKE logs in Logging: Logs Explorer – You can see your logs directly from the Logs Explorer by using the logging filters to select the Kubernetes resources, such as cluster, node, namespace, pod, or container logs.

How do I get rid of Google fluent?

Uninstalling the agent Note: If you added your own fluentd configuration files, copy them from the agent's configuration directory for safekeeping. In the Windows Control Panel, choose Uninstall a program. You should see the Logging agent in the list of programs that you can uninstall.

Where are Gke logs stored?

Find your GKE logs in Cloud Logging Alternatively, you can access any of your workloads in your GKE cluster and click on the container logs links in your deployment, pod or container details; this also brings you directly to your logs in the Cloud Logging console.


1 Answers

Please take a look at the Prerequisites section on the documentation page you mentioned. It's mentioned there, that on GKE you cannot change the default Stackdriver Logging integration. The reason is that GKE maintains this configuration: updates the agent, watches its health and so on. It's not possible to provide the same level of support for all possible configurations.

However, you can always disable the default integration and deploy your own, patched version of DaemonSet. You can find out how to disable the default integration in the GKE documentation:

gcloud beta container clusters update [CLUSTER-NAME] \ --logging-service=none

Note, that after you disabled the default integration, you have to maintain the new deployment yourself: update the agent, set the resources, watch its health.

like image 124
Mik Vyatskov Avatar answered Sep 27 '22 23:09

Mik Vyatskov