I’m trying to build a Filebeat Kubernetes Series Charm and following the docs for deploying Filebeat in Kubernetes it seems that I need to mount some volumes to receive log files from other containers. I’m trying to do this by defining volumes in the spec template and volumeMounts in the container definition. Unfortunately the volumes don’t seem to be mounting when I deploy the charm. The only way I seem to be able to mount stuff is by defining it in my spec file in the files section. Is mounting volumes the other way currently supported?
Here is the documentation that I’m following:
https://www.elastic.co/guide/en/beats/filebeat/6.0/running-on-kubernetes.html
The kubernetes file that the docs use:
https://github.com/elastic/beats/blob/master/deploy/kubernetes/filebeat-kubernetes.yaml
And my spec_template.yaml:
containers:
- name: %(name)s
imageDetails:
imagePath: %(docker_image_path)s
username: %(docker_image_username)s
password: %(docker_image_password)s
args: [
"-c", "/etc/filebeat.yml",
"-e",
]
env:
- name: ELASTICSEARCH_HOST
value: %(elasticsearch_host)s
- name: ELASTICSEARCH_PORT
value: %(elasticsearch_port)s
securityContext:
runAsUser: 0
ports:
- containerPort: %(advertised-port)s
protocol: TCP
files:
- name: config
mountPath: /etc/filebeat
files:
filebeat.yml: |
filebeat.inputs:
- type: docker
enabled: true
containers:
ids:
- '*'
processors:
- add_docker_metadata: ~
output.elasticsearch:
hosts: ["%(elasticsearch_host)s:%(elasticsearch_port)s"]
logging.to_files: true
volumeMounts:
- name: prospectors
mountPath: /usr/share/filebeat/prospectors.d
readOnly: true
- name: data
mountPath: /usr/share/filebeat/data
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
volumes:
- name: dockercontainers
hostPath:
path: /var/lib/docker/containers
- name: prospectors
configMap:
defaultMode: 0600
name: filebeat-prospectors
- name: data
emptyDir: {}