k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/cluster/addons/fluentd-gcp/README.md (about) 1 # Stackdriver Logging Agent 2 ============== 3 4 Stackdriver Logging Agent is a DaemonSet which spawns a pod on each node 5 that reads logs, generated by kubelet, container runtime and containers 6 and sends them to the Stackdriver. When logs are exported to the Stackdriver, 7 they can be searched, viewed, and analyzed. 8 9 Learn more at: https://kubernetes.io/docs/tasks/debug-application-cluster/logging-stackdriver 10 11 ## Troubleshooting 12 13 In Kubernetes clusters in version 1.10.0 or later, fluentd-gcp DaemonSet can be 14 manually scaled. This is useful e.g. when applications running in the cluster 15 are sending a large volume of logs (i.e. over 100kB/s), causing fluentd-gcp to 16 fail with OutOfMemory errors. Conversely, if the applications aren't generating 17 a lot of logs, it may be useful to reduce the amount of resources consumed by 18 fluentd-gcp, making these resources available to other applications. To learn 19 more about Kubernetes resource requests and limits, see the official 20 documentation ([CPU][cpu], [memory][memory]). The amount of resources requested 21 by fluentd-gcp on every node in the cluster can be fetched by running following 22 command: 23 24 ``` 25 $ kubectl get ds -n kube-system -l k8s-app=fluentd-gcp \ 26 -o custom-columns=NAME:.metadata.name,\ 27 CPU_REQUEST:.spec.template.spec.containers[].resources.requests.cpu,\ 28 MEMORY_REQUEST:.spec.template.spec.containers[].resources.requests.memory,\ 29 MEMORY_LIMIT:.spec.template.spec.containers[].resources.limits.memory 30 ``` 31 32 This will display an output similar to the following: 33 34 ``` 35 NAME CPU_REQUEST MEMORY_REQUEST MEMORY_LIMIT 36 fluentd-gcp-v2.0.15 100m 200Mi 300Mi 37 ``` 38 39 In order to change those values, a [ScalingPolicy][scalingPolicy] needs to be 40 defined. Currently, only base values are supported (no automatic scaling). The 41 ScalingPolicy can be created using kubectl. E.g. to set cpu request to 101m, 42 memory request to 150Mi and memory limit to 400Mi: 43 44 ``` 45 $ cat <<EOF | kubectl apply -f - 46 apiVersion: scalingpolicy.kope.io/v1alpha1 47 kind: ScalingPolicy 48 metadata: 49 name: fluentd-gcp-scaling-policy 50 namespace: kube-system 51 spec: 52 containers: 53 - name: fluentd-gcp 54 resources: 55 requests: 56 - resource: cpu 57 base: 101m 58 - resource: memory 59 base: 150Mi 60 limits: 61 - resource: memory 62 base: 400Mi 63 EOF 64 ``` 65 66 To remove the override and go back to GKE-provided defaults, it is enough to 67 just remove the ScalingPolicy: 68 69 ``` 70 $ kubectl delete -n kube-system scalingpolicies.scalingpolicy.kope.io/fluentd-gcp-scaling-policy 71 ``` 72 73 [cpu]: https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/ 74 [memory]: https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/ 75 [scalingPolicy]: https://github.com/justinsb/scaler