Helm deployment based on cluster status

Cluster information:

Kubernetes version: Client Version: v1.19.7
Server Version: v1.19.16
Cloud being used: (put bare-metal if not on a public cloud) Rancher
Installation method: Terraform
Host OS: control plane Centos7, worker nodes Centos 8
CNI and version: flannel 0.15.1
CRI and version: docker 20.10.6

My cluster is set up with two different StatefulSet (data-az1 and data-az2), deployed in two different availability zone (AZ1 and AZ2). We want to deploy in following orders (helm install/upgrade).

Before the deployment , want to check cluster health status and if it’s Green then bring down all the pods at a time in AZ1, wait for cluster to turn into Green and then do the deployment in AZ1. Once the deployment is completed it will again check the cluster status before deploying in AZ2… In any stage it should not deploy if Cluster is not healthy (Green). I have bash script to check the health status. I know with kubernetes job using “helm.sh/hook”: pre-install,pre-upgrade/post-install,post-upgrade and with script we can check the health status. But not getting idea to proceed further like bring down pods and do the deployment based on the cluster health health status. Can I implement all this steps within a single job… Or we need separate job for pre/post install/upgrade for both AZ.

Could anyone please suggest how can I achieve it.

I able to fix that by creating a health checker job and enabled it by passing arguments with helm deployment for respective zone.

Something like:

helm upgrade opensearch-test-az2 . --install -f values.yaml -f values.AZ2.DEV.yaml --wait --timeout 10m --set healthCheckerJob.enabled=true