<p>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.</p>

<p>Following this <a href="https://github.com/kubernetes/kubernetes.github.io/blob/master/docs/tasks/debug-application-cluster/logging-stackdriver.md" rel="noreferrer" title="Stackdriver logging guide from kubernetes.io">Stackdriver logging guide from kubernetes.io</a>, I have attempted to:</p>

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

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

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

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

<p>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?</p>

<p>Please take a look at the Prerequisites section on the <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/logging-stackdriver#configuring-stackdriver-logging-agents" rel="noreferrer">documentation page you mentioned</a>. 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.</p>

<p>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 <a href="https://cloud.google.com/container-engine/docs/logging" rel="noreferrer">GKE documentation</a>:</p>

<p><code>gcloud beta container clusters update [CLUSTER-NAME] \
  --logging-service=none</code></p>

<p>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.</p>
