From b82d63e2ad42becec2f4ff277e5206cab9d7e859 Mon Sep 17 00:00:00 2001 From: Gerard Nguyen Date: Wed, 4 Dec 2024 14:12:02 +1100 Subject: [PATCH] docs: clusterContainerStatuses analyzer (#597) * new doc for container status analyzer * style fix * add restart count to sample spec --- docs/gatsby-config.js | 1 + .../analyze/cluster-container-statuses.md | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 docs/source/analyze/cluster-container-statuses.md diff --git a/docs/gatsby-config.js b/docs/gatsby-config.js index 57743dd4..820647b4 100644 --- a/docs/gatsby-config.js +++ b/docs/gatsby-config.js @@ -88,6 +88,7 @@ module.exports = { "analyze/ceph-status", "analyze/certificates", "analyze/cluster-pod-statuses", + "analyze/cluster-container-statuses", "analyze/cluster-resource", "analyze/cluster-version", "analyze/container-runtime", diff --git a/docs/source/analyze/cluster-container-statuses.md b/docs/source/analyze/cluster-container-statuses.md new file mode 100644 index 00000000..9638bec6 --- /dev/null +++ b/docs/source/analyze/cluster-container-statuses.md @@ -0,0 +1,40 @@ +--- +title: Cluster Container Statuses +description: Detecting Kubernetes containers with certain statuses +--- + +The `clusterContainerStatuses` analyzer is used to detect containers that have a certain status. It complements the existing [clusterPodStatuses analyzer](./cluster-pod-statuses) by allowing you to detect containers that are unhealthy. +The `when` attribute supports standard comparators to compare the status of the container. + +The `clusterContainerStatuses` analyzer uses data from the [clusterResources collector](https://troubleshoot.sh/collect/cluster-resources). +The `clusterResources` collector is automatically added and will always be present. + +The outcomes on this analyzer will be processed in order for each container of each pod, and execution will stop after the first outcome that is truthy. + +## Parameters + +**namespaces**: (Optional) The namespaces to look for the pods in. If not specified, it will default to all namespaces. + +**restartCount**: (Optional) Only consider containers with a restart count greater than or equal to this value. + +## Example Analyzer Definition + +```yaml +apiVersion: troubleshoot.sh/v1beta2 +kind: Preflight +metadata: + name: container-statuses +spec: + analyzers: + - clusterContainerStatuses: + checkName: oom-detector + namespaces: + - default + restartCount: 1 + outcomes: + - fail: + when: "== OOMKilled" + message: "Container {{ .ContainerName }} from pod {{ .Namespace }}/{{ .PodName }} has OOMKilled" + - pass: + message: "No OOMKilled containers found" +```