From e3b5d40b160709c81be66096b470f1b46dd9a4db Mon Sep 17 00:00:00 2001 From: Evans Mungai Date: Fri, 6 Dec 2024 06:58:08 -0700 Subject: [PATCH] chore: Add matchExpressions node resources analyser example (#598) * chore: Add matchExpressions node resources analyser example Signed-off-by: Evans Mungai * Move matchExpressions to correct section Signed-off-by: Evans Mungai --------- Signed-off-by: Evans Mungai --- docs/source/analyze/node-resources.md | 31 +++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/source/analyze/node-resources.md b/docs/source/analyze/node-resources.md index 61bd1b30..5a113556 100644 --- a/docs/source/analyze/node-resources.md +++ b/docs/source/analyze/node-resources.md @@ -157,6 +157,33 @@ 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. ``` +```yaml +- nodeResources: + checkName: Must have at least 1 node with 3 cores that is not a storage, queue or control plane node + filters: + cpuCapacity: "3" + selector: + matchExpressions: + # An AND operation will be applied to this list of expressions + # Nodes that are not storage or queue nodes + - key: node.kubernetes.io/role + operator: NotIn # Other operations are In, Exists, DoesNotExist + values: # An OR operation i.e any node that does not have "node.kubernetes.io/role=storage" or "node.kubernetes.io/role=queue" label + - storage + - queue + # Nodes that are not control-plane nodes + - key: node-role.kubernetes.io/control-plane + operator: NotIn + values: + - "true" + outcomes: + - pass: + when: "count() >= 1" + message: "Found {{ .NodeCount }} nodes with at least 3 CPU cores" + - fail: + message: "{{ .NodeCount }} nodes do not meet the minimum requirements" +``` + ## 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: @@ -178,7 +205,7 @@ To make the outcome message more informative, you can include certain values gat ```yaml - nodeResources: filters: - cpuArchitecture: arm64 + cpuArchitecture: arm64 checkName: Must have at least 3 nodes in the cluster outcomes: - fail: @@ -195,7 +222,7 @@ To make the outcome message more informative, you can include certain values gat - nodeResources: filters: cpuArchitecture: arm64 - cpuCapacity: "2" + cpuCapacity: "2" checkName: Must have at least 3 nodes in the cluster outcomes: - fail: