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

Kubernetes ETCDCTL

ETCD is a key-value data store for storing kubernetes state and objects. ETCDCTL is the tool used to back up with snapshot. ETCDCTL a command line tool for interacting with the etcd server  Key Features:  Keep the event history until compaction. access to old version of keys. user controlled key compaction. Support range query. pagination support with limit argument. support consistency guarantee across multiple queries. Replace TTL key with lease. Support watch feature. ETCDTOOL Installation: Build binary from source code  Download tool directly  Build binary from source code: Checkout the code repository git clone -b v3.4.16 https://github.com/etcd-io/etcd.git Change directory to etcd cd etcd Run build script ./build The binaries are under the bin directory. exportPATH="$PATH:`pwd`/bin" Check etcd version etcd --version Download ETCD tool directly: kubectl exec -it etcd-docker-desktop -n kube-system -- /bin/bash -c 'ETCDCTL_API=3 /usr/local/bin/etcd --version' | ...

PODS, SERVICES & DEPLOYMENTS

PODS Pod is a wrapper to container and it is the smallest deployable unit in Kubernetes. pod yaml configuration   Pod Useful Commands: $kubectl version --short Client Version: v1.22.4 Server Version: v1.22.4 $kubectl get svc NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE kubernetes   ClusterIP   10.96.0.1                    <none>           443/TCP   5d20h $kubectl get nodes NAME             STATUS   ROLES                       AGE     VERSION docker-desktop   Ready    control-plane,master   3d23h   v1.22.4 $kubectl cluster-info Kubernetes control plane is running at https://kubernetes.docker.internal:6443 Core...

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...