aboutsummaryrefslogtreecommitdiffstats
path: root/sdv/docker/sdvstate/internal/validator/kuberef/kubevirt_health_check.py
diff options
context:
space:
mode:
authorParth Inamdar <parth.inamdar1@gmail.com>2021-11-29 22:01:38 -0500
committerParth Inamdar <parth.inamdar1@gmail.com>2021-11-30 05:25:24 +0000
commit52ba79c07aa517160698ee7e04797447448ebf3c (patch)
tree5a27ed50d5f75d21eaf789ae027ac7e899cb254d /sdv/docker/sdvstate/internal/validator/kuberef/kubevirt_health_check.py
parentbfd37762bdf91a7f89d4ebc259454ddb2f5e7b3d (diff)
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 <parth.inamdar1@gmail.com> Change-Id: I28dc8e687c14cba099230f2226b4add79a55a7ad
Diffstat (limited to 'sdv/docker/sdvstate/internal/validator/kuberef/kubevirt_health_check.py')
-rw-r--r--sdv/docker/sdvstate/internal/validator/kuberef/kubevirt_health_check.py44
1 files changed, 44 insertions, 0 deletions
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