I am tring to write a bash function to check pods in kuebernetes and if all pods are healthy i.e either they are Running or Completed if not I am entering the loop and exiting with error
check_pods_status() {
  # Save the output of the kubectl command in an array
  pods_status=`kubectl get pods -o wide | grep "swarm" |  awk '{print $3}'`
  echo "============================================================================================================"
  echo "checking all the microservices in the swarm cluster are running normally ..."
  kubectl get pods -o wide | grep "swarm"
  echo "============================================================================================================"
  for status in "${pods_status[@]}"; do
    if [[ "$status" != "Running" ]] || [[ "$status" != "Completed" ]]; then
      # Print an error message and return 1
      echo "Error: One or more pods are not running or completed"
      return 1
    fi
  done
  # all pods are healthy at this point and function will return 0 whihc is true
  return 0
}
this if condition
if [[ "$status" != "Running" ]] || [[ "$status" != "Completed" ]]; then
is getting passed even if all the pods are in Running state Any suggestions? thanks
I am expecting this function to check and return error if pod status is other then Running or Completed
 
    