Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.

Add fluentd-cloudwatch log forwarder #211

Closed
wants to merge 7 commits into from
Closed

Add fluentd-cloudwatch log forwarder #211

wants to merge 7 commits into from

Conversation

icereval
Copy link
Collaborator

@icereval icereval commented Nov 6, 2016

Adds a Fluentd Cloudwatch chart adapted from fluentd-elasticsearch.

@jmcarp

@k8s-ci-robot
Copy link
Contributor

Can a kubernetes member verify that this patch is reasonable to test? If so, please reply with "@k8s-bot ok to test" on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands will still work. Regular contributors should join the org to skip this step.

If you have questions or suggestions related to this bot's behavior, please file an issue against the kubernetes/test-infra repository.

release: "{{ .Release.Name }}"
kubernetes.io/cluster-service: "true"
annotations:
{{- include "toYaml" .Values.annotations | indent 8 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helm now comes with a built-in toYaml function, so you can change this to:

      annotations:
{{- toYaml .Values.annotations | indent 8 }}

Note though, that it needs to be unindented.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My approach for this is to use a simple key/value iterator:

annotations:
{{- range $key, $value := .Values.annotations }}
  {{ $key }}: {{ $value }}
{{- end }}

Annotations are only ever k:v anyway, so there's no need to feed them through the toYaml filter.

@@ -0,0 +1,26 @@
image: 18fgsa/fluentd-cloudwatch
imageTag: 0.1.0
namespace: kube-system
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the kube-system default a hard requirement? Generally we prefer the namespace be managed by helm using the --namespace flag.

@prydonius
Copy link
Member

@k8s-bot ok to test


| Parameter | Description | Default |
| ----------------------- | ---------------------------------- | ---------------------------------------------------------- |
| `image` | Image | `18fgsa/fluentd-cloudwatch:{VERSION}` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need the :{VERSION} here since it's declared in imageTag

release: "{{ .Release.Name }}"
kubernetes.io/cluster-service: "true"
annotations:
{{- include "toYaml" .Values.annotations | indent 8 }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My approach for this is to use a simple key/value iterator:

annotations:
{{- range $key, $value := .Values.annotations }}
  {{ $key }}: {{ $value }}
{{- end }}

Annotations are only ever k:v anyway, so there's no need to feed them through the toYaml filter.

chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: "{{ .Release.Service }}"
release: "{{ .Release.Name }}"
kubernetes.io/cluster-service: "true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the cluster-service label is needed/useful. Per the add-on docs, it only has an effect on static manifests.

- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
terminationGracePeriodSeconds: 30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you consider adding hostNetwork: {{ default false .Values.hostNetwork }} here? We rely on it to create journald log streams using the hostname.

log_group_name "#{ENV['LOG_GROUP_NAME']}"
auto_create_stream true
use_tag_as_stream true
</match>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend/request moving the fluentd config to a values.yaml key, then templating it into a ConfigMap. That would make this more of a generic fluentd chart (though with CloudWatch/ES defaults), allowing others to provide their own, custom image & settings.

@icereval
Copy link
Collaborator Author

changes made from review, thanks!

found a bug when testing w/ annotations and reported:

@viglesiasce
Copy link
Contributor

Is it possible to make this the fluentd chart instead of the fluentd-cloudwatch chart? Can we move the config file (or at least its relevant parts) into the values file (similar to the prometheus chart)?

@icereval
Copy link
Collaborator Author

I'll move the current td-agent.conf into the values.yaml and update the chart.

As for a generic chart, it seems possible though it might complicate the deployments and overall maintenance of the chart more than one would like.

Some thoughts on a possible implementation:

  • Environment variables as a generic variable to support platforms like AWS.
  • Platform & OS specific configurations in the values.yaml for td-agent.conf configurations.
  • Image can be part of the platform/os values.yaml configuration or a generic image w/ all ruby gems installed.
fluentd:
  env:
    AWS_REGION: us-east-1
    LOG_GROUP_NAME: kubernetes
  platform: googleCloud
  configurations:
    # source: https://github.com/kubernetes/kubernetes/blob/b5b47620f5f13ec2d45dd8879206b99f9a7ecc2f/cluster/addons/fluentd-gcp/fluentd-gcp-image/google-fluentd.conf
    googleCloud:
      image: kubernetes/fluentd-gcp:latest
      tdAgent: |
        # This configuration file for Fluentd / td-agent is used
        # to watch changes to Docker log files that live in the
        ...
    awsCloudWatch:
      image: 18fgsa/fluentd-cloudwatch:0.1.0
      tdAgent: |
        ...
    googleCloudJournal: |
      ...
    elasticsearch: |
      ...

Google Cloud

$ helm install --name my-release \
  --set fluentd.platform=googleCloud \
    incubator/fluentd

Google Cloud Journal

$ helm install --name my-release \
  --set fluentd.platform=googleCloudJournal \
    incubator/fluentd

AWS CloudWatch

$ helm install --name my-release \
  --set fluentd.platform=awsCloudWatch, \
    fluentd.env.AWS_REGION=us-east-1, \
    fluentd.env.LOG_GROUP_NAME=kubernetes \
    incubator/fluentd

ElasticSearch

$ helm install --name my-release \
  --set fluentd.platform=elasticseach, \
    fluentd.env.ELASTIC_SEARCH_HOST=elasticsearch-logging, \
    fluentd.env.ELASTIC_SEARCH_PORT=9200 \
    incubator/fluentd

Thoughts?

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 27, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins Charts e2e failed for commit 83dd8cd. Full PR test history.

The magic incantation to run this job again is @k8s-bot e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@viglesiasce
Copy link
Contributor

I really like the idea of allowing configurability of the platform to help guide users to the right set of working plugins and configs. How about something like:

fluentd:
  env:
    AWS_REGION: us-east-1
    LOG_GROUP_NAME: kubernetes
  platform: googleCloud

Then having the logic for which image to use in an if statement of the DaemonSet and a similar block in the ConfigMap.

@viglesiasce
Copy link
Contributor

@k8s-bot ok to test

@viglesiasce
Copy link
Contributor

This change is Reviewable

@aaglenn
Copy link

aaglenn commented Jan 23, 2017

Apologies if this is out of line. I came across this PR while looking for a fluentd Chart. My use case is strictly as a syslog ingest to influxdb store. I would like to voice my support for a generic, configurable fluentd Chart.

@viglesiasce
Copy link
Contributor

@aaglenn not out of line at all! Thanks for providing your feedback.

@viglesiasce viglesiasce modified the milestone: Milestone 1 Feb 3, 2017
@icereval
Copy link
Collaborator Author

icereval commented Feb 8, 2017

Time is spread to thin and I'm not finding an opportunity to investigate the complexities of making this more agnostic, gonna close for now.

@icereval icereval closed this Feb 8, 2017
@prydonius
Copy link
Member

FWIW I'd be okay merging this as-is and perhaps someone else can work on making it more agnostic, given it's in incubator.

@mgoodness
Copy link
Contributor

@icereval Do you mind if I step in and work on it? Mostly there, IMHO. I have an idea about making it generic while providing some example (yet usable) out-of-the-box configs.

@icereval
Copy link
Collaborator Author

icereval commented Feb 8, 2017

@mgoodness please do, not a problem at all

@so0k
Copy link
Contributor

so0k commented Mar 14, 2017

@mgoodness, as mentioned in fluent/fluentd-kubernetes-daemonset#3 - I'm making the base fluentd configurable so that multiple tags exist based on the plugins available within. I had created a PR for a fluentd-logentries Chart previously, but will look at how to use this work to base on.

old PR: #779

@so0k
Copy link
Contributor

so0k commented Mar 15, 2017

PR for unified fluentd repository @icereval - is it ok if I add your cloudwatch fluentd conf in there?

fluent/fluentd-kubernetes-daemonset#4

Edit: Done, added cloudwatch image build to fluentd-kubernetes image

@so0k
Copy link
Contributor

so0k commented Mar 15, 2017

@viglesiasce - I personally prefer config files to be in a separate folder and use the helm AsSecrets / AsConfig functions with a Files.Glob and a target directory as follows:

The advantage this gives is that you do not need to worry about the yaml format (and spacing) which you do have to worry about if you work with config files that are embedded in yaml. I find it more user friendly as well (just drop your config that you're used to in there, and run this command, done)

Your thoughts?

@so0k
Copy link
Contributor

so0k commented Apr 5, 2017

I believe this is relevant to this PR; https://github.com/krallistic/kubernetes-fluentd

kenden added a commit to kenden/charts that referenced this pull request Apr 21, 2017
The container, and the chart is not called
'fluentd-kubernetes-daemonset'

The configuration is now inside the container (from PR comment:
helm#211 (comment)),
so I removed the configMap.

The AWS keys are added as secrets from files, using Files.Glob (from PR
comment
helm#211 (comment))
kenden added a commit to kenden/charts that referenced this pull request Apr 21, 2017
The container, and the chart is not called
'fluentd-kubernetes-daemonset'

The configuration is now inside the container (from PR comment:
helm#211 (comment)),
so I removed the configMap.

The AWS keys are added as secrets from files, using Files.Glob (from PR
comment
helm#211 (comment))
kenden added a commit to kenden/charts that referenced this pull request Sep 19, 2017
The configuration is now inside the container (from PR comment:
helm#211 (comment)),
I then removed the configMap holding the config.

The AWS keys are added as secrets from files, using Files.Glob (from PR
comment
helm#211 (comment))
unguiculus pushed a commit that referenced this pull request Oct 12, 2017
* fluentd cloudwatch incubator

* rename deployment -> daemonset

* annotations as value

* reorder values

* use helm namespace

* address code review

* move td-agent.conf into values.yaml

* Updated fluentd-cloudwatch code from PR 211

The configuration is now inside the container (from PR comment:
#211 (comment)),
I then removed the configMap holding the config.

The AWS keys are added as secrets from files, using Files.Glob (from PR
comment
#211 (comment))

* Add configMap for fluentd config

Copied the config from what's in
/fluentd/etc in image:
fluent/fluentd-kubernetes-daemonset:v0.12-cloudwatch

* Update to use namespaces

* Add appVersion

* Add fluentd icon

* Using github usernames instead of real names

* Update label for configmap
dnelson pushed a commit to Vungle/charts that referenced this pull request Oct 26, 2017
* fluentd cloudwatch incubator

* rename deployment -> daemonset

* annotations as value

* reorder values

* use helm namespace

* address code review

* move td-agent.conf into values.yaml

* Updated fluentd-cloudwatch code from PR 211

The configuration is now inside the container (from PR comment:
helm#211 (comment)),
I then removed the configMap holding the config.

The AWS keys are added as secrets from files, using Files.Glob (from PR
comment
helm#211 (comment))

* Add configMap for fluentd config

Copied the config from what's in
/fluentd/etc in image:
fluent/fluentd-kubernetes-daemonset:v0.12-cloudwatch

* Update to use namespaces

* Add appVersion

* Add fluentd icon

* Using github usernames instead of real names

* Update label for configmap
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
changes needed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants