Add lightweight logging mode (#668)
Enabled with `logging.fileMode`: true - disables elasticsearch, kibana and ingress - only enables fluentd to write logs in the node's volume - lightweight logging into files (in JSON format and compressed in gzip) - log file rotation (default: rotating files every 4 hours, retention 3 days)
This commit is contained in:
parent
86ca9c4bac
commit
7528f2ec6d
@ -20,6 +20,13 @@ And, edit `chart/examples/local-logging.yaml` for a local test.
|
|||||||
Optionally, when install the logging service only, edit `chart/admin/logging/values.yaml`.
|
Optionally, when install the logging service only, edit `chart/admin/logging/values.yaml`.
|
||||||
For a local test, it should use a hostname (not `localhost` but a hostname like `myhostname` registered in `/etc/hosts`)
|
For a local test, it should use a hostname (not `localhost` but a hostname like `myhostname` registered in `/etc/hosts`)
|
||||||
|
|
||||||
|
# Modes
|
||||||
|
|
||||||
|
* Lightweight File mode (Fluentd only mode): set `logging.fileMode` to `true`
|
||||||
|
* This will disable Elasticsearch, Kibana and Ingress.
|
||||||
|
* Log files will be placed in each node's `/var/log/fluentd/`.
|
||||||
|
* Log file's retention period: 3 days (see `templates/fluentd.yaml`)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
* run a setup script (will create a namespace and install elastic's CRDS)
|
* run a setup script (will create a namespace and install elastic's CRDS)
|
||||||
|
@ -35,6 +35,52 @@ subjects:
|
|||||||
- kind: ServiceAccount
|
- kind: ServiceAccount
|
||||||
name: fluentd
|
name: fluentd
|
||||||
namespace: {{ .Values.logging.namespace | default "btrix-admin" }}
|
namespace: {{ .Values.logging.namespace | default "btrix-admin" }}
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: fluentd-config
|
||||||
|
namespace: {{ .Values.logging.namespace | default "btrix-admin" }}
|
||||||
|
labels:
|
||||||
|
k8s-app: fluentd-logging
|
||||||
|
data:
|
||||||
|
fluent.conf: |
|
||||||
|
@include "#{ENV['FLUENTD_SYSTEMD_CONF'] || 'systemd'}.conf"
|
||||||
|
@include "#{ENV['FLUENTD_PROMETHEUS_CONF'] || 'prometheus'}.conf"
|
||||||
|
@include kubernetes.conf
|
||||||
|
@include conf.d/*.conf
|
||||||
|
|
||||||
|
<match **>
|
||||||
|
@type file
|
||||||
|
path /var/log/fluentd/btrix.log
|
||||||
|
time_slice_format %Y%m%d%H%M%S
|
||||||
|
time_slice_wait 10m
|
||||||
|
compress gzip
|
||||||
|
|
||||||
|
<format>
|
||||||
|
@type json
|
||||||
|
</format>
|
||||||
|
|
||||||
|
<buffer>
|
||||||
|
@type file
|
||||||
|
path /var/log/fluentd/buffer
|
||||||
|
flush_thread_count 2
|
||||||
|
flush_interval 5s
|
||||||
|
chunk_limit_size 1m
|
||||||
|
queue_limit_length 64
|
||||||
|
overflow_action block
|
||||||
|
</buffer>
|
||||||
|
|
||||||
|
<rotate>
|
||||||
|
@type time
|
||||||
|
timekey %Y%m%d%H%M
|
||||||
|
# How often rotate a file. 14400 means 4 hour. default is 86400 seconds (1 day)
|
||||||
|
interval 14400
|
||||||
|
# How long to keep rotated files. 0 means forever. default is 7 days
|
||||||
|
keep 3
|
||||||
|
</rotate>
|
||||||
|
</match>
|
||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: DaemonSet
|
kind: DaemonSet
|
||||||
@ -74,6 +120,7 @@ spec:
|
|||||||
valueFrom:
|
valueFrom:
|
||||||
fieldRef:
|
fieldRef:
|
||||||
fieldPath: spec.nodeName
|
fieldPath: spec.nodeName
|
||||||
|
{{ if not .Values.logging.fileMode }}
|
||||||
- name: FLUENT_ELASTICSEARCH_HOST
|
- name: FLUENT_ELASTICSEARCH_HOST
|
||||||
value: "btrixlog-es-http.{{ .Values.logging.namespace | default "btrix-admin" }}.svc.cluster.local"
|
value: "btrixlog-es-http.{{ .Values.logging.namespace | default "btrix-admin" }}.svc.cluster.local"
|
||||||
- name: FLUENT_ELASTICSEARCH_PORT
|
- name: FLUENT_ELASTICSEARCH_PORT
|
||||||
@ -99,6 +146,7 @@ spec:
|
|||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: btrixlog-es-elastic-user
|
name: btrixlog-es-elastic-user
|
||||||
key: elastic
|
key: elastic
|
||||||
|
{{ end }}
|
||||||
# =====================
|
# =====================
|
||||||
- name: FLUENT_CONTAINER_TAIL_EXCLUDE_PATH
|
- name: FLUENT_CONTAINER_TAIL_EXCLUDE_PATH
|
||||||
value: /var/log/containers/fluent*
|
value: /var/log/containers/fluent*
|
||||||
@ -114,6 +162,12 @@ spec:
|
|||||||
cpu: {{ .Values.logging.fluentd.cpu | default "60m" }}
|
cpu: {{ .Values.logging.fluentd.cpu | default "60m" }}
|
||||||
memory: {{ .Values.logging.fluentd.mem | default "200Mi" }}
|
memory: {{ .Values.logging.fluentd.mem | default "200Mi" }}
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
{{ if .Values.logging.fileMode }}
|
||||||
|
- name: config-volume
|
||||||
|
mountPath: /fluentd/etc/fluent.conf
|
||||||
|
subPath: fluent.conf
|
||||||
|
readOnly: true
|
||||||
|
{{ end }}
|
||||||
- name: varlog
|
- name: varlog
|
||||||
mountPath: {{ .Values.logging.fluentd.logVar | default "/var/log" }}
|
mountPath: {{ .Values.logging.fluentd.logVar | default "/var/log" }}
|
||||||
# When actual pod logs in /var/lib/docker/containers, the following lines should be used.
|
# When actual pod logs in /var/lib/docker/containers, the following lines should be used.
|
||||||
@ -121,11 +175,16 @@ spec:
|
|||||||
mountPath: {{ .Values.logging.fluentd.logPathContainers | default "/var/lib/docker/containers" }}
|
mountPath: {{ .Values.logging.fluentd.logPathContainers | default "/var/lib/docker/containers" }}
|
||||||
readOnly: true
|
readOnly: true
|
||||||
# When actual pod logs in /var/log/pods, the following lines should be used.
|
# When actual pod logs in /var/log/pods, the following lines should be used.
|
||||||
# - name: dockercontainerlogdirectory
|
- name: dockercontainerlogdirectory2
|
||||||
# mountPath: /var/log/pods
|
mountPath: /var/log/pods
|
||||||
# readOnly: true
|
readOnly: true
|
||||||
terminationGracePeriodSeconds: 30
|
terminationGracePeriodSeconds: 30
|
||||||
volumes:
|
volumes:
|
||||||
|
{{ if .Values.logging.fileMode }}
|
||||||
|
- name: config-volume
|
||||||
|
configMap:
|
||||||
|
name: fluentd-config
|
||||||
|
{{ end }}
|
||||||
- name: varlog
|
- name: varlog
|
||||||
hostPath:
|
hostPath:
|
||||||
path: {{ .Values.logging.fluentd.logVar | default "/var/log" }}
|
path: {{ .Values.logging.fluentd.logVar | default "/var/log" }}
|
||||||
@ -134,7 +193,7 @@ spec:
|
|||||||
hostPath:
|
hostPath:
|
||||||
path: {{ .Values.logging.fluentd.logPathContainers | default "/var/lib/docker/containers" }}
|
path: {{ .Values.logging.fluentd.logPathContainers | default "/var/lib/docker/containers" }}
|
||||||
# When actual pod logs in /var/log/pods, the following lines should be used.
|
# When actual pod logs in /var/log/pods, the following lines should be used.
|
||||||
# - name: dockercontainerlogdirectory
|
- name: dockercontainerlogdirectory2
|
||||||
# hostPath:
|
hostPath:
|
||||||
# path: /var/log/pods
|
path: /var/log/pods
|
||||||
{{- end -}}
|
{{- end -}}
|
@ -1,8 +1,11 @@
|
|||||||
{{ if .Values.logging.enabled }}
|
{{ if .Values.logging.enabled }}
|
||||||
|
|
||||||
|
{{ if not .Values.logging.fileMode }}
|
||||||
{{ include "es.install" . }}
|
{{ include "es.install" . }}
|
||||||
{{ include "kb.install" . }}
|
{{ include "kb.install" . }}
|
||||||
{{ include "ingress.install" . }}
|
{{ include "ingress.install" . }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ include "fluentd.install" . }}
|
{{ include "fluentd.install" . }}
|
||||||
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -2,21 +2,22 @@ logging:
|
|||||||
namespace: btrix-admin
|
namespace: btrix-admin
|
||||||
enabled: true
|
enabled: true
|
||||||
dedicatedNode:
|
dedicatedNode:
|
||||||
enabled: false
|
enabled: true
|
||||||
nodeType: admin
|
nodeType: admin
|
||||||
|
fileMode: true
|
||||||
ingress:
|
ingress:
|
||||||
tls: false
|
tls: false
|
||||||
host: localhost
|
host: localhost
|
||||||
path: /kibana
|
path: /kibana
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
local: true
|
local: false
|
||||||
cpu: 1
|
cpu: 1
|
||||||
mem: 4Gi
|
mem: 4Gi
|
||||||
opt: -Xms2g -Xmx2g
|
opt: -Xms2g -Xmx2g
|
||||||
volumeEnabled: false
|
volumeEnabled: false
|
||||||
volumeSize: 1Gi
|
volumeSize: 1Gi
|
||||||
kibana:
|
kibana:
|
||||||
local: true
|
local: false
|
||||||
cpu: 1
|
cpu: 1
|
||||||
mem: 1Gi
|
mem: 1Gi
|
||||||
opt: --max-old-space-size=1024
|
opt: --max-old-space-size=1024
|
||||||
|
Loading…
Reference in New Issue
Block a user