Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Reliable Log Aggregation System in Multi-Tenant Kubernetes cluster

Reliable Log Aggregation System in Multi-Tenant Kubernetes cluster

LINE DEVDAY 2021

November 10, 2021
Tweet

More Decks by LINE DEVDAY 2021

Other Decks in Technology

Transcript

  1. Speaker: Hiroki Sakamoto - Role: Site Reliability Engineer at Verda

    - Mission: Improving System Reliability - Interest: Kubernetes, Distributed System 
  2. SRE Teams for Verda Platform wide SRE Provide Verda-Internal platform

    to improve Verda services reliability Infra Management Manage our physical infrastructure resources to host Verda services 
  3. SRE Teams for Verda Platform wide SRE Provide Verda-Internal platform

    to improve Verda services reliability Here! 
  4. Presentation Targets  Targets - The people who address the

    issues similar to ours - The people who are thinking about Multi-Tenant architecture - The people who can make decision about architecture Theme - Config Management in Multi-Tenant Kuberenetes - Operation for Fluentd in Multi-Tenant Kubernetes
  5. Benefits  - Get a useful idea to address the

    config management in Multi- Tenant Kubernetes - Get knowledge about log management and config management in Multi-Tenant Kuberetes before your release
  6. Provide Multi-Tenant Kubernetes for Verda Purpose - Aggregate infra resources

    - Standardize operations - Provide internal platform tools to reduce operation costs /PWB /FVUSPO ,FZTUPOF .POJUPSJOH -PBECBMBODFS /"5 %BTICPBSE %FTJHOBUF $JOEFS 
  7. Original log aggregation mechanism /PWB"1* emptydir -PHSPUBUFE /FVUSPO"1* emptydir -PHSPUBUFE

    Elasticsearch - Fluentd and Logrotated are in a Pod as sidecars - Emptydir is used to share log files among the containers 
  8. Original log aggregation mechanism /PWB"1* emptydir -PHSPUBUFE /FVUSPO"1* emptydir -PHSPUBUFE

    Elasticsearch Pain Points - Too many sidecars in all of the Pods - All developers must maintain Fluentd regardless of their knowledge - Lack of monitoring, taking care of performance, reliability and durability 
  9. Original log aggregation mechanism /PWB"1* emptydir -PHSPUBUFE /FVUSPO"1* emptydir -PHSPUBUFE

    Elasticsearch Hard to schedule pods efficiently due to too many containers!! 
  10. Original log aggregation mechanism /PWB"1* emptydir -PHSPUBUFE /FVUSPO"1* emptydir -PHSPUBUFE

    Elasticsearch Hard to schedule pods efficiently due to too many containers!! Quality depends on each teams 
  11. Original log aggregation mechanism /PWB"1* emptydir -PHSPUBUFE /FVUSPO"1* emptydir -PHSPUBUFE

    Elasticsearch Hard to schedule pods efficiently due to too many containers!! Quality depends on each teams Need to send “Audit logs” but don’t have enough monitoring 
  12. Original log aggregation mechanism /PWB"1* emptydir -PHSPUBUFE /FVUSPO"1* emptydir -PHSPUBUFE

    Elasticsearch 5XFNPKJzCZ$PQZSJHIU5XJUUFS *ODBOEPUIFSDPOUSJCVUPSTJTMJDFOTFEVOEFS$$#: 
  13. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder 
  14. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder Managed scope 
  15. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder Forwarders - Collect logs and send them to aggregators - Deployed as Daemonset It means that a node has only one Fluentd container 
  16. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder Aggregators - Receive logs from forwarders - Process and filter logs - Send logs to datastore like ES - Deployed as StatefulSet - With PersistentVolume 
  17. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder Why split? - Not need much resource for Daemonset - Improve Scalability - Reduce changing scope when deploying 
  18. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder Pods output logs to stdout 
  19. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout Forwarder Docker log driver copies from stdout to other log file logfile logfile 
  20. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout Forwarder Tail from the logs logfile logfile 
  21. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout Forwarder Aggregate and process logs logfile logfile 
  22. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout Forwarder Send logs logfile logfile 
  23. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder Fluentd is shared resource 
  24. For durability /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout "HHSFHBUPS/PEFT

    Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout Forwarder - Buffer logs in each host directory - Flush buffers at shutdown - Save the position it’s already read into files - Require ack response from aggregator logfile logfile 
  25. For durability /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile

    "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder - Buffer logs in each PersistentVolume - Flush buffers at shutdown - Distribute Pods across nodes 
  26. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder Pros - Developers don’t need to maintain Fluentd - Fluentd can buffer logs while the destinations are down - Easy to scale aggregators - Monitored by SRE Team so developers don’t need to do that - Ensured durability, reliability and performance by SRE Team 
  27. Managed Fluentd Cluster /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile /PEF# ,FZTUPOF /"5 -PBECBMBODFS stdout stdout stdout logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Forwarder Aggregator Aggregator Aggregator So... How do developers apply their own logging config? 5XFNPKJzCZ$PQZSJHIU5XJUUFS *ODBOEPUIFSDPOUSJCVUPSTJTMJDFOTFEVOEFS$$#: 
  28. Shared Fluentd Issues /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder 
  29. Shared Fluentd Issues /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder A team would apply... 
  30. Shared Fluentd Issues /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder The other team would apply... 
  31. Shared Fluentd Issues /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder Conflict! Conflict! Conflict! 
  32. Shared Fluentd Issues /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder Some team would apply broken config... ! 
  33. Shared Fluentd Issues /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder Process down!! 
  34. Shared Fluentd Issues /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout

    logfile "HHSFHBUPS/PEFT Elasticsearch Forwarder Aggregator Aggregator Aggregator /PEF# /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile Forwarder Process down!! What happen?! 
  35. Shared Fluentd Issues - Changes to config would be conflicted

    among some teams - Invalid config causes process down - Developers need to take care of Fluentd when applying config 
  36. Requirements  - All configs should be validated before applying

    - All configs shouldn’t affect other teams’ configs - All configs shouldn’t cause process down - All applying config shouldn’t make developers operate manually
  37. LoggingPipeline Forwarder Config Fluentd Config Operator  Forwarder Aggregator Fluentd

    Config Operator Aggregator Config FluentdNode Developers SRE
  38. Fluentd Config Operator  LoggingPipeline Forwarder Config Forwarder Aggregator Fluentd

    Config Operator Aggregator Config FluentdNode Developers SRE - Automatically validate config written in CRD “LoggingPipeline” - Automatically compile the Fluentd config to CM if the config is valid - Automatically notify Fluentd to reload new config - Automatically block config if the config is invalid
  39. LoggingPipeline Forwarder Config Fluentd Config Operator  Forwarder Aggregator Fluentd

    Config Operator Aggregator Config FluentdNode Developers SRE Apply to specify managed Fluentd
  40. LoggingPipeline Forwarder Config Fluentd Config Operator  Forwarder Aggregator Fluentd

    Config Operator Aggregator Config FluentdNode Developers SRE Apply logging config
  41. LoggingPipeline Forwarder Config Fluentd Config Operator  Forwarder Aggregator Fluentd

    Config Operator Aggregator Config FluentdNode Developers SRE Start to reoncile
  42. LoggingPipeline Forwarder Config Fluentd Config Operator  Forwarder Aggregator Fluentd

    Config Operator Aggregator Config FluentdNode Developers SRE Compile config to Configmaps for validation for forwarder for aggregator
  43. LoggingPipeline Forwarder Config Fluentd Config Operator  Forwarder Aggregator Fluentd

    Config Operator Aggregator Config FluentdNode Developers SRE for forwarder for aggregator Start validation
  44. LoggingPipeline Forwarder Config Fluentd Config Operator  Forwarder Aggregator Fluentd

    Config Operator Aggregator Config FluentdNode Developers SRE Compile & update configs If success
  45. LoggingPipeline Forwarder Config Fluentd Config Operator  Forwarder Aggregator Fluentd

    Config Operator Aggregator Config FluentdNode Developers SRE Notify Fluentd specified in FluentdNode CRD if config get updated
  46. Fluentd Config Operator  LoggingPipeline Forwarder Config Forwarder Aggregator Fluentd

    Config Operator Aggregator Config FluentdNode Developers SRE All developers need to do is specify log source and destination in CRD. 5XFNPKJzCZ$PQZSJHIU5XJUUFS *ODBOEPUIFSDPOUSJCVUPSTJTMJDFOTFEVOEFS$$#:
  47. Fluentd Config Operator  LoggingPipeline Forwarder Config Forwarder Aggregator Fluentd

    Config Operator Aggregator Config FluentdNode Developers SRE Dive into this more detail
  48. Compile LoggingPipeline  - Compile separately for forwarders and aggregators

    - Automatically complicate important parameters - Automatically wrap config with label to isolate it not to affect others - Automatically change directory to buffer logs to ensure durability
  49. Config Validation  - Run static validation - Run pod

    with dry-run command for forwarders - Run pod with actual-run to ensure connectivity to destinations for aggregators
  50. Load Test /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile

    /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile 
  51. Load Test /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile

    /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile "HHSFHBUPS/PEFT Forwarder Aggregator Aggregator Aggregator Forwarder Dark launch in prod 
  52. Load Test /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile

    /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile "HHSFHBUPS/PEFT Forwarder Aggregator Aggregator Aggregator Forwarder About 250GB/day 
  53. Load Test Results…  The CPU usage of some aggregators

    got very higher periodically regardless of plenty of aggregator instances - Event thread in Fluentd was hanging up - Connections between the aggregator and forwarders were not too much - It means that aggregation, processing and writing buffer are heavy - But I/O was not hanging up
  54. Load Test Results…  The CPU usage of some aggregators

    got very higher periodically regardless of plenty of aggregator instances - Event thread in Fluentd was hanging up - Connections between the aggregator and forwarders were not too much - It means that aggregation, processing and writing buffer are heavy - But I/O was not hanging up Log chunk size may be too much Let’s make chunk size be lower! 5XFNPKJzCZ$PQZSJHIU5XJUUFS *ODBOEPUIFSDPOUSJCVUPSTJTMJDFOTFEVOEFS$$#:
  55. Load Test Results…  The CPU usage of some aggregators

    got very higher periodically regardless of plenty of aggregator instances - Event thread in Fluentd was hanging up - Connections between the aggregator and forwarders were not too much - It means that aggregation, processing and writing buffer are heavy - But I/O was not hanging up Resolved 5XFNPKJzCZ$PQZSJHIU5XJUUFS *ODBOEPUIFSDPOUSJCVUPSTJTMJDFOTFEVOEFS$$#:
  56. Monitoring AlertManager Cluster Remote write Monitor VM Alert Fire alerts

    Query periodically /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile "HHSFHBUPS/PEFT Forwarder Aggregator Aggregator Aggregator Forwarder 
  57. Monitoring AlertManager Cluster Remote write Monitor VM Alert Fire alerts

    Query periodically /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile "HHSFHBUPS/PEFT Forwarder Aggregator Aggregator Aggregator Forwarder - Prometheus in the cluster scrape metrics from Fluentd containers - It is monitored by a Prometheus which is out of the cluster - The Prometheus writes metrics to VictoriaMetrics TSDB - VM Alert query pre-defined rules for VictoriaMetrics periodically - VM Alert fire alerts to AlertManager if match with the rules - AlertManager sends notifications to the destinations like Slack, PagerDuty 
  58. Monitoring - CPU, Memory Usage - Process down, Pod down,

    Pod restart count - Whether there is no logs which is sent to the destination - log inflow speed < log processing speed - Disk usage for buffering and buffered bytes - Number of errors and slow flush about Fluentd - Number of errors about Fluentd Config Operator 
  59. Project Results  Provided Managed Fluentd Cluster and Fluentd Config

    Operator - Got developers off maintaining Fluentd - All developers need to do is to manage their own logging config itself - Reduced about 172 containers in a cluster - Improve reliability, durability and performance about logging - Found undetected error about logging by monitoring
  60. However…  Some issues occurs after release - Docker JSON

    Log Driver splits the logs more than 16k so broken json log come to our Fluentd… - We need mechanism to notify developers parsing error
  61. Introduce Kafka and… Elasticsearch /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout

    stdout logfile /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile "HHSFHBUPS/PEFT Forwarder Aggregator Aggregator Aggregator Forwarder 
  62. Introduce Kafka and… Elasticsearch /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout

    stdout logfile /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile "HHSFHBUPS/PEFT Forwarder Aggregator Aggregator Aggregator Forwarder - Remove direct dependency between forwarder and aggregator to improve scalability - Enable developers to send logs from out of the cluster 
  63. Introduce Kafka and… Elasticsearch /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout

    stdout logfile /PEF" /PWB /FVUSPO ,FZTUPOF stdout stdout stdout logfile "HHSFHBUPS/PEFT Forwarder Aggregator Aggregator Aggregator Forwarder Standardize logging across all Verda services!