This commit is contained in:
sdjo 2024-09-30 10:35:49 +09:00
parent aed62bba7b
commit 4692a443c5
6 changed files with 487 additions and 0 deletions

View File

@ -0,0 +1,55 @@
---
# Source: fluent-bit/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: fluent-bit
namespace: logging
labels:
helm.sh/chart: fluent-bit-0.47.9
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
app.kubernetes.io/version: "3.1.7"
app.kubernetes.io/managed-by: Helm
---
# Source: fluent-bit/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: fluent-bit
labels:
helm.sh/chart: fluent-bit-0.47.9
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
app.kubernetes.io/version: "3.1.7"
app.kubernetes.io/managed-by: Helm
rules:
- apiGroups:
- ""
resources:
- namespaces
- pods
verbs:
- get
- list
- watch
---
# Source: fluent-bit/templates/clusterrolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: fluent-bit
labels:
helm.sh/chart: fluent-bit-0.47.9
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
app.kubernetes.io/version: "3.1.7"
app.kubernetes.io/managed-by: Helm
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: fluent-bit
subjects:
- kind: ServiceAccount
name: fluent-bit
namespace: logging

View File

@ -0,0 +1,69 @@
# Source: fluent-bit/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: fluent-bit
namespace: logging
labels:
helm.sh/chart: fluent-bit-0.47.9
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
app.kubernetes.io/version: "3.1.7"
app.kubernetes.io/managed-by: Helm
data:
custom_parsers.conf: |
[PARSER]
Name docker_no_time
Format json
Time_Keep Off
Time_Key time
Time_Format %Y-%m-%dT%H:%M:%S.%L
fluent-bit.conf: |
[SERVICE]
Daemon Off
Flush 1
Log_Level info
Parsers_File /fluent-bit/etc/parsers.conf
Parsers_File /fluent-bit/etc/conf/custom_parsers.conf
HTTP_Server On
HTTP_Listen 0.0.0.0
HTTP_Port 2020
Health_Check On
[INPUT]
Name tail
Path /var/log/containers/*.log
multiline.parser docker, cri
Tag kube.*
Mem_Buf_Limit 5MB
Skip_Long_Lines On
[INPUT]
Name systemd
Tag host.*
Systemd_Filter _SYSTEMD_UNIT=kubelet.service
Read_From_Tail On
[FILTER]
Name kubernetes
Match kube.*
Merge_Log On
Keep_Log Off
K8S-Logging.Parser On
K8S-Logging.Exclude On
[OUTPUT]
Name es
Match kube.*
Host elasticsearch-master
Logstash_Format On
Retry_Limit False
[OUTPUT]
Name es
Match host.*
Host elasticsearch-master
Logstash_Format On
Logstash_Prefix node
Retry_Limit False

View File

@ -0,0 +1,73 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: fluent-bit
namespace: logging
labels:
app.kubernetes.io/name: fluentbit
app.kubernetes.io/instance: fluent-bit
app.kubernetes.io/version: "3.1.7"
data:
custom_parsers.conf: |
[PARSER]
Name cri
Format regex
Regex ^(?<time>[^ ]+) (?<stream>stdout|stderr) (?<logtag>[^ ]*) (?<message>.*)$
Time_Key time
Time_Format %Y-%m-%dT%H:%M:%S.%L%z
Decode_Field_As json message
[PARSER]
Name svcname
Format regex
Regex /sample-(?<servicename>.+)-dp-[^-]+-[^-]+_(?<namespace>.+)_.+-con-[^-]+.log$
fluent-bit.conf: |
[SERVICE]
Flush 5
Log_Level info
Daemon off
Parsers_File /fluent-bit/etc/parsers.conf
Parsers_File /fluent-bit/etc/conf/custom_parsers.conf
HTTP_Server On
HTTP_Listen 0.0.0.0
HTTP_Port 2020
Health_Check On
storage.path /var/fluent-bit/state/flb-storage/
storage.sync normal
storage.checksum off
storage.backlog.mem_limit 5M
@INCLUDE input-kubernetes.conf
# @INCLUDE filter-kubernetes.conf
@INCLUDE output-file.conf
input-kubernetes.conf: |
[INPUT]
Name tail
Parser cri
Path /var/log/containers/blog-*-dp-*-*_blog_*-con-*.log
DB /var/fluent-bit/state/flb_log.db
Tag blog.<service_name>
Tag_Regex /blog-(?<service_name>.+)-dp-[^-]+-[^-]+_blog_.+-con-[^-]+.log$
Mem_Buf_Limit 5MB
Skip_Long_Lines On
Refresh_Interval 10
Path_key svc_name
filter-kubernetes.conf: |
[FILTER]
Name parser
Match blog.*
Key_name svc_name
reserve_data On
Parser svcname
output-file.conf: |
[OUTPUT]
Name file
Match blog.*
Path /home/ubuntu
file fluentbit-scrape.txt

View File

@ -0,0 +1,137 @@
# Source: fluent-bit/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: fluent-bit
namespace: logging
labels:
helm.sh/chart: fluent-bit-0.47.9
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
app.kubernetes.io/version: "3.1.7"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 2020
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
---
# Source: fluent-bit/templates/daemonset.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluent-bit
namespace: logging
labels:
helm.sh/chart: fluent-bit-0.47.9
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
app.kubernetes.io/version: "3.1.7"
app.kubernetes.io/managed-by: Helm
spec:
selector:
matchLabels:
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
template:
metadata:
labels:
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
annotations:
checksum/config: 19631ad1090fbeaf145be8a25d43bf24621413639593494df4b243914c27e763
spec:
serviceAccountName: fluent-bit
hostNetwork: false
dnsPolicy: ClusterFirst
containers:
- name: fluent-bit
image: "cr.fluentbit.io/fluent/fluent-bit:3.1.7-debug"
imagePullPolicy: IfNotPresent
command:
- /fluent-bit/bin/fluent-bit
args:
- --workdir=/fluent-bit/etc
- --config=/fluent-bit/etc/conf/fluent-bit.conf
ports:
- name: http
containerPort: 2020
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /api/v1/health
port: http
volumeMounts:
- name: config
mountPath: /fluent-bit/etc/conf
- mountPath: /var/log
name: varlog
- mountPath: /var/lib/docker/containers
name: varlibdockercontainers
readOnly: true
- mountPath: /etc/machine-id
name: etcmachineid
readOnly: true
# Custom Add
- name: runlogjournal
mountPath: /run/log/journal
readOnly: true
# - name: dmesg
# mountPath: /var/log/dmesg
# readOnly: true
- name: mnt
mountPath: /mnt
readOnly: true
- name: fluentbitstate
mountPath: /var/fluent-bit/state
- name: file-save
mountPath: /home/ubuntu
# https://docs.fluentbit.io/manual/pipeline/filters/kubernetes
resources:
limits:
cpu: 500m
memory: 500Mi
requests:
cpu: 500m
memory: 500Mi
volumes:
- name: config
configMap:
name: fluent-bit
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
- name: etcmachineid
hostPath:
path: /etc/machine-id
type: File
# Custom Add
## for cash
- name: fluentbitstate
hostPath:
path: /var/fluent-bit/state
- name: runlogjournal # 있음
hostPath:
path: /run/log/journal
# - name: dmesg # 있음
# hostPath:
# path: /var/log/dmesg
- name: mnt # 있음
hostPath:
path: /mnt
- name: file-save # 있음
hostPath:
path: /home/ubuntu

View File

@ -0,0 +1,132 @@
# Source: fluent-bit/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: fluent-bit
namespace: logging
labels:
helm.sh/chart: fluent-bit-0.47.9
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
app.kubernetes.io/version: "3.1.7"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 2020
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
---
# Source: fluent-bit/templates/daemonset.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluent-bit
namespace: logging
labels:
helm.sh/chart: fluent-bit-0.47.9
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
app.kubernetes.io/version: "3.1.7"
app.kubernetes.io/managed-by: Helm
spec:
selector:
matchLabels:
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
template:
metadata:
labels:
app.kubernetes.io/name: fluent-bit
app.kubernetes.io/instance: fluent-bit
annotations:
checksum/config: 19631ad1090fbeaf145be8a25d43bf24621413639593494df4b243914c27e763
spec:
serviceAccountName: fluent-bit
hostNetwork: false
dnsPolicy: ClusterFirst
containers:
- name: fluent-bit
image: "cr.fluentbit.io/fluent/fluent-bit:3.1.7"
imagePullPolicy: IfNotPresent
command:
- /fluent-bit/bin/fluent-bit
args:
- --workdir=/fluent-bit/etc
- --config=/fluent-bit/etc/conf/fluent-bit.conf
ports:
- name: http
containerPort: 2020
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /api/v1/health
port: http
volumeMounts:
- name: config
mountPath: /fluent-bit/etc/conf
- mountPath: /var/log
name: varlog
- mountPath: /var/lib/docker/containers
name: varlibdockercontainers
readOnly: true
- mountPath: /etc/machine-id
name: etcmachineid
readOnly: true
# Custom Add
- name: runlogjournal
mountPath: /run/log/journal
readOnly: true
# - name: dmesg
# mountPath: /var/log/dmesg
# readOnly: true
- name: mnt
mountPath: /mnt
readOnly: true
- name: fluentbitstate
mountPath: /var/fluent-bit/state
# https://docs.fluentbit.io/manual/pipeline/filters/kubernetes
resources:
limits:
cpu: 500m
memory: 500Mi
requests:
cpu: 500m
memory: 500Mi
volumes:
- name: config
configMap:
name: fluent-bit
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
- name: etcmachineid
hostPath:
path: /etc/machine-id
type: File
# Custom Add
## for cash
- name: fluentbitstate
hostPath:
path: /var/fluent-bit/state
- name: runlogjournal # 있음
hostPath:
path: /run/log/journal
# - name: dmesg # 있음
# hostPath:
# path: /var/log/dmesg
- name: mnt # 있음
hostPath:
path: /mnt

View File

@ -0,0 +1,21 @@
# Source: fluent-bit/templates/tests/test-connection.yaml
apiVersion: v1
kind: Pod
metadata:
name: "fluent-bit-test-connection"
namespace: logging
labels:
helm.sh/chart: fluent-bit-0.47.9
app.kubernetes.io/version: "3.1.7"
app.kubernetes.io/managed-by: Helm
annotations:
helm.sh/hook: test
helm.sh/hook-delete-policy: hook-succeeded
spec:
containers:
- name: wget
image: "busybox:latest"
imagePullPolicy: Always
command: ["sh"]
args: ["-c", "wget -O- fluent-bit:2020"]
restartPolicy: Never