Skip to content

Commit

Permalink
node-health-check and self-node-remediation operators deployment (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebattat authored Nov 14, 2024
1 parent 9117485 commit 600fe0a
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 1 deletion.
43 changes: 43 additions & 0 deletions benchmark_runner/common/ocp_resources/create_nhc_snr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

import os

from benchmark_runner.common.oc.oc import OC
from benchmark_runner.common.logger.logger_time_stamp import logger_time_stamp, logger
from benchmark_runner.common.ocp_resources.create_ocp_resource_operations import CreateOCPResourceOperations


class CreateNHCSNR(CreateOCPResourceOperations):
"""
This class is created node-health-check and self-node-remediation operators
"""
def __init__(self, oc: OC, path: str, resource_list: list):
super().__init__(oc)
self.__oc = oc
self.__path = path
self.__resource_list = resource_list

@logger_time_stamp
def create_nhc_snr(self):
"""
This method creates node-health-check and self-node-remediation operators
:return:
"""
for resource in self.__resource_list:
logger.info(f'run {resource}')
self.__oc.create_async(yaml=os.path.join(self.__path, resource))

if '03_subscription.yaml' in resource:
# verify once after create all resource files
self.wait_for_ocp_resource_create(operator='nhc',
verify_cmd="oc get csv -n openshift-workload-availability -o jsonpath='{.items[0].status.phase}'",
status='Succeeded')
self.wait_for_ocp_resource_create(operator='snr',
verify_cmd="oc get csv -n openshift-workload-availability -o jsonpath='{.items[1].status.phase}'",
status='Succeeded')
# SNR is automatically enabled when NHC is enabled
if '04_nhc_snr.yaml' in resource:
# Verify NHC is enabled
self.wait_for_ocp_resource_create(operator='nhc',
verify_cmd="oc get nhc -A -o jsonpath='{range .items[*]}{.status.phase}{\"\\n\"}{end}'",
status='Enabled')
return True
4 changes: 4 additions & 0 deletions benchmark_runner/common/ocp_resources/create_ocp_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from benchmark_runner.common.ocp_resources.create_odf import CreateODF
from benchmark_runner.common.ocp_resources.create_kata import CreateKata
from benchmark_runner.common.ocp_resources.create_cnv import CreateCNV
from benchmark_runner.common.ocp_resources.create_nhc_snr import CreateNHCSNR
from benchmark_runner.common.ocp_resources.create_custom import CreateCustom
from benchmark_runner.common.ocp_resources.migrate_infra import MigrateInfra

Expand Down Expand Up @@ -91,6 +92,9 @@ def create_resource(self, resource: str, upgrade_version: str):
elif 'cnv' == resource:
create_cnv = CreateCNV(self.__oc, path=os.path.join(self.__dir_path, resource), resource_list=resource_files)
create_cnv.create_cnv()
elif 'nhc_snr' == resource:
create_nhc_snr = CreateNHCSNR(self.__oc, path=os.path.join(self.__dir_path, resource), resource_list=resource_files)
create_nhc_snr.create_nhc_snr()
elif 'infra' == resource:
create_infra = MigrateInfra(self.__oc, path=os.path.join(self.__dir_path, resource), resource_list=resource_files)
create_infra.migrate_infra()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: openshift-workload-availability
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: workload-availability-operator-group
namespace: openshift-workload-availability
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: node-health-check-operator
namespace: openshift-workload-availability
spec:
channel: stable
name: node-healthcheck-operator
source: redhat-operators
sourceNamespace: openshift-marketplace
package: node-healthcheck-operator
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
apiVersion: remediation.medik8s.io/v1alpha1
kind: NodeHealthCheck
metadata:
name: chaos-nodehealthcheck
spec:
minHealthy: 1
remediationTemplate:
apiVersion: self-node-remediation.medik8s.io/v1alpha1
name: self-node-remediation-automatic-strategy-template
namespace: openshift-workload-availability
kind: SelfNodeRemediationTemplate
selector:
matchExpressions:
- key: node-role.kubernetes.io/worker
operator: Exists
unhealthyConditions:
- type: Ready
status: "False"
duration: 20s
- type: Ready
status: Unknown
duration: 20s

---
apiVersion: v1
items:
- apiVersion: self-node-remediation.medik8s.io/v1alpha1
kind: SelfNodeRemediationTemplate
metadata:
annotations:
remediation.medik8s.io/multiple-templates-support: "true"
name: self-node-remediation-automatic-strategy-template
namespace: openshift-workload-availability
spec:
template:
spec:
remediationStrategy: OutOfServiceTaint
kind: List
metadata:
resourceVersion: ""
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ END
steps {
script {
// cnv first for “-virtualization” storage class name for Win bootstorm
def resources = ['cnv', 'lso', 'odf', 'infra', 'custom']
def resources = ['cnv', 'lso', 'odf', 'nhc_snr', 'infra', 'custom']

for (resource in resources) {
echo "Run Operator Deployment for ${resource}"
Expand Down

0 comments on commit 600fe0a

Please sign in to comment.