KUBERNETES: A Simple Guide to Master Kubernetes for Beginners and Advanced Users (2020 Edition) by Brian Docker
Author:Brian Docker [Docker, Brian]
Language: eng
Format: azw3, epub
Published: 2020-05-14T16:00:00+00:00
Chapter 7.
Logging
When you are using monitoring functions, then you can easily dig out components that show whether your system has failed or if there is a problem you might have overlooked. However, in many cases, you might not be able to discover the root cause of the problem.
This is why you have the process of logging.
Let us take a simple example. Imagine that you have run a program that is going to produce the sum of all the numbers from 1 to 100. You know that the result is 5,050. However, as you were monitoring the process, you realized that the program skipped the number 50.
You know that there was an error in that process. But when you get the result, you notice that the final number is 4,900. You know that the program has omitted the number 50, but you don’t know what other numbers were removed and for that matter, why those numbers have been excluded. You then go to the log and notice where the errors have happened and also why they occurred.
The process of logging allows you to refine your program so that it makes fewer and fewer errors in the future. Think of it this way: monitoring allows you to effectively look at the present situation of the program. However, logging allows you go back to the beginning if you would like to and check for any inconsistencies.
Generally, there are two important posts to a logging system. You have the logging agent and then the backend.
The logging agent is a layer that is responsible for gathering information and dispatching the information to the backend. When the information reaches the backend, then all the logs are saved. One of the most challenging parts of creating logs is for Kubernetes to determine how to gather logs from various containers and then transfer them to a centralized backend. Thankfully, there is a solution for that.
The most efficient method of creating logs is to assign logging agents for each and every node and configuring them in such a way that they forward all the information to one destination. To do so, we can create what is known as a sidecar container.
A sidecar container is a special utility entity. It does not perform any actions on its own, but actually supports the main container. This process is useful to us, as we can simply create a sidecar container to deal with the logs of each container within a pod.
That way, we do not have to worry about managing each and every log file since that is automatically done by the sidecar container. Here is a script that you can use for such a sidecar container:
---6-2_logging-sidecar.yml---
apiVersion: v1
kind: Pod
metadata:
name: myapp
spec:
containers:
- image: busybox
name: application
args:
- /bin/sh
- -c
- >
while true; do
echo "$(date) INFO hello" >> /var/log/myapp.log;
sleep 1;
done
volumeMounts:
- name: log
mountPath: /var/log
- name: sidecar
image: busybox
args:
- /bin/sh
- -c
- tail -fn+1 /var/log/myapp.log
volumeMounts:
- name: log
mountPath: /var/log
volumes:
- name: log
emptyDir: {}
Source: (Baier, 2017)
With that, you have successfully created your monitoring and logging capabilities within Kubernetes.
However, there is much more to logging, especially when we take into consideration Fluentd and Elasticsearch.
Download
KUBERNETES: A Simple Guide to Master Kubernetes for Beginners and Advanced Users (2020 Edition) by Brian Docker.epub
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12555)
Hello! Python by Anthony Briggs(9904)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9785)
The Mikado Method by Ola Ellnestam Daniel Brolund(9769)
Dependency Injection in .NET by Mark Seemann(9329)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8282)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7756)
Grails in Action by Glen Smith Peter Ledbrook(7686)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7550)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7008)
Microservices with Go by Alexander Shuiskov(6774)
Practical Design Patterns for Java Developers by Miroslav Wengner(6685)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6629)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6399)
Angular Projects - Third Edition by Aristeidis Bampakos(6035)
The Art of Crafting User Stories by The Art of Crafting User Stories(5566)
NetSuite for Consultants - Second Edition by Peter Ries(5497)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5302)
Kotlin in Action by Dmitry Jemerov(5048)
