我使用Fluentd作为侧车,将nginx日志发送到stdout,以便它们显示在Pod的日志中。我有一个奇怪的问题,当容器启动时Fluentd没有选择配置。
在检查Fluentd启动日志时,似乎没有加载配置。容器启动时,应该从/etc/fluentd- config /fluentd.conf加载配置。我已经连接到容器,配置文件是正确的,pv安装也是正确的。环境变量也存在。
完整的部署规范在下面--如果你想使用它,它是自包含的。
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: PersistentVolume
metadata:
name: weblog-pv
labels:
type: local
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
hostPath:
path: /tmp/weblog
type: DirectoryOrCreate
capacity:
storage: 500Mi
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: weblog-pvc
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 200Mi
- apiVersion: v1
kind: ConfigMap
metadata:
name: fluentd-config
data:
fluentd.conf: |
<source>
@type tail
format none
path /var/log/nginx/access.log
tag count.format1
</source>
<match *.**>
@type forward
<server>
name localhost
host 127.0.0.1
</server>
</match>
- apiVersion: v1
kind: Pod
metadata:
name: sidecar-example
labels:
app: webserver
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
volumeMounts:
- name: logging-vol
mountPath: /var/log/nginx
- name: fdlogger
env:
- name: FLUENTD_ARGS
value: -c /etc/fluentd-config/fluentd.conf
image: fluent/fluentd
volumeMounts:
- name: logging-vol
mountPath: /var/log/nginx
- name: log-config
mountPath: /etc/fluentd-config
volumes:
- name: logging-vol
persistentVolumeClaim:
claimName: weblog-pvc
- name: log-config
configMap:
name: fluentd-config
- apiVersion: v1
kind: Service
metadata:
name: sidecar-svc
spec:
selector:
app: webserver
type: NodePort
ports:
- name: sidecar-port
port: 80
nodePort: 32000发布于 2019-06-08 19:59:01
我通过使用stdout而不是重定向到localhost来让它工作。
- apiVersion: v1
kind: ConfigMap
metadata:
name: fluentd-config
data:
fluent.conf: |
<source>
@type tail
format none
path /var/log/nginx/access.log
tag count.format1
</source>
<match *.**>
@type stdout
</match>https://stackoverflow.com/questions/56505798
复制相似问题