From 5fae6ae1dfefa1e54f1be042a04bc850347cf1c9 Mon Sep 17 00:00:00 2001 From: Miguel Varela Ramos Date: Mon, 2 Dec 2024 11:19:06 +0000 Subject: [PATCH 1/2] docs: example for matchExpressions filtering --- docs/source/analyze/node-resources.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/source/analyze/node-resources.md b/docs/source/analyze/node-resources.md index 61bd1b30..c45354d8 100644 --- a/docs/source/analyze/node-resources.md +++ b/docs/source/analyze/node-resources.md @@ -157,6 +157,27 @@ Troubleshoot allows users to analyze nodes that match one or more labels. For ex message: This cluster has a node with enough memory and cpu capacity running Mongo Operator. ``` +Alternatively, you can use `matchExpressions` to specify a list of selector label expressions that the node needs to match in its metadata. +```yaml + - nodeResources: + checkName: Must have Mongo running + filters: + allocatableMemory: 16Gi + cpuCapacity: "5" + selector: + matchExpressions: + - key: kubernetes.io/role + operator: In + values: + - database-primary-replica + outcomes: + - fail: + when: "count() < 1" + message: Must have 1 node with 16 GB (available) memory and 5 cores (on a single node) running Mongo Operator. + - pass: + message: This cluster has a node with enough memory and cpu capacity running Mongo Operator. +``` + ## Message Templating To make the outcome message more informative, you can include certain values gathered by the NodeResources collector as templates. The templates are enclosed in double curly braces with a dot separator. The following templates are available: From d1bace41357d81d3dd0b1c6c5f4aae7eab3fa143 Mon Sep 17 00:00:00 2001 From: Miguel Varela Ramos Date: Mon, 2 Dec 2024 14:27:29 +0000 Subject: [PATCH 2/2] docs: create version note --- docs/source/analyze/node-resources.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/analyze/node-resources.md b/docs/source/analyze/node-resources.md index c45354d8..cc8e28c8 100644 --- a/docs/source/analyze/node-resources.md +++ b/docs/source/analyze/node-resources.md @@ -157,6 +157,8 @@ Troubleshoot allows users to analyze nodes that match one or more labels. For ex message: This cluster has a node with enough memory and cpu capacity running Mongo Operator. ``` +> Filtering by labels with `matchExpressions` was introduced in Troubleshoot 0.113.0. + Alternatively, you can use `matchExpressions` to specify a list of selector label expressions that the node needs to match in its metadata. ```yaml - nodeResources: