added NV CVE db version function

This commit is contained in:
Jonas Forsberg 2022-05-24 09:23:40 +02:00
parent 13c81c09da
commit 63448ef3b9
No known key found for this signature in database
GPG Key ID: F2E9818C70350CC9

View File

@ -64,3 +64,14 @@ function k8s_list_deprecation_apis(){
fi fi
kubectl get --raw /metrics | prom2json | jq -c '.[] | select(.name=="apiserver_requested_deprecated_apis").metrics[].labels' | column -t -s'{}[],"' kubectl get --raw /metrics | prom2json | jq -c '.[] | select(.name=="apiserver_requested_deprecated_apis").metrics[].labels' | column -t -s'{}[],"'
} }
function neuvector_cve_db_version(){
local NAMESPACE="cattle-neuvector-system"
printf "%-40s %s\n" "Pod" "CVE DB version"
for POD in $(kubectl -n $NAMESPACE get pods -l 'app=neuvector-scanner-pod' --template "{{range .items}}{{.metadata.name}}{{\"\n\"}}{{end}}"); do
version="$(kubectl -n "$NAMESPACE" logs "$POD" | grep "Expand new DB" | tail -1 | sed -n 's/.*Expand new DB - version=\([0-9]*\.[0-9]*\)/\1/p')"
printf "%-40s %s\n" "$POD" "$version"
done
}