From 52ba79c07aa517160698ee7e04797447448ebf3c Mon Sep 17 00:00:00 2001 From: Parth Inamdar Date: Mon, 29 Nov 2021 22:01:38 -0500 Subject: Added Security, Policy, Observability & Plugin Checks Security Checks: Checking for security config on the cluster, consisting of capability, privilege, host network, host path and connectivity checks Policy Checks: Validating CPU Manager and Topology Manager policies against the settings from PDF Observability Checks Checking existence and health of prometheus, node-exporter and collectd pods Plugin checks Checking for the existence of multi-interface pod (multus) and validating the list of CNI against the PDF Also added usage information and pdf field information to userguide.rst file in the docs section. For reference, I have added a PDF.json in sdv/docker/sdvstate/settings section file to look at necessary configuration required for the kuberef validation. Signed-off-by: Parth V Inamdar Change-Id: I28dc8e687c14cba099230f2226b4add79a55a7ad --- .../validator/kuberef/kubevirt_health_check.py | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 sdv/docker/sdvstate/internal/validator/kuberef/kubevirt_health_check.py (limited to 'sdv/docker/sdvstate/internal/validator/kuberef/kubevirt_health_check.py') diff --git a/sdv/docker/sdvstate/internal/validator/kuberef/kubevirt_health_check.py b/sdv/docker/sdvstate/internal/validator/kuberef/kubevirt_health_check.py new file mode 100644 index 0000000..08bb3c7 --- /dev/null +++ b/sdv/docker/sdvstate/internal/validator/kuberef/kubevirt_health_check.py @@ -0,0 +1,44 @@ +""" +Kubevirt Check +Checks the existence and health of kubevirt +""" + +import logging +from tools.kube_utils import kube_api +from internal.checks.pod_health_check import pod_status, get_logs +from internal.store_result import store_result + +def kubevirt_check(): + """ + Checks for existence kubevirt namespace and checks health of the pods within + + """ + k8s_api = kube_api() + namespaces = k8s_api.list_namespace() + ns_names = [] + for nspace in namespaces.items: + ns_names.append(nspace.metadata.name) + + result = {'category': 'platform', + 'case_name': 'kubevirt_check', + 'criteria': 'pass', + 'details': [] + } + + logger = logging.getLogger(__name__) + + if 'kubevirt' in ns_names: + result['criteria'] = 'pass' + result['details'].append(ns_names) + pod_list = k8s_api.list_namespaced_pod('kubevirt') + for pod in pod_list.items: + pod_stats = pod_status(logger, pod) + if pod_stats['criteria'] == 'fail': + pod_stats['logs'] = get_logs(k8s_api, pod) + result['criteria'] = 'fail' + result['details'].append(pod_stats) + else: + result['criteria'] = 'fail' + + store_result(logger, result) + return result -- cgit 1.2.3-korg