This commit is contained in:
Beto Sánchez
2025-04-24 11:37:29 -05:00
parent bbfc836c6b
commit e52fee62b2
44 changed files with 484 additions and 293 deletions

View File

@@ -0,0 +1,8 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: fluentd-cluster-role
rules:
- apiGroups: [""]
resources: ["pods", "namespaces"]
verbs: ["get", "list", "watch"]

View File

@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: fluentd-cluster-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: fluentd-cluster-role
subjects:
- kind: ServiceAccount
name: default
namespace: kube-system

View File

@@ -0,0 +1,46 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: fluent-conf
namespace: kube-system
data:
fluent.conf: |
<source>
@type tail
path /var/log/containers/*.log
pos_file /var/log/containers.log.pos
tag kubernetes.*
format /^(?<time>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z) (?<stream>stdout|stderr) (?<log>.*)$/
time_format %Y-%m-%dT%H:%M:%S.%NZ
read_from_head true
keep_time_key true
exclude_path ["/var/log/containers/fluentd-*.log"]
</source>
<filter kubernetes.**>
@type record_transformer
enable_ruby true
<record>
log ${record["log"].gsub(/\\+/, "").gsub(/^F /, "")} # Elimina escapes y el prefijo "F "
</record>
</filter>
<filter kubernetes.**>
@type kubernetes_metadata
#@type stdout
</filter>
<match kubernetes.**>
@type remote_syslog
host nblsrv.mind.brm.co
port 5513
protocol udp
tls false
tls_verify false
<buffer>
@type memory
flush_interval 10s
chunk_limit_size 1MB
queue_limit_length 1024
</buffer>
</match>

View File

@@ -0,0 +1,57 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd
namespace: kube-system
labels:
k8s-app: fluentd-logging
spec:
selector:
matchLabels:
name: fluentd
template:
metadata:
labels:
name: fluentd
spec:
containers:
- name: fluentd
image: fluent/fluentd-kubernetes-daemonset:v1-debian-syslog
env:
- name: FLUENT_SYSLOG_HOST
value: "nblsrv.mind.brm.co" # Dirección del servidor syslog
- name: FLUENT_SYSLOG_PORT
value: "516" # Puerto del servidor syslog
- name: FLUENT_SYSLOG_PROTOCOL
value: "tcp" # Protocolo (tcp, udp o tls)
- name: FLUENT_SYSLOG_TLS
value: "false" # Habilitar TLS (true/false)
#- name: FLUENT_SYSLOG_TLS_VERIFY
# value: "false" # Verificar certificado TLS (true/false)
# - name: FLUENT_SYSLOG_TLS_CERT_PATH
# value: "/path/to/cert.pem" # Ruta al certificado TLS (opcional)
# - name: FLUENT_SYSLOG_TLS_KEY_PATH
# value: "/path/to/key.pem" # Ruta a la clave privada TLS (opcional)
# - name: FLUENT_SYSLOG_TLS_CA_PATH
# value: "/path/to/ca.pem" # Ruta al certificado de la CA (opcional)
volumeMounts:
- name: varlog
mountPath: /var/log
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
- name: fluent-conf
mountPath: /fluentd/etc/fluent.conf
subPath: fluent.conf
imagePullSecrets:
- name: ofront-gitlab-img
volumes:
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
- name: fluent-conf
configMap:
name: fluent-conf