First, I’m not sure if you’ve seen it, but our Deploy Kubernetes Container built-in step should do this natively. If that looks like it might work, then it might be the easiest way to accomplish what you’re after.
If your scenario requires using the Deploy raw Kubernetes YAML step, then a way you could accomplish this is by adding a Run a Script step to your deployment process that runs on your deployment target (the K8s cluster) with something like one of the following kubectl commands:
kubectl rollout status deployment/YOURDEPLOYMENT
This should return a status on that deployment that you can act on.
kubectl get deployments
Would return the deployments and their statuses, which you could parse to determine if they’re successful.
These in combination with some error handling as shown in our documentation in the following area should get you close to what you’re hoping to do: Error handling - Octopus Deploy