Issue here is its copying my entire fluentd-confg.yaml instead of creating fluent.conf file in the fluentd containers. I added the subPath: fluent.conf
into volumeMounts and after that there is no any file created inside any of my fluentd containers. Why its not creating fluent.conf file inside my containers?
Below file is my fluentd-confg.yaml file.
apiVersion: v1
kind: ConfigMap
metadata:
name: fluentd-config
namespace: surf-lite
data:
fluent.conf: |
<source>
@type tail
format none
path /var/log/*.log
pos_file /var/log/fluentd_pos_files/*.log.pos
</source>
<match **>
@type elasticsearch
host 192.168.4.24
port 9200
index_name mylogs
logstash_format true
</match>
Below file is my fluentd-daemonset-elasticsearch-rbac.yaml file
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: fluentd
namespace: surf-lite
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: fluentd
rules:
- apiGroups:
- ""
resources:
- pods
- namespaces
verbs:
- get
- list
- watch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: fluentd
roleRef:
kind: ClusterRole
name: fluentd
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: fluentd
namespace: surf-lite
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd
namespace: surf-lite
labels:
k8s-app: fluentd-logging
version: v1
spec:
selector:
matchLabels:
k8s-app: fluentd-logging
version: v1
template:
metadata:
labels:
k8s-app: fluentd-logging
version: v1
spec:
serviceAccount: fluentd
serviceAccountName: fluentd
tolerations:
- key: node-role.kubernetes.io/control-plane
effect: NoSchedule
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- name: fluentd
image: fluent/fluentd-kubernetes-daemonset:v1.16.1-debian-elasticsearch7-1.2
env:
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: FLUENT_ELASTICSEARCH_HOST
value: "192.168.4.24"
- name: FLUENT_ELASTICSEARCH_PORT
value: "9200"
- name: FLUENT_ELASTICSEARCH_SCHEME
value: "http"
- name: FLUENTD_SYSTEMD_CONF
value: 'disable'
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: varlog
mountPath: /var/log
- name: config-volume
mountPath: /fluent.conf
subPath: fluent.conf
terminationGracePeriodSeconds: 30
volumes:
- name: config-volume
configMap:
name: fluentd-config
- name: varlog
hostPath:
path: /var/log/pods