From 2f6b61ae0956bdc3d7370edb69609775d09aa393 Mon Sep 17 00:00:00 2001 From: Natan Yellin Date: Thu, 9 Jan 2025 10:19:53 +0200 Subject: [PATCH] Kubectl jq (#168) Co-authored-by: arik Co-authored-by: Dima Chievtaiev --- holmes/plugins/toolsets/kubernetes.yaml | 7 ++++++- poetry.lock | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/holmes/plugins/toolsets/kubernetes.yaml b/holmes/plugins/toolsets/kubernetes.yaml index 4bcb4c3a..31948055 100644 --- a/holmes/plugins/toolsets/kubernetes.yaml +++ b/holmes/plugins/toolsets/kubernetes.yaml @@ -125,7 +125,12 @@ toolsets: } print namespace, name, sum_memory(requests) " Mi"; }' | sort -k3 -nr - + + - name: "kubernetes_jq_query" + description: > + Use kubectl to get json for all resources of a specific kind pipe the results to jq to filter them. Do not worry about escaping the jq_expr it will be done by the system on an unescaped expression that you give. e.g. give an expression like .items[] | .spec.containers[].image | select(test("^gcr.io/") | not) + command: kubectl get {{ kind }} --all-namespaces -o json | jq -r {{ jq_expr }} + # NOTE: this is only possible for probes with a healthz endpoint - we do this to avoid giving the LLM generic # http GET capabilities which are more powerful than we want to expose diff --git a/poetry.lock b/poetry.lock index a28d9046..e7dd9bcf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "aiohappyeyeballs" @@ -1220,13 +1220,13 @@ files = [ [[package]] name = "jinja2" -version = "3.1.4" +version = "3.1.5" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" files = [ - {file = "jinja2-3.1.4-py3-none-any.whl", hash = "sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d"}, - {file = "jinja2-3.1.4.tar.gz", hash = "sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369"}, + {file = "jinja2-3.1.5-py3-none-any.whl", hash = "sha256:aba0f4dc9ed8013c424088f68a5c226f7d6097ed89b246d7749c2ec4175c6adb"}, + {file = "jinja2-3.1.5.tar.gz", hash = "sha256:8fefff8dc3034e27bb80d67c671eb8a9bc424c0ef4c0826edbff304cceff43bb"}, ] [package.dependencies]