From 640bfd5d84fc9e7a8200c86a3508ce32c0592faf Mon Sep 17 00:00:00 2001 From: bborbely Date: Tue, 18 Jun 2019 13:22:38 +0200 Subject: [PATCH] Hybrid logging MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The fluentd component has moved to helm chart, too. Now can be configured to use elasticsearch or remote_syslog for logging Signed-off-by: Botond Borbély Change-Id: I81b5342f9325652ac343e1b4d201d232b034a245 --- SPECS/fluentd.spec | 19 +--- ansible/playbooks/fluentd.yaml | 23 ----- ansible/roles/fluentd/meta/main.yml | 32 ------- ansible/roles/fluentd/tasks/main.yaml | 34 -------- ansible/roles/fluentd/templates/fluentd-cm.yaml | 64 -------------- ansible/roles/fluentd/templates/fluentd-ds.yaml | 111 ------------------------ docker-build/fluentd/Dockerfile | 8 +- docker-build/fluentd/bom.json | 18 ++++ docker-build/fluentd/conf/fluent.conf | 19 ---- 9 files changed, 21 insertions(+), 307 deletions(-) delete mode 100644 ansible/playbooks/fluentd.yaml delete mode 100644 ansible/roles/fluentd/meta/main.yml delete mode 100644 ansible/roles/fluentd/tasks/main.yaml delete mode 100644 ansible/roles/fluentd/templates/fluentd-cm.yaml delete mode 100644 ansible/roles/fluentd/templates/fluentd-ds.yaml delete mode 100644 docker-build/fluentd/conf/fluent.conf diff --git a/SPECS/fluentd.spec b/SPECS/fluentd.spec index 6af5a31..3e1d394 100644 --- a/SPECS/fluentd.spec +++ b/SPECS/fluentd.spec @@ -15,7 +15,7 @@ %define COMPONENT fluentd %define RPM_NAME caas-%{COMPONENT} %define RPM_MAJOR_VERSION 1.5.2 -%define RPM_MINOR_VERSION 1 +%define RPM_MINOR_VERSION 2 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION} Name: %{RPM_NAME} @@ -62,27 +62,10 @@ docker rmi -f %{COMPONENT}:%{IMAGE_TAG} mkdir -p %{buildroot}/%{_caas_container_tar_path}/ rsync -av %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save/%{COMPONENT}:%{IMAGE_TAG}.tar %{buildroot}/%{_caas_container_tar_path}/ -mkdir -p %{buildroot}/%{_playbooks_path}/ -rsync -av ansible/playbooks/fluentd.yaml %{buildroot}/%{_playbooks_path}/ - -mkdir -p %{buildroot}/%{_roles_path}/ -rsync -av ansible/roles/fluentd %{buildroot}/%{_roles_path}/ - %files %{_caas_container_tar_path}/%{COMPONENT}:%{IMAGE_TAG}.tar -%{_playbooks_path}/fluentd.yaml -%{_roles_path}/fluentd %preun - %post -mkdir -p %{_postconfig_path}/ -ln -sf %{_playbooks_path}/fluentd.yaml %{_postconfig_path}/ - -%postun -if [ $1 -eq 0 ]; then - rm -f %{_postconfig_path}/fluentd.yaml -fi - %clean rm -rf ${buildroot} diff --git a/ansible/playbooks/fluentd.yaml b/ansible/playbooks/fluentd.yaml deleted file mode 100644 index 943ae23..0000000 --- a/ansible/playbooks/fluentd.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -# Copyright 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# cmframework.requires: install_caas_infra.yaml -- hosts: installation_controller:&caas_master - strategy: free - become: true - become_user: "{{ users.admin_user_name }}" - roles: - - fluentd - diff --git a/ansible/roles/fluentd/meta/main.yml b/ansible/roles/fluentd/meta/main.yml deleted file mode 100644 index ab6a42a..0000000 --- a/ansible/roles/fluentd/meta/main.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -# Copyright 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -dependencies: - - role: cert - instance: "fluentd" - cert_path: /etc/fluentd/ssl - become: true - become_user: "root" - - - role: docker_image_load - images: - - fluentd - - - role: docker_image_push - images: - - fluentd - when: nodename | search("caas_master1") - - - role: manifests diff --git a/ansible/roles/fluentd/tasks/main.yaml b/ansible/roles/fluentd/tasks/main.yaml deleted file mode 100644 index 53011df..0000000 --- a/ansible/roles/fluentd/tasks/main.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -# Copyright 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- name: template Fluentd DaemonSet file - template: - src: fluentd-ds.yaml - dest: "{{ caas.manifests_directory }}/fluentd-ds.yaml" - -- name: template Fluentd ConfigMap file - template: - src: fluentd-cm.yaml - dest: "{{ caas.manifests_directory }}/fluentd-cm.yaml" - -- name: create Fluentd ConfigMap - kubectl: - manifest: "{{ caas.manifests_directory }}/fluentd-cm.yaml" - state: present - -- name: create DaemonSet for fluentd - kubectl: - manifest: "{{ caas.manifests_directory }}/fluentd-ds.yaml" - state: present diff --git a/ansible/roles/fluentd/templates/fluentd-cm.yaml b/ansible/roles/fluentd/templates/fluentd-cm.yaml deleted file mode 100644 index fb58c0d..0000000 --- a/ansible/roles/fluentd/templates/fluentd-cm.yaml +++ /dev/null @@ -1,64 +0,0 @@ -{# -Copyright 2019 Nokia - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -#} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: fluentd-cm - namespace: kube-system -data: - #Take care that the files will be processed by fluentd in alphabetical order - 01-fluentd_kubernetes.conf: |- - - # Look for files of type *kube-system* and add tag kubernetes - - @type tail - path /var/log/containers/*kube-system*.log - pos_file /fluentd/log/fluentd-kubernetes.log.pos - time_format %Y-%m-%dT%H:%M:%S.%NZ - tag kubernetes.* - format json - read_from_head true - - # Add kubernetes metadata to "kubernetes" tagged messages - - @type kubernetes_metadata - - - 02-fluentd_elasticsearch.conf: |- - - # Forward all messages with either kubenetes tag to elasticsearch - - @type elasticsearch - @log_level info - include_tag_key true - host "{{ caas.elasticsearch_url }}" - port "{{ caas.elasticsearch_port }}" - scheme "{{ elasticsearch_sheme | default('http') }}" - user "{{ elasticsearch_user | default('elastic') }}" - password "{{ elasticsearch_passwd | default('changeme') }}" - ssl_verify "{{ elasticsearch_ssl | default('true') }}" - reload_connections "{{ elasticsearch_reload_connections | default('true') }}" - logstash_prefix "{{ elasticsearch_logstash_prefix | default('logstash') }}" - logstash_format true - reconnect_on_error true - resurrect_after 5s - - chunk_limit_size 256m - flush_at_shutdown "true" - flush_interval 5s - - diff --git a/ansible/roles/fluentd/templates/fluentd-ds.yaml b/ansible/roles/fluentd/templates/fluentd-ds.yaml deleted file mode 100644 index a80cfd6..0000000 --- a/ansible/roles/fluentd/templates/fluentd-ds.yaml +++ /dev/null @@ -1,111 +0,0 @@ -{# -Copyright 2019 Nokia - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -#} ---- -apiVersion: apps/v1beta2 -kind: DaemonSet -metadata: - name: fluentd - namespace: kube-system - labels: - {{ caas.kubernetes_component_label }}: fluentd-logging - version: v1 - kubernetes.io/cluster-service: "true" -spec: - selector: - matchLabels: - {{ caas.kubernetes_component_label }}: fluentd-logging - template: - metadata: - annotations: - danm.k8s.io/interfaces: | - [ - { - "network":"flannel" - } - ] - labels: - {{ caas.kubernetes_component_label }}: fluentd-logging - version: v1 - kubernetes.io/cluster-service: "true" - spec: - dnsPolicy: ClusterFirst - containers: - - name: fluentd - image: {{ container_image_names | select('search', '/fluentd') | list | last }} - command: - - "/bin/entrypoint.sh" - - "fluentd" - - "-c" - - "/fluentd/etc/fluent.conf" - - "-p" - - "/fluentd/plugins" - securityContext: - capabilities: - add: - - ALL - env: - - name: KUBERNETES_SERVICE_HOST - value: "{{ caas.apiserver_service_name }}" - - name: KUBERNETES_SERVICE_PORT - value: "{{ caas.apiserver_svc_port }}" - - name: FLUENT_ELASTICSEARCH_HOST - value: "{{ caas.elasticsearch_url }}" - - name: FLUENT_ELASTICSEARCH_PORT - value: "{{ caas.elasticsearch_port }}" - - name: FLUENT_ELASTICSEARCH_SCHEME - value: "http" - - name: FLUENT_ELASTICSEARCH_USER - value: "elastic" - - name: FLUENT_ELASTICSEARCH_PASSWORD - value: "changeme" - - name: FLUENT_ELASTICSEARCH_SSL - value: "false" - - name: FLUENTD_OPT - value: "" - # TODO: change it to a dynamic ConfigMap, in case something needs to be run-time configurable - - name: FLUENTD_CONF - value: "fluent.conf" - volumeMounts: - - name: time-mount - mountPath: /etc/localtime - readOnly: true - - name: varlog - mountPath: /var/log - - name: varlibdockercontainers - mountPath: /var/lib/docker/containers - - name: fluentd-secrets - mountPath: /etc/fluentd/ssl - readOnly: true - - name: fluentd-config - mountPath: /etc/fluentd/config.d - terminationGracePeriodSeconds: 30 - volumes: - - name: time-mount - hostPath: - path: /etc/localtime - - name: varlog - hostPath: - path: /var/log - - name: varlibdockercontainers - hostPath: - path: /var/lib/docker/containers - - name: fluentd-secrets - hostPath: - path: /etc/fluentd/ssl - - name: fluentd-config - configMap: - name: fluentd-cm - serviceAccountName: fluentd diff --git a/docker-build/fluentd/Dockerfile b/docker-build/fluentd/Dockerfile index 1d805f9..d4b6456 100644 --- a/docker-build/fluentd/Dockerfile +++ b/docker-build/fluentd/Dockerfile @@ -13,7 +13,7 @@ # limitations under the License. FROM alpine:3.9 -MAINTAINER Levente Kale +MAINTAINER Levente Kale ARG VERSION ENV FLUENTD_VERSION=$VERSION @@ -48,6 +48,7 @@ RUN apk update \ && gem install fluent-plugin-record-reformer \ && gem install fluent-plugin-rewrite-tag-filter \ && gem install fluent-plugin-elasticsearch \ +&& gem install fluent-plugin-remote_syslog \ && gem install fluent-plugin-kubernetes_metadata_filter \ && gem install bigdecimal \ && gem install etc \ @@ -60,8 +61,3 @@ RUN apk update \ && mkdir -p /fluentd/etc /fluentd/plugins \ && chmod +x /bin/entrypoint.sh \ && chmod 700 /fluentd/log - -# Copy configuration files -# TODO: change it to a dynamic ConfigMap, in case something needs to be run-time configurable -COPY ./conf/fluent.conf /fluentd/etc/ - diff --git a/docker-build/fluentd/bom.json b/docker-build/fluentd/bom.json index 4edcc6b..a3f6f4d 100644 --- a/docker-build/fluentd/bom.json +++ b/docker-build/fluentd/bom.json @@ -342,6 +342,24 @@ "source-url": "https://github.com/uken/fluent-plugin-elasticsearch/archive/v3.2.1.tar.gz", "foss": "yes" }, + { + "name": "fluent-plugin-remote_syslog", + "version": "1.0.0", + "source-url": "https://github.com/dlackty/fluent-plugin-remote_syslog/archive/v1.0.0.tar.gz", + "foss": "yes" + }, + { + "name": "remote_syslog_sender", + "version": "1.2.1", + "source-url": "https://github.com/reproio/remote_syslog_sender/archive/v1.2.1.tar.gz", + "foss": "yes" + }, + { + "name": "syslog_protocol", + "version": "0.9.2", + "source-url": "https://github.com/eric/syslog_protocol/archive/v0.9.2.tar.gz", + "foss": "yes" + }, { "name": "fluent-plugin-kubernetes_metadata_filter", "version": "2.1.6", diff --git a/docker-build/fluentd/conf/fluent.conf b/docker-build/fluentd/conf/fluent.conf deleted file mode 100644 index a943535..0000000 --- a/docker-build/fluentd/conf/fluent.conf +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2019 Nokia -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - @type null - - -@include /etc/fluentd/config.d/*.conf - -- 2.16.6