Rahul Roshan Kachchap 6d3cfd86ee Add system health check for psp policy
Removal of PSP Support as part of k8s 1.25/1.26 transition,
adding a check in the system health-query that there are
NO PSP policies present in the cluster. With the release of
Kubernetes v1.25, PodSecurityPolicy has been deprecated.
We can read more information about the removal of PodSecurityPolicy
in the Kubernetes 1.25 release notes here:
https://kubernetes.io/blog/2021/04/06/podsecuritypolicy-deprecation
-past-present-and-future/
The check should FAIL the scenario and log the error output in
sysinv log with the psp resource names exisitng in the cluster,
asking the user to remove it before the upgrade.

Test Plan
AIO-SX: Perform system health-query
PASS: Iso creation
PASS: bootstrap
PASS: RUN system health-query with no PSP policies
      Output:
      System Health:
      All hosts are provisioned: [OK]
      All hosts are unlocked/enabled: [OK]
      All hosts have current configurations: [OK]
      All hosts are patch current: [OK]
      No alarms: [OK]
      All kubernetes nodes are ready: [OK]
      All kubernetes control plane pods are ready: [OK]
      All PodSecurityPolicies are removed: [OK]
PASS: RUN system health-query with existing PSP policies
      Output:
      System Health:
      All hosts are provisioned: [OK]
      All hosts are unlocked/enabled: [OK]
      All hosts have current configurations: [OK]
      All hosts are patch current: [OK]
      No alarms: [OK]
      All kubernetes nodes are ready: [OK]
      All kubernetes control plane pods are ready: [OK]
      All PodSecurityPolicies are removed: [Fail]
      PSP policies exists, please remove them before
      upgrade: privileged, restricted
PASS: RUN system health-query-kube-upgrade with no PSP policies
PASS: RUN system health-query-kube-upgrade with existing PSP policies
      All hosts are provisioned: [OK]
      All hosts are unlocked/enabled: [OK]
      All hosts have current configurations: [OK]
      All hosts are patch current: [OK]
      No alarms: [OK]
      All kubernetes nodes are ready: [OK]
      All kubernetes control plane pods are ready: [OK]
      All PodSecurityPolicies are removed: [Fail]
      PSP policies exists, please remove them before
      upgrade: privileged, restricted
      All kubernetes applications are in a valid state: [OK]
PASS: RUN system health-query-upgrade with no PSP policies
PASS: RUN system health-query-upgrade with existing PSP policies
      All hosts are provisioned: [OK]
      All hosts are unlocked/enabled: [OK]
      All hosts have current configurations: [OK]
      All hosts are patch current: [OK]
      No alarms: [OK]
      All kubernetes nodes are ready: [OK]
      All kubernetes control plane pods are ready: [OK]
      All PodSecurityPolicies are removed: [Fail]
      PSP policies exists, please remove them before
      upgrade: privileged, restricted
      No imported load found. Unable to test further

Story: 2010590
Task: 48145

Change-Id: I3787bdce505c2d18f5312fc32e95c507d8916b3d
Signed-off-by: Rahul Roshan Kachchap <rahulroshan.kachchap@windriver.com>
2023-06-01 05:56:54 -04:00
..