Skip to main content

Kubernetes Logging

Kubernetes Logging

/var/log/containers ==> default log location on nodes. Last two log files are retained on the node.

In order to aggregate logs from varies sources like pods, containers , nodes, control plane and events we use fluentd and elastic search for searching and grafana for visualization.


Logging Architecture - Nodes:

  • Kubectl logs $POD_NAME ==> accessing pod logs
  • Kubectl logs $POD_NAME -c $CONTAINER_NAME ==> specific container inside a pod.
  • Kubectl logs $POD_NAME --all-containers
  • Kubectl logs $POD_NAME --all-containers --follow ==> real time logs
  • Kubectl logs --selector app=backend --all-containers

When an api server is down then in that case we cannot use kubectl get logs instead we can log in to a node and directly run 

  • docker logs $CONTAINER_NAME

What if docker is not available? 

  • tail -f /var/log/containers/$CONTAINER_NAME$CONTAINER_ID

Logging Architecture - Control Plane:

Get a list of control plane pods using a selector
  • kubectl get pods --namespace kube-system --selector tier=control-plane
  • kubectl logs --namespace kube-system $POD_NAME

Kubernetes Events:

Logs for resources defined in the cluster changes in resource state.
  • kubectl get events
  • kubectl describe $TYPE $NAME

Happy Learning😉

Comments

Popular posts from this blog

Ansible

 What is Ansible Ansible is a configuration management, deployment and orchestration tool. Features of Ansible Simple: Simple to install and setup Built on top of Python: Provides lot of python functionality. SSH for Secure Connection  Agentless Platform independent  Push Based unlike Puppet and Chef Install and Setup: Install Ansible via pip install ansible   Generate SSH-Key on Master node using ssh-keygen -t rsa Goto /root/.ssh and copy id_rsa.pub key to all other nodes and  Run ssh-copy-id <Destination IP Address> By default, Ansible configuration file is located under  /etc/ansible/ansible.cfg and inventory file is pointed to  /etc/ansible/hosts ansible --version shows the version of ansible is using and the configuration file it is pointing to. We can create our own inventory file filename - inventory.ini [web_servers]  web01 web02 [db_servers] db01 db02 Create a ansible.cfg file under working directory or edit the default confi...

Selenium - Basics

Selenium: Selenium is an open source automated testing Suite for web applications across different browsers and platforms. Selenium has 4 major components: Selenium Integrated Development Environment(IDE) Selenium Remote Control(RC) Web Driver Selenium Grid 1. Selenium Integrated Development Environment: Selenium IDE is the simplest framework in the Selenium Suite and very easiest to learn. It has got record playback and saving tests and inbuilt reporting tool.  2. Selenium Remote Control: Selenium RC was the flagship testing framework of the whole Selenium project for a long time. This is the first automated web testing tool where it allows users to use their programming language they prefer. RC comes in 2 forms: 2.1 Selenium Server:      Selenium Server receives selenium commands from your program, interprets them and reports  back the results of those running tests. Selenium Core is a Java Script program which execute...

Selenium Xpath

XPath  XPath is abbreviated as XML Path.  Xpath is used to find the location of any element on the web page using HTML DOM structure. Basic format of XPath is : Xpath = //tagnanme[@attribute='value'] //  : Select current node. Tagname  : Tagname of the particular node. eg : input, img, div etc @   : Select attribute. Value   : Value of the attribute. Different locators are used to find the element on web pages accurately. ID  ClassName Name LinkText XPath CSSPath Types of XPath: Absolute XPath Relative XPath Absolute xpath: It is direct way to find the element right from the root element of the webpage. The disadvantage of the absolute xpath is that if there are any changes made in the path of the element then xpath gets failed. It begins with the single forward slash(/), which means you can select the element from the root node. example : html/body/div[1]/section/div[1]/div/div/div/div[1]/div/di...