-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
node-health-check and self-node-remediation operators deployment (#926)
- Loading branch information
Showing
7 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
benchmark_runner/common/ocp_resources/nhc_snr/template/01_namespace_template.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: openshift-workload-availability |
5 changes: 5 additions & 0 deletions
5
benchmark_runner/common/ocp_resources/nhc_snr/template/02_operator_group_template.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
11 changes: 11 additions & 0 deletions
11
benchmark_runner/common/ocp_resources/nhc_snr/template/03_subscription_template.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
41 changes: 41 additions & 0 deletions
41
benchmark_runner/common/ocp_resources/nhc_snr/template/04_nhc_snr_template.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters