Categorygithub.com/ragoob/logger-injector
modulepackage
1.0.0
Repository: https://github.com/ragoob/logger-injector.git
Documentation: pkg.go.dev

# README

logger injector

Operator that run into K8s cluster level or outside looking into pods that match some annotations and inject a sidecar fluentd container to push the app level logs to Elastic search

workflow workflow

Design

N|Solid

How it works

The injector run on cluster level and watch all objects changes and if it contains special annotations the inector start modify the deployment or stateful pod to add fluentd side-car containers configured to look into the pod logs volume and stream the logs to elastic search

Features

  • automatic Injector (fluentd sidecar container)
  • You do not need to configure anything to your app just write your logs into volume
  • Support multiple worker threads
  • One time installation per cluster
  • support in-cluster configuration or kube config if you need to run it outside K8s cluster

Tech Stack

  • Go

Supported K8s workloads

  • Deployment
  • Stateful
  • DaemonSet
  • Job
  • Cron Job

Todo

  • Add more option to control elastic search and file formats
  • Support replication
  • Handle multiple streamer more than elastic search

Injector Configurations

VariableTypeDescription
ELASTIC_HOSTstringelastic search host
ELASTIC_PORTnumberelastic search port
ELASTIC_PASSWORDnumberelastic user password
ELASTIC_USERstringelastic user
ELASTIC_SSL_VERIFYbooleanelastic skip ssl verify default false
ELASTIC_SCHEMEstringelastic http/https default https
ELASTIC_SSL_VERSIONstringelastic tls version default TLSv1_2
FLUENTD_IMAGE_REPOSITORYstringfluentd image default fluent/fluentd-kubernetes-daemonset:v1-debian-elasticsearch
IN_CLUSTER_CONFIGbooleanSet it true if the app will run inside the cluster

App required annotations

nametypeDescription
logger.injector.io/agent-injectbooleanRequired to be true
logger.injector.io/log-tag-namestringElastic search tag for create index
logger.injector.io/flush-intervalstringFluentd flush interval default 1m
logger.injector.io/flush-intervalstringFluentd flush interval default 1m
logger.injector.io/log-path-patternstringYour log file pattern such as log*.txt default log*.log
logger.injector.io/storage-class-namestringStorage class Name to create PVC for fluentd buffer default emptyDir{}
logger.injector.io/fluentd-vol-sizestringVolume storage for fluentd buffer PV default 1 Gi

How to install

In cluster setup

  • Open bin directory and copy default.properties to the bin dir and populate your environment variables value
  • run deploy.sh

Docker stand-alone

  • create .env file from default.properties
  • populate all required environment variables
  • Make sure you have docker-compose
  • Make sure you have config file inside ~/.kube/ in your host machine
  • Run docker-compose up --build -d

# Packages

No description provided by the author
No description provided by the author
No description provided by the author