<p>I have an AKS cluster with Kubernetes version 1.14.7.</p>

<p>I have build CI/CD pipelines to deploy newly created images to the cluster. </p>

<p>I am using kubectl apply to update a specific deployment with the new image. sometimes and for many reasons, the deployment fails, for example ImagePullBackOff. </p>

<p>is there a command to run after the kubectl apply command to check if the pod creation and deployment was successful? </p>

<p>For this purpose Kubernetes has  <code>kubectl rollout</code> and you should use option <code>status</code>.</p>

<blockquote>
  <p>By default 'rollout status' will watch the status of the latest rollout until it's done. If you don't want to wait for the rollout to finish then you can use --watch=false. Note that if a new rollout starts in-between, then 'rollout status' will continue watching the latest revision. If you want to pin to a specific revision and abort if it is rolled over by another revision, use --revision=N where N is the revision you need to watch for.</p>
</blockquote>

<p>You can read the full description <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#rollout" rel="noreferrer">here</a></p>

<p>If you use <code>kubect apply -f myapp.yaml</code> and check <code>rollout status</code> you will see:</p>

<pre><code>$ kubectl rollout status deployment myapp
Waiting for deployment "myapp" rollout to finish: 0 of 3 updated replicas are available…
Waiting for deployment "myapp" rollout to finish: 1 of 3 updated replicas are available…
Waiting for deployment "myapp" rollout to finish: 2 of 3 updated replicas are available…
deployment "myapp" successfully rolled out
</code></pre>
