Giter Site home page Giter Site logo

mshivanna / kubernetes-fluentd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from upmc-enterprises/kubernetes-fluentd

0.0 1.0 0.0 20 KB

Send logs files from a Kubernetes cluster via Fluentd

License: Other

Dockerfile 55.93% Makefile 5.32% Ruby 37.09% Shell 1.67%

kubernetes-fluentd's Introduction

kubernetes-fluentd

Kubernetes Logger is designed to take all of the logs from your containers and system and forward them to a central location. Today this can be a S3 bucket in AWS or a ElasticSearch cluster (or both). The logger is intended to be a DaemonSet which will run a pod on each Node in your cluster. Fluentd is the forwarder agent which has a configuration file to configure the different output destinations for your logs.

Currently the sample container has both the S3 plugin as well as the Elasticsearch plugin installed by default. Please customize the fluent.conf to your satisfaction to enable or disable one or the other.

Deployment

Deployment to a Kubernetes cluster is maintained by a DaemonSet. The DaemonSet requires a ConfigMap to pass parameters to the DaemonSet.

  1. Create bucket in S3 changing the value of 'steve_bucket' to your unique bucket name:

    $ aws s3api create-bucket --bucket steve_bucket --region us-east-1
    
  2. Edit the file 's3_iam_role.json' and update the value '{YOUR_BUCKET}' with the value of the bucket created in the previous step. In the following example my bucket name is 'steve_bucket':

    $ sed 's/{YOUR_BUCKET}/steve_bucket/g' s3_iam_role.json > s3_iam_role_complete.json
    
  3. Create an IAM policy to allow access to the S3 bucket:

    $ aws iam create-policy --policy-name kubernetes-fluentd-s3-logging --policy-document file://s3_iam_role_complete.json
    
  4. Attach the policy to the IAM Role for the Kubernetes workers:

    # Find RoleName for the worker role
    $ aws iam list-roles | grep -i iamroleworker
    
    # Attach policy
    $ aws iam attach-role-policy --policy-arn <ARN_of_policy_created_in_previous_step> --role-name <RoleName>
    Create the ConfigMap specifying the correct values for your environment:
    $ kubectl create configmap fluentd-conf --from-literal=AWS_S3_BUCKET_NAME=<!YOUR_BUCKET_NAME!> --from-literal=AWS_S3_LOGS_BUCKET_PREFIX=<!YOUR_BUCKET_PREFIX!>  --from-literal=AWS_S3_LOGS_BUCKET_PREFIX_KUBESYSTEM=<!YOUR_BUCKET_PREFIX!> --from-literal=AWS_S3_LOGS_BUCKET_REGION=<!YOUR_BUCKET_REGION!> --from-file=fluent_s3.conf -n kube-system
    
    Variable Description
    AWS_S3_BUCKET_NAME Name of the S3 bucket
    AWS_S3_LOGS_BUCKET_PREFIX The prefix to place the application logs into (e.g. k8s-logs/logs/)
    AWS_S3_LOGS_BUCKET_PREFIX_KUBESYSTEM The prefix to place the system logs into (e.g. k8s-logs/kubesystem-logs/)
    AWS_S3_LOGS_BUCKET_REGION AWS Region
  5. Deploy the daemonset:

    $ kubectl create -f https://raw.githubusercontent.com/upmc-enterprises/kubernetes-fluentd/master/fluentd_s3.yaml
    
  6. Verify logs are writing to S3:

    $ aws s3api list-objects --bucket steve_bucket
    

Deploy ELK Stack

For a simple ELK stack to get started, deploy the following:

kubectl create -f https://raw.githubusercontent.com/kubernetes/kubernetes/master/cluster/addons/fluentd-elasticsearch/es-controller.yaml
kubectl create -f https://raw.githubusercontent.com/kubernetes/kubernetes/master/cluster/addons/fluentd-elasticsearch/es-service.yaml
kubectl create -f https://raw.githubusercontent.com/kubernetes/kubernetes/master/cluster/addons/fluentd-elasticsearch/kibana-controller.yaml
kubectl create -f https://raw.githubusercontent.com/kubernetes/kubernetes/master/cluster/addons/fluentd-elasticsearch/kibana-service.yaml

Source: https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/fluentd-elasticsearch

About

Built by UPMC Enterprises in Pittsburgh, PA. http://enterprises.upmc.com/

kubernetes-fluentd's People

Contributors

stevesloka avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.