Skip to content

Instantly share code, notes, and snippets.

@jeesmon
Created February 28, 2022 14:49
Show Gist options
  • Save jeesmon/a29a34f566f80e06e790c7f8ee386efe to your computer and use it in GitHub Desktop.
Save jeesmon/a29a34f566f80e06e790c7f8ee386efe to your computer and use it in GitHub Desktop.

OpenShift 4 is an operator-focused NoOps Platform. Almost all services are managed by cluster operators with the exception of few services like crio and kubelet. crio and kubelet run as systemd services.

Systemd services are appropriate for services that you need to always come up on that particular system shortly after it starts.

  • The CRI-O container engine (crio), which runs and manages the containers
  • Kubelet (kubelet), which accepts requests for managing containers on the machine from master services

With everything else running as pods, you can monitor and debug them using traditional kubernetes debugging steps.

If you want to check logs of systemd services you normally run journalctl. That means you need to hop on to the node where it is running using oc debug. But there is an easier way to check logs of systemd services using oc cli.

# Find nodes in cluster
oc get nodes
# Get last 50 lines of kubelet log
oc adm node-logs <node_name> -u kubelet --tail 50

Note: There is a default 30 seconds context deadline set when streaming journal logs out of the nodes to protect API servers. So gather logs in a limited scope with --tail or --since or --until flags.

Similarly, you can read log files from /var/log also with same approach.

# List log files in /var/log
oc adm node-logs <node_name> --path=/
# Get /var/log/messages
oc adm node-logs <node_name> --path=/messages
# Get /var/log/audit/audit.log
oc adm node-logs <node_name> --path=/audit/audit.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment