diff --git a/.functions/kubernetes.sh b/.functions/kubernetes.sh index 3138fcc..8f9ea23 100644 --- a/.functions/kubernetes.sh +++ b/.functions/kubernetes.sh @@ -64,3 +64,14 @@ function k8s_list_deprecation_apis(){ fi 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 +}