Kubernetes Container Orchestration Monitoring and Logging 2 — Questions and Answers
Question 1: Which Kubernetes resource allows you to define alerting rules based on Prometheus metrics?
- PrometheusRule (Correct answer)
- AlertPolicy
- MetricAlert
- RuleSet
Correct answer: PrometheusRule
PrometheusRule is a custom resource definition (CRD) used by the Prometheus Operator to define alerting and recording rules.
Question 2: What does the `kubectl top nodes` command display?
- CPU and memory usage of nodes (Correct answer)
- Disk I/O per node
- Network bandwidth per node
- Pod count per node
Correct answer: CPU and memory usage of nodes
`kubectl top nodes` shows the current CPU and memory resource consumption for each node in the cluster.
Question 3: In Kubernetes, which component is responsible for collecting and serving resource metrics used by HPA?
- Metrics Server (Correct answer)
- kube-state-metrics
- cAdvisor
- Prometheus
Correct answer: Metrics Server
Metrics Server aggregates resource usage data from kubelets and exposes it via the Kubernetes Metrics API for HPA and `kubectl top`.
Question 4: Which log driver is commonly used when running Kubernetes nodes to forward container logs to a centralized system?
- json-file
- fluentd (Correct answer)
- syslog
- journald
Correct answer: fluentd
Fluentd is a widely used log driver and DaemonSet-based agent that collects and forwards container logs to backends like Elasticsearch.
Question 5: What is the purpose of kube-state-metrics in a Kubernetes monitoring setup?
- Exposes metrics about the state of Kubernetes objects (Correct answer)
- Collects container CPU and memory metrics
- Provides node-level disk usage stats
- Aggregates logs from all namespaces
Correct answer: Exposes metrics about the state of Kubernetes objects
kube-state-metrics listens to the Kubernetes API and generates metrics about the state of objects like Deployments, Pods, and Nodes.
Question 6: Which field in a Pod spec controls which log output streams are captured by `kubectl logs`?
- stdout and stderr of the container process (Correct answer)
- The /var/log directory inside the container
- A dedicated log volume
- The container's syslog socket
Correct answer: stdout and stderr of the container process
Kubernetes captures logs written to stdout and stderr of the container's main process and makes them available via `kubectl logs`.
Question 7: When using Grafana with Prometheus in Kubernetes, what is the primary role of a Grafana datasource?
- It defines the connection to Prometheus for querying metrics (Correct answer)
- It stores historical metric data
- It generates alert notifications
- It scrapes metrics from pods directly
Correct answer: It defines the connection to Prometheus for querying metrics
A Grafana datasource configures the connection endpoint and credentials for Grafana to query Prometheus (or other backends) for metric data.
Which Kubernetes resource allows you to define alerting rules based on Prometheus metrics?